PHP 3 --> 4 migration
#1
I'm just trying to move servers from one with php3 installed (I think) to one with php4 installed.
My search page appears broken, that worked fine on the old server and I have no idea why!
does anyone have any ideas?
// create SQL statement
$sql = "SELECT * FROM list WHERE (name LIKE '%$searchname%' OR description LIKE '%$searchname%') AND Private = 'N' ";
// execute SQL query and get result
$sql_result = mysql_query($sql,$db);
// start results formatting
echo "<TABLE border='1' cellpadding='0' cellspacing='0'>";
echo "<TR><TH>Name</TH><TH>Description</TH><TH>Cost</TH><TH>Date Added</TH>";
// format results by row
while ($row = mysql_fetch_array($sql_result)) {
$id= $row["id"];
$name = $row["name"];
$description = $row["description"];
$link = $row["link"];
$cost = $row["cost"];
$date_add = $row["date_added"];
echo "<TR><TD><a href='trackclick.php?link=$link&id=$id' target='blank'>$name</a> </TD><TD>$description</TD><TD>$cost</TD><TD>$date_add</TD></TR>";
}
echo "</TABLE>";
// free resources and close connection
mysql_free_result($sql_result);
mysql_close($connection);
?>
My search page appears broken, that worked fine on the old server and I have no idea why!
does anyone have any ideas?
// create SQL statement
$sql = "SELECT * FROM list WHERE (name LIKE '%$searchname%' OR description LIKE '%$searchname%') AND Private = 'N' ";
// execute SQL query and get result
$sql_result = mysql_query($sql,$db);
// start results formatting
echo "<TABLE border='1' cellpadding='0' cellspacing='0'>";
echo "<TR><TH>Name</TH><TH>Description</TH><TH>Cost</TH><TH>Date Added</TH>";
// format results by row
while ($row = mysql_fetch_array($sql_result)) {
$id= $row["id"];
$name = $row["name"];
$description = $row["description"];
$link = $row["link"];
$cost = $row["cost"];
$date_add = $row["date_added"];
echo "<TR><TD><a href='trackclick.php?link=$link&id=$id' target='blank'>$name</a> </TD><TD>$description</TD><TD>$cost</TD><TD>$date_add</TD></TR>";
}
echo "</TABLE>";
// free resources and close connection
mysql_free_result($sql_result);
mysql_close($connection);
?>
#2
What error do you get? Or is erroring not turned on?
Only thing I can spot offhand is you're referring to your db connection as $db in mysql_query() and as $connection in mysql_close()
Only thing I can spot offhand is you're referring to your db connection as $db in mysql_query() and as $connection in mysql_close()
#3
No error, just rather than displaying the terms I've searched for I get the whole database listed!!
cheers for the close tip, that didn't help, but it probably was stealing resources elswhere
regards,
greg
cheers for the close tip, that didn't help, but it probably was stealing resources elswhere
regards,
greg
#4
Hmm, is this code in a function or include?
If so PHP4 by default (around 4.2.0?) stopped registering GET and POST variable as globals, which would mean your $searchname would have no value and you would get the whole database.
Either turn on register_globals in php.ini or more properly replace such usage with the new 'super' global arrays of $_GET["searchname"] or $_POST["searchname"]
If so PHP4 by default (around 4.2.0?) stopped registering GET and POST variable as globals, which would mean your $searchname would have no value and you would get the whole database.
Either turn on register_globals in php.ini or more properly replace such usage with the new 'super' global arrays of $_GET["searchname"] or $_POST["searchname"]
#6
oh if you want to put one of those in a print statement or string, wrap them like this with {}:
$sql = "SELECT * FROM list WHERE (name LIKE '%{$_POST["searchname"]}%' OR description LIKE '%{$_POST["searchname"]}%') AND Private = 'N' ";
$sql = "SELECT * FROM list WHERE (name LIKE '%{$_POST["searchname"]}%' OR description LIKE '%{$_POST["searchname"]}%') AND Private = 'N' ";
Thread
Thread Starter
Forum
Replies
Last Post