php

help with passing arguments to function

function get_tags_by_criteria($gender="%", $min_age_of_birth="%", $max_age_of_birth="%", $country="%", $region="%", $city="%", $tag="") { when i just want to pass the tag argument and let the others by default, how do i write? ive tried this but it didnt work. get_tags_by_criteria("", "", "", "", "", "", computer); ...

Is it a good practice to write subqueries in MySQL?

I am writing the following sub query for some project specific purpose: SELECT count(*) from table1 WHERE userB='$p' AND userA IN (SELECT userB FROM table1 WHERE userA='$row[username]') I was curious if this was the best practice when doing it in PHP or should I resort to the conventional way of first getting the subquery resu...

MVC function - okay in the view?

I am upgrading my site from some old spaghetti coding to some nice, clean custom MVC structure (and having fun learning in the process). On my page to display blog listings, I had a function that would help my dynamically build HREF's for the a links - to keep track of applied filters via $_GET...hard to explain...but here it is: /* AP...

Shortest path in a map

I have designed a weighted graph using a normalized adjacency list in mysql. Now I need to find the shortest path between two given nodes. I have tried to use Dijkstra in php but I couldnt manage to implement it (too difficult for me). Another problem I felt was that if I use Dijkstra I would need to consider all the nodes, that may b...

PHP share objects across multple sessions

How can i have user A and user B has the same instance of an object? I guess this would be across two different sessions. TIA. ...

Cannot connect to MySQL through PHP

Seems like a beginner question but I can't seem to figure it out ... I have a fresh Windows 7 x64 / Apache 2.2 / PHP 5.2 / MySQL 5 x64 installation. Actually I tried both IIS and Apache. But this PHP Code does not work: <? $hostname = "localhost"; $username = "xxx"; $password = "xxx"; $db = mysql_connect($hostname,$username,$passwo...

Returning neighborhood based on address with Google geocoder/API

Is there any way to effectively/accurately pull out a neighborhood within a city based on a passed in address, zip, city, state to the Google Geocoder? Whenever I try to do it via HTTP (ideal solution) It returns the following info <kml> − <Response> <name>anthonys cookies san francisco California</name> − <Status> <code>200</code> <re...

PHP MYSQL - Insert into without using column names but with autoincrement field

Hi guys, I've to insert a long form with 32 fields into a mysql table. i'd like to do that something like this: $sql="insert into tblname values (... 32 fields ...)"; Obviosly it works fine if the fiedls were in the same order as the mysql table fields. But, my table has as first field an id (auto-increment). What i want to avoid i...

where is PHP code interpreted?

where is PHP code interpreted? ...

How to make CakePHP redirect to a different action/controller?

My situation: The user is presented with a table or list of items. Beside each item they can click a checkbox to select it, and then at the bottom is a select box which says "With selected items...", and things like "delete", "move to project", "download", etc. You know the deal - bulk operations. Some of the operations will execute imm...

Remote Mysql Server connection by PHP

Hello Techies, while i execute following code $db_host = "<IP>"; // Host name $db_user = "<usr>"; // User name of your database $db_password = "<pass>"; // Password of your database $db_name="<db name>"; // Database name $con = mysql_connect($db_host,$db_user,$db_password); mysql_select_db($db_name) or die("Cannot select datab...

How to Set timer function

Hi I am doing online Exam Management, I have set a time duration for an exam to 5 min. When student attend this test, timer starts decreasing. I made this timer using javascript. What the problem is if the student refresh the page timer starts from first. How can I make the time to be static if page refreshed. ...

How do I get the current URL of my script using PHP?

How do I get the current URL of my script using PHP? ...

php strtotime is choking on time zone string

<?php echo "Hello?"; $thetime = strtotime("Wed Dec 16 2009 00:00:00 GMT-0500 (Eastern Standard Time)"); var_dump($thetime); ?> This code evaluates to "bool(false)"; however, just removing "(Eastern Standard Time)" allows the strtotime function to evaluate correctly. Any ideas why strtotime is choking on the time zone bit of the str...

PHP RegularExpression : match anything (including whitespaces)

text text text text text text {test} content content content {/test} text text text text text text i need to get two separate results from the above string: 1. {test} content content content {/test} 2. content content content so, what should be the two separate regular expression patterns for...

How is steganography implemented in php.

Somewhere I found out steganography .. the way of storing or hiding information within another information.. at times certain images are also used to hide the information.. Can i get an example or any thing further to know more about how this is implemented... or if at all is it possible to use this in php ...

Server getting slow on ajax calls

Hi, In my webpage, I need to display the some information which will be updating frequently. For that I am using ajax calls, and showing it in the page using innerHTML. Im making the ajax request on each 3 seconds.. And in the php page (ajax request handler), Im opening the mysql connection using mysql_connect and at the end of the scri...

Looking for software which can build PHP scripts into Mac executables

I found roadsend and phc but failed to install either one of them. Is there any other software that can build PHP scripts into Mac applications? ...

Mysqli abstraction, fetching arrays from prepared statements

Lately I've stumbled upon an error in a lib that used to work just fine, and I'll be damned if I can figure out where it is. The code sample is below, and I apologize for the debug stuff that's inside it, but I'm trying to get it to work. The problem is that $temp is an array with correct key (the name of the columns) but all the value...

PHP: How to detect if a certain class has constructor?

Hello All, How do i detect of a certain class has constructor method in it? eg: function __construct() { } ...