RE: Warning - newby question -- $_GET

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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...



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux