leest Posted January 12, 2008 Share Posted January 12, 2008 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']; Quote Link to comment https://forums.phpfreaks.com/topic/85631-changing-from-php4-to-php-5/ Share on other sites More sharing options...
revraz Posted January 12, 2008 Share Posted January 12, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/85631-changing-from-php4-to-php-5/#findComment-436988 Share on other sites More sharing options...
leest Posted January 12, 2008 Author Share Posted January 12, 2008 Thanks you, I don't know i have always just done it that way, but i will give it a go and hopefully it will work cheers lee Quote Link to comment https://forums.phpfreaks.com/topic/85631-changing-from-php4-to-php-5/#findComment-436991 Share on other sites More sharing options...
revraz Posted January 12, 2008 Share Posted January 12, 2008 Not saying its wrong, but what is the point of $title = $row['title']; when you do echo $row['title']; after. Quote Link to comment https://forums.phpfreaks.com/topic/85631-changing-from-php4-to-php-5/#findComment-436993 Share on other sites More sharing options...
leest Posted January 12, 2008 Author Share Posted January 12, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/85631-changing-from-php4-to-php-5/#findComment-436997 Share on other sites More sharing options...
revraz Posted January 12, 2008 Share Posted January 12, 2008 Your table name isnt database is it? Quote Link to comment https://forums.phpfreaks.com/topic/85631-changing-from-php4-to-php-5/#findComment-437007 Share on other sites More sharing options...
leest Posted January 12, 2008 Author Share Posted January 12, 2008 No I changed the details of my script Quote Link to comment https://forums.phpfreaks.com/topic/85631-changing-from-php4-to-php-5/#findComment-437012 Share on other sites More sharing options...
revraz Posted January 12, 2008 Share Posted January 12, 2008 Make sure it's not a reserved word. What does $id contain? Quote Link to comment https://forums.phpfreaks.com/topic/85631-changing-from-php4-to-php-5/#findComment-437015 Share on other sites More sharing options...
leest Posted January 12, 2008 Author Share Posted January 12, 2008 just a number Quote Link to comment https://forums.phpfreaks.com/topic/85631-changing-from-php4-to-php-5/#findComment-437018 Share on other sites More sharing options...
revraz Posted January 12, 2008 Share Posted January 12, 2008 Well, being so cryptic won't solve the issue. Feel free to post more code or the real code and maybe the error can be spotted. Make sure error reporting is turned on and check for errors either on the screen or in the log. Quote Link to comment https://forums.phpfreaks.com/topic/85631-changing-from-php4-to-php-5/#findComment-437020 Share on other sites More sharing options...
leest Posted January 12, 2008 Author Share Posted January 12, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/85631-changing-from-php4-to-php-5/#findComment-437029 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.