php

PHP/MySQL 2 'while' statements from 1 mysql query?

Hi, I was wondering if it's possible to have 2 'while' statements using the same 'mysql_query'? I'm using a jquery thumb gallery with the results pulled in from a database. The gallery requires that the images are grouped together in an unordered list, with the text/overlayed content grouped together in hidden divs which need to be sep...

Multi-Level Views in Drupal

The question: Publications This view has two levels. The first level will list all members who have associated Journal or Conference Paper records. The second level lists the titles of the papers for a selected member; the entries in this view are links to the actual papers. And all I can find from my professor's notes: http://im...

PHP / MySQL Error Querying Email Address

Hi, I've been trying to query an email address using the following statement, however after hours of trying to escape the string successfully I've accepted defeat. The query I am using is: SELECT id, email FROM user WHERE email = '$email' That gives me an error: MySQL Error: You have an error in your SQL syntax; check the manual ...

zend_form: is it bad practice to load a form in init() of controller

I have a form which I need for some actions but not for others. In the actions that need it, I repeat the same code. $form = New BlaBla_Form(); I've seen an example which declared it in init(). This means the form gets initialized even for actions that don't need it. It does make the code cleaner, but is it resource intensive enough ...

In PHP, how does PDO protect from SQL injections? How do prepared statements work?

I understand the right way to protect a db from SQL injection is by using prepared statements. I would like to understand how prepared statements protect my db. For starters, are prepared statements the same thing as "parameterised queries"? As an example, I'm pasting below my code for the insertion of a new user in a user table. I...

Simple PHP Login does not work.

This is my script: session_start(); include "../inc/conn.php"; if ($_GET['login']=="yes") { echo 'test2'; $username=$_POST('username'); $password=$_POST('password'); echo $username.' '.$password; $userq=mysql_query("SELECT * FROM members WHERE username='$username' AND password='$password'") or die(mysql_error()); if (mysql_num_rows($u...

How to share username+password between 2 server ?

I need to create for my blog in PHP, a chat like facebook-chat in erlang. But I don't know how to share the username+password between APACHE and Ejabberd. How do I do this ? ...

PHP: HTTP or HTTPS? How can one tell?

How can I tell if a php page was accessed via http or https? ...

php default value and non-object

i have a multipage form with some textfields. When you fill out the form and press next the form stores the values in an object. When you press the backbutton it reloads those values in textfields. This works fine. But when you initially load the form, the object isn't created so there is nothing to load the values from and i get a Call...

fetching a mail box and finding bounced email address

Hi, I want to make a script which is fetching a mail box (that only got bounced emails) every 5 min. as cron job and finding the bounced email inside that mails. And then i can make database stuff with that bounced emails. I know there are some ready to use scripts for fetching mail box, i can use em, how can i find the bounced email ad...

Echo Javascript Alert Before Redirect, usleep(2000000)? - PHP CodeIgniter

Hello, I'm trying to have a javascript alert, after a database interaction and before a page redirect (back to the same page, but displaying the updated data). I thought having a pause before the redirect with usleep() might work, but it seems to ignore it. If I comment out the redirect it takes me to the controller page, where the ale...

Using PHP to manage GMail Mail Filter XML Files

Since GMail made it possible to import and export the mail filters, I'd like to manage the XML files that are exported from GMail using a PHP script, as there are some known issues with the number of characters in the search filters. I've found the simplexml_load_file function in PHP, and have performed var_dump() against the performed ...

Get HTTP Referrer on Redirection

How can you get the HTTP Referrer when redirected from another website, not when they click on a link since it would work for $_SERVER['HTTP_REFERER'], but it doesn't work when a user has been redirected a website and the referrer would be empty. What will be the method to get the referrer? ...

How can I use __call to dynamically return property values

Hello, I've been trying to think of a way to dynamically return property values for a class using __call instead of creating a slew of functions whose only purpose would be to return those values. The idea I have is to be able to request ( for example ) $this->fetch_PersonFirstName() and have the class check if $this->person["first_name"...

How to track users across domains?

We got pitched this idea yesterday. A user visits our site and are marked. Then when they visit other sites like CNN they are targeted with adds for our site. So once they are exposed to us, they start to see us everywhere, creating the illusion we are bigger than we are. The person pitching it said it was done by cookies. I was very s...

PHP: variable (array) is function?

I dont understand the function of these characters -> in this code: $var->getImageInfo(); the function "getImageInfo()" populates the variable "$var". I can use the print_r function to display all values but how do I get a specific value echo "<pre>"; print_r($var->getImageInfo()); echo "</pre>"; returns Array ( [resoluti...

PHP Performance : Copy vs. Reference

Hey there. Today I wrote a small benchmark script to compare performance of copying variables vs. creating references to them. I was expecting, that creating references to large arrays for example would be significantly slower than copying the whole array. Here is my benchmark code: <?php $array = array(); for($i=0; $i<100000; ...

Dispatch requests to other servers based on API key

I am designing an app that requires that all requests to our servers be routed through a single 'dispatcher'-type server. This server will, based on an API key sent in the request, forward the request on to an appropriate backend server, than relay the response back to the client. eg., an incoming request could be http://example.com:657...

delete lines after fgets() if condition is met in php

hello, i have a very big text file, am using fgets() to get the contents of the file line by line. but i need to delete some text from the file if certain condition is met. ex: hello world am string number 1 hello world am string number 2 hello world am string A hello world am string B lets say a condition is met in string 1, then i...

Mobile website single quote problem

Hi, I'm getting the error below on a Nokia N80 when visiting the mobile site I wrote in PHP.... How do I resolve? XML Parsing Error: not well-formed Line Number 22, Column 45: Click here for T&Cs --------------------------------------------^ ...