Jump to content

changing from php4 to php 5


leest

Recommended Posts

Hi i am working through my website and trying to convert it to work with php5, Largely most of my site works ok and every now and then i hit some thing that gives me trouble.  Largley i tend to manage to get it working, below i have a database query that works perfect in php 4 but in php 5, it doesn't work at all and when you click on to the page it is just blank.  I have tried other queries that do work, but can not understand why this one doesn't, any info would be gratefully recieved. 

 

Thanks

 


$_SESSION['id']="$id";

                   include 'connections/db.php';


$sql = "SELECT * FROM database WHERE id like '%$id%'";
  
  $result = mysql_query($sql) or die(mysql_error());
  
  while($row = mysql_fetch_array($result)){
$title = $row['title'];
$site_id = $row['site_id'];
$jobject_id = $row['object_id'];
echo $row['title']; 

Link to comment
https://forums.phpfreaks.com/topic/85631-changing-from-php4-to-php-5/
Share on other sites

I would think you would want

 

$_SESSION['id']="$id";

 

to be

 

$id = $_SESSION['id'];

 

Your SQL Query looks fine, I doubt it's there.  Nothing else that you posted looks wrong code wise.

 

Not sure why you echo $row['title'] when you can just echo $title

No totally I agree with what your saying,

 

Anyway i tried changing the session but it made no difference though i wasn't sure it would as i had tried the query earlier with out a session and had the same effect and then if i remove the whole query the page shows so it is without doubt in that section of code, but i just can't see it.

ok, i will make sure it is but i believe it is as i had an error a day or so ago.

 

this is all the code there is other than calling the session at the begining of the script, the only thing changed on the script is the database name, the id is simply an auto incemented number, which is so simple as i am only echoing the one result, but it just simply doesn't display any of the page until i remove this code.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.