LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   MySQL Returning very strange Values in PHP Script (https://www.linuxquestions.org/questions/programming-9/mysql-returning-very-strange-values-in-php-script-245295/)

benrose111488 10-20-2004 06:45 PM

MySQL Returning very strange Values in PHP Script
 
Hello!

I've begun the ardous trek of programming my own forum... completely in SQL

And the problem arises when i try to print the values of a table. Check the code below:

$newsupostusername1=mysql_query("SELECT SUPERUSER FROM SUPERUSERPOSTS ORDER BY TIMEPOSTED DESC LIMIT 1");
$newsuposttime1=mysql_query("SELECT TIMEPOSTED FROM SUPERUSERPOSTS ORDER BY TIMEPOSTED DESC LIMIT 1");
$newsupostname1=mysql_query("SELECT POSTNAME FROM SUPERUSERPOSTS ORDER BY TIMEPOSTED DESC LIMIT 1");
$newsupost1=mysql_query("SELECT POST FROM SUPERUSERPOSTS ORDER BY TIMEPOSTED DESC LIMIT 1");


Now, One would expect this to work. But oh no, not today. On my page, this returns:


POST BY USER Resource id #7 AT Resource id #8
POST TITLE: Resource id #9.
Resource id #10


Any ideas?

Thanks in advance!

Hko 10-21-2004 09:08 AM

Quote:

$newsupost1=mysql_query("SELECT POST FROM SUPERUSERPOSTS ORDER BY TIMEPOSTED DESC LIMIT 1");

Now, One would expect this to work. But oh no, not today. On my page, this returns:

POST BY USER Resource id #7 AT Resource id #8
POST TITLE: Resource id #9.
Resource id #10
The PHP function mysql_query() executes the query, but does not return any resulting data from the database. After mysql_query(), you need to call mysql_fetch_row() after mysql_query() to get an array with the data resulting from the query.

Read all about it here (includes examples):
http://www.php.net/manual/en/function.mysql-query.php
http://www.php.net/manual/en/functio...-fetch-row.php

benrose111488 10-21-2004 11:26 AM

yayyy I got it! For those interested, I'll be posting the code I have that made it work shortly. Thanks for your help, Hko!

:D


All times are GMT -5. The time now is 05:40 AM.