LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-20-2004, 06:45 PM   #1
benrose111488
Member
 
Registered: Jun 2004
Location: Wantage, NJ
Distribution: Fedora 7
Posts: 177

Rep: Reputation: 30
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!
 
Old 10-21-2004, 09:08 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
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
 
Old 10-21-2004, 11:26 AM   #3
benrose111488
Member
 
Registered: Jun 2004
Location: Wantage, NJ
Distribution: Fedora 7
Posts: 177

Original Poster
Rep: Reputation: 30
Talking

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!

 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Shell Script (with MySql) Tony Empire Programming 1 09-20-2005 09:59 AM
Really strange change of string values in C realos Programming 34 08-08-2005 09:32 PM
PHP HELP: values are deleted from cookies in Mozilla xbaez Programming 0 07-13-2004 11:14 PM
Accessing MySQL from a PHP script (locally) lowpro2k3 Linux - Software 2 11-23-2003 09:50 PM
Returning a PID from PHP?? Dirt Programming 5 06-14-2003 04:26 AM


All times are GMT -5. The time now is 02:22 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration