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.
php4 - php5
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: php4 - php5
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!!).
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!!).
-
vburshteyn
- Forum Newbie
- Posts: 3
- Joined: Mon Oct 04, 2010 12:10 pm
Re: php4 - php5
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\"> <span class=\"heading\">$art_name</span></p>");
echo ("$art_content");
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\"> <span class=\"heading\">$art_name</span></p>");
echo ("$art_content");
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: php4 - php5
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.
-
vburshteyn
- Forum Newbie
- Posts: 3
- Joined: Mon Oct 04, 2010 12:10 pm
Re: php4 - php5
That worked.
Thank you.
Thank you.