php

Calling custom PHP inside Drupal

Drupal version 6.12 I have a page whose input format is PHP. I simply want to update a database table. The SQL code appears to be too complex for db_query. I can not make db_query work nor does including php nor does dropping custom php code into the “Body” seem to work either. Any advise on how I can make the following code work in...

Instantiating a new PHP class with one or many arguments

I have this fetch function: public static function fetch($class, $key) { try { $obj = new $class($key); } catch(Exception $e) { return false; } return $obj; } It creates a new instance by calling that class's constructor and passing in the key. Now, how would I make it so I can pass in an ar...

how do i reset the value of a single session array index in codeigniter??

Using a user model which returns an array that looks like this: $user_data['display_name'] = "John Doe"; $user_data['avatar'] = ./images/user144.jpg"; i create my session using $this->session->set_userdata('user_data',$user_data); now if on another controller i let the user change his avatar, how can i replace the session variable...

Infinitely Deep Recursive Children

I have a single-table with the following (relative) structure: foo_id, parent_foo_id, foo_name I would like to build an (effectively) infinite-depth recursive array with these entities, and consequently output them into a tree menu. Nodes with no "parent_foo_id" would be considered at the top of the heirerchy, while all successive n...

How to give a print to printer in PHP-Gtk?

Hi, I want to print some records using PHP-Gtk. I am using following code but it did not worked. $handle = fopen("PRN", "w"); fwrite($handle, 'text to printer'); fclose($handle); Please help me Thanks Rahul ...

php htmlspecialchars

what type of input should I be using htmlspecialchars with? or should I always use it to sanitize input data? or are there any better 'data sanitizing' functions? That is assuming that these values will be stored in a database Example: $userdata = array( 'username' => $_POST['username'], 'email' => $_POST['email'], 'password' => $_P...

OOP - Sessions and PHP

Hi Folkes, iam a litte bit confused, i've started to learn php 5 the OO Way last year. First Projects are done with the Zend Framework. But some of my friends are talking about storing Objects in the $_SESSION Superglobal Array. But iam not able to find an good example, why or when this is nesecarry ? It would be great , if someone pe...

How to do a login in flash, and then redirect to php?

As the title said, login page should be in flash(login.swf), and the redirect to a php page (account.php). In account.php, I will need to check session, for example: isset($_SESSION['loggedin']){ echo "Welcome back, $user"; } else { echo "You need to login and main site"; } Where do I generate the sessions, and where do I store it...

Sort php array on one column and output to list

I have created an array that is populated from a wordpress loop:- <?php while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?> $alisting []["questions"] = $questions; $alisting []["id"] = $post->ID; $alisting []["title"] = $post->post_title; <?php endwhile; ?> This outputs Array ( [0] => Array ( [quest...

dynamic show/hide div controls in php with js?

I have some SQL output that id like to format into a collapsible div. The problem is that all the JS show/hide div code i find isnt really meant for dynamic instances, they all need to be pre assigned to a particular div. Since my results may vary from 1-30...this isnt really a good option. My question. Is there an easy way to dynamical...

PHP is displaying my source code?

I just upgraded to php5.3 and when I execute: php myfile.php I see the source code for myfile.php. Any idea why this is happening? I've never seen anything like it before! G-Man ...

Add a header to each request using .htaccess

I want to add a custom header to a phpbb installation without touching the code. (Using .htaccess) The header is: Strict-Transport-Security: max-age=157680000 Any ideas? ...

problem in parsing

i have a page,say abc.html, that is having a small form with some fields. <form name="form" method="post" action="abc.html">.......................</form> when we submit the form it again comes back to abc.html with some data posted and shows the resulted names on the page which came after processing the posted data. in the whole pro...

MySQL can't see column in PHP. Ok as SQL statement.

Im trying use the following insert: mysql_query ("INSERT INTO users (company_name, fname, lname, salt, email, date_added, password) VALUES ('$CompanyName', '$fname', '$lname', '$salt', '$email', '$mysqldate', '$encrypted')") or die(mysql_error()); But I get an error: Unknown column 'company_name' in 'field list' ...

Quick PHP question

Hello, I have the following excerpt: if (empty($last_db_error)) { echo "OK"; } else { echo "Error activating subscription."; echo "{$last_db_error}"; } The problem is that "{$last_db_error}" is not shown, unless I use just $last_db_error, without the quotes and brackets. Am I missing something here? Isn't the above syntax...

jquery grabbing current div or wildcard placeholder for show/hide function

i have the code below <div id=topbar> <a class="nav" href="#" onClick="if($('#embedding').css('display') == 'none') { $('#embedding').show('fast'); } else { $('#embedding').hide('fast'); } return false;">Show Details</a> <div id=embedding>Content</div> </div> In the link to show the embedding layer, is there any way instead of putting...

pass array by reference

when using arrays as parameters in functions, should I pass them by reference or by value? Or there is not that much significance? ...

What's the best Open Php newsletter manager ?

Hi :) I'm looking for a nice newsletter management solution. I tried CCmail a good script but whaere I can't imort usernames !!! I would like to find a system that is able to import Opt-in lists in the following format : John Smith;[email protected];other paramaeters...;[like] ;Male;Age... I will develop my own module if I could find...

How can i convert a file from avi to flv with php?

It's possible? I don't need the complete solution, just an hint on how to do. Everything is appreciated, thanx. ...

PHP str_replace at the URL

$uri = "http://test.com/test/?q=Marketing&amp;start=2"; $newuri = str_replace("&start=","",$url); // I want to remove "&start=2" echo $newuri; ...