RE: [PHP-DB] Warning - newby question -- $_GET

From: Date: Thu, 07 Nov 2002 02:19:42 +0000
Subject: RE: [PHP-DB] Warning - newby question -- $_GET
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-23070@lists.php.net to get a copy of this message
> I'm trying to call a script with the "?=" after the php script name in the > URL, but can't seem to pick up the variable to use in my script... > any help would be greatly appreciated :) > > I'm calling the script with this url: > http://localhost/Data/test/dbconnect2c.php?id=TestPage > > The section of the script i'm using is: > $id = $_GET['id']; > $sql="SELECT * FROM content where title=$id"; > $result=mysql_query($sql,$db); Well, for your example, $id is going to equal "TestPage", so you are making an invalid query: where title=TestPage. If you echo mysql_error(), it'll probably say something about unknown column TestPage. At the very least, use quotes: where title='$id' > Error message returned: > Warning: mysql_fetch_array(): supplied argument is not a valid MySQL > result > resource in... This means your query failed. Echo mysql_error() to determine why. Get used to using mysql_error for good debugging. ---John Holmes...

« previous php.db (#23070) next »