Page 1 of 1

php4 - php5

Posted: Mon Oct 04, 2010 12:15 pm
by vburshteyn
Hi folks, I am new php so please excuse me for a stupid question.

I inherited some php4 code that i need to get to work on a php5 system. I fixed most items except this one.

The following statement, is supposed to pass the ID variable (depending on which article link i choose) to viewarticle.php file which then pulls it from the DB and .... Yet nothing happens.



echo ("<td width=\"86%\" height=\"25\"><a href=\"/includes/viewarticle.php?id=$art_id\" class=\"sublinks\">$art_shortname</a></td>");


when i click on the link i get -> <site name>/includes/viewarticle.php?id=3 so i am assuming it is getting the right ID just not passing it to the file.

any advice would be appreciated.

Re: php4 - php5

Posted: Mon Oct 04, 2010 12:17 pm
by John Cartwright
You'll need to post the relevant sections of your viewarticle.php script.

Basically, you need to make sure it's grabbing the id through $_GET['id'], and not through register globals (which I can only assume since your using PHP4 --- OLD!!).

Re: php4 - php5

Posted: Mon Oct 04, 2010 12:27 pm
by vburshteyn
The following is the relevant part from the viewarticle.php.
if i insert ID manually it works.


$SQL = "SELECT * FROM tbl_articles WHERE art_id LIKE '$id' LIMIT 1";
$retid = mysql_query($SQL);

if (!$retid) { echo( mysql_error()); }
else {
echo ("");
while ($row = mysql_fetch_array($retid)) {
$art_id = $row["art_id"];
$art_shortname = $row["art_shortname"];
$art_name = $row["art_name"];
$art_author = $row["art_author"];
$art_content = $row["art_content"];
$art_type = $row["art_type"];

echo ("<p><img src=\"/images/dot.jpg\" width=\"15\" height=\"18\">&nbsp;<span class=\"heading\">$art_name</span></p>");
echo ("$art_content");

Re: php4 - php5

Posted: Mon Oct 04, 2010 12:28 pm
by John Cartwright
I already gave you your answer. Also, there is no reason to use LIKE to compare against something without a wildcard. Simply use the equals operator.

Re: php4 - php5

Posted: Mon Oct 04, 2010 1:02 pm
by vburshteyn
That worked.

Thank you.