Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

PHP 3 --> 4 migration

Thread Tools
 
Search this Thread
 
Old 02 April 2003, 12:57 PM
  #1  
gregh
Scooby Regular
Thread Starter
 
gregh's Avatar
 
Join Date: Dec 1999
Posts: 3,360
Likes: 0
Received 0 Likes on 0 Posts
Post

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);

?>
Old 02 April 2003, 01:23 PM
  #2  
Andrewza
Scooby Regular
 
Andrewza's Avatar
 
Join Date: Jan 2002
Posts: 667
Likes: 0
Received 0 Likes on 0 Posts
Post

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()
Old 02 April 2003, 01:30 PM
  #3  
gregh
Scooby Regular
Thread Starter
 
gregh's Avatar
 
Join Date: Dec 1999
Posts: 3,360
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 02 April 2003, 01:35 PM
  #4  
Andrewza
Scooby Regular
 
Andrewza's Avatar
 
Join Date: Jan 2002
Posts: 667
Likes: 0
Received 0 Likes on 0 Posts
Post

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"]
Old 02 April 2003, 01:39 PM
  #5  
gregh
Scooby Regular
Thread Starter
 
gregh's Avatar
 
Join Date: Dec 1999
Posts: 3,360
Likes: 0
Received 0 Likes on 0 Posts
Post

It was a post call, so that's sorted it

Thanks alot!

Greg
Old 02 April 2003, 01:44 PM
  #6  
Andrewza
Scooby Regular
 
Andrewza's Avatar
 
Join Date: Jan 2002
Posts: 667
Likes: 0
Received 0 Likes on 0 Posts
Post

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' ";
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
XRS
Computer & Technology Related
18
16 October 2015 01:38 PM



Quick Reply: PHP 3 --> 4 migration



All times are GMT +1. The time now is 03:40 AM.