Page 1 of 1

[Solved (keyword issue)] passing parameters via URL

Posted: Tue Nov 20, 2007 8:47 pm
by bob38
Hi there,

I have a UDT as below

===
$topic = $params['topic'];
$link = mysql_connect('mylocalhost', 'myUser', 'mypass');
mysql_select_db('mt_articlesdb');

if ($topic == "" OR $topic == "Home"){
  $result=mysql_query('SELECT * FROM articles ORDER BY ID DESC LIMIT 20', $link);
}else{
        $result = mysql_query('SELECT * FROM articles WHERE section = \''.$topic.'\' ORDER BY ID DESC LIMIT 20');
}

echo "";
    // Get an array containing the results.
    // Loop for each item in that array
    while ($row =  mysql_fetch_array($result)){
        echo "";
        echo "".$row['section'].": ";
        echo "".stripslashes($row['title'])." ";
        echo "Posted by ".$row['postedby']." on ".$row['posteddate']."";
        echo "".stripslashes($row['tagline'])."...";
        echo "Read Complete Article";
        echo "";
        echo "";
    }
echo "";
===

Trying to create a list of articles that the user clicks on to read the full article.

The problem is that I can not access the id in a UDT in the readarticle page. In fact if the id param is included the UDT in the readarticle page does not run at all. It will not echo 1. But if I remove id from the above href it does echo 1.

readarticle UDT

===
echo '1';

$link = mysql_connect('mylocalhost', 'myuser', 'mypass');
mysql_select_db('mt_articlesdb');

$articleID = $HTTP_GET_VARS['id'];
echo  '$articleID '.$articleID;

$result = $connector->query('SELECT * FROM articles WHERE ID='.$articleID);
$row =  mysql_fetch_array($result);

echo "";
  echo "";
  echo "".stripslashes($row['title'])." ";
  echo "Posted by ".$row['postedby']." on ".$row['posteddate']."";
  echo ''.stripslashes($row['thearticle']);
  echo "";
echo "";
===

The readarticle is displayed but the UDT not actioned.

What am I missing here?

Cheers
Tom

Re: passing parameters via URL

Posted: Tue Nov 20, 2007 8:52 pm
by calguy1000
don't use 'id' as a parameter..... it's reserved.  Use 'articleid', 'junk', or some other word.

Re: passing parameters via URL

Posted: Tue Nov 20, 2007 9:02 pm
by bob38
U da MAN.

Thanking you. Only spent three hours on that little sucker.

Is there a list of key words you can point me to?

Cheers
Bob

Re: passing parameters via URL

Posted: Tue Nov 20, 2007 9:04 pm
by calguy1000
well, there aren't too many

but here's a brief list:
  id
  returnid
  page
  mact

Also, you should use adodb for your database stuff, not mysql_connect, it's much easier and there won't be a problem with having to re-connect the adodb object.