PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
4Boredom
Forum Contributor
Posts: 176 Joined: Tue Nov 08, 2005 4:29 pm
Post
by 4Boredom » Sun Nov 19, 2006 9:40 pm
This spits out Query was empty
Is there a more effective way then this to display title? Once I figure this out I can apply it to other vars....
submitted_articles, articleid, and title are all correct structure...
Code: Select all
$display= mysql_query("SELECT 'title' FROM 'submitted_articles' WHERE 'articleid'=1");
$result= mysql_query($display) or die ($ERROR_MSG . mysql_error());
echo'
<table width="100%">
<tr width="100%">
<td width="75%" valign="top">
<b>$title</b> - <i>Written by DeReK</i><hr>
blah
</td>....
the rest doesnt pertain
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Nov 19, 2006 9:46 pm
You've asked MySQL to select the string "title" from the string "submitted_articles" where the string "articleid" is equal to one. I believe you intended those to be field and table references, therefore recommend you remove the single quotes.
tecktalkcm0391
DevNet Resident
Posts: 1030 Joined: Fri May 26, 2006 9:25 am
Location: Florida
Post
by tecktalkcm0391 » Sun Nov 19, 2006 10:11 pm
Try...
Code: Select all
$display= mysql_query("SELECT `title` FROM `submitted_articles` WHERE `articleid`='1' ");
$result= mysql_query($display) or die ($ERROR_MSG . mysql_error());
$info = mysql_fetch_array($result);
echo "
<table width="100%">
<tr width="100%">
<td width="75%" valign="top">
<b>$info['title']</b> - <i>Written by DeReK</i><hr>
blah
</td>....
the rest doesnt pertain
4Boredom
Forum Contributor
Posts: 176 Joined: Tue Nov 08, 2005 4:29 pm
Post
by 4Boredom » Sun Nov 19, 2006 11:16 pm
still says Query Was Empty
I tried it removing the 's too
4Boredom
Forum Contributor
Posts: 176 Joined: Tue Nov 08, 2005 4:29 pm
Post
by 4Boredom » Sun Nov 19, 2006 11:20 pm
maybe the error is with articleid=1
thats all i can think of?
volka
DevNet Evangelist
Posts: 8391 Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger
Post
by volka » Mon Nov 20, 2006 9:12 am
try
Code: Select all
$result=mysql_query($display) or die ('<div>' . mysql_error(). ': ' . $display . "</div>\n");What does that print?
4Boredom wrote: still says Query Was Empty
meaning: you're not sending a query at all, like mysql_query(NULL); or mysql_query('');
onion2k
Jedi Mod
Posts: 5263 Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com
Post
by onion2k » Mon Nov 20, 2006 9:39 am
tecktalkcm0391 wrote: Code: Select all
$display= mysql_query("SELECT `title` FROM `submitted_articles` WHERE `articleid`='1' ");
$result= mysql_query($display) or die ($ERROR_MSG . mysql_error());
$display is the result of mysql_query(). Putting that into another mysql_query() isn't going to work.
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Mon Nov 20, 2006 11:22 am
Few questions to answer...
1) is there data in the table to select?
2) What is the field type for article?
3 What does
Code: Select all
SELECT `title` FROM `submitted_articles`; return?