Page 1 of 1
Displaying from DB based on $articleid
Posted: Sun Nov 19, 2006 9:40 pm
by 4Boredom
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
Posted: Sun Nov 19, 2006 9:46 pm
by feyd
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.
Re: Displaying from DB based on $articleid
Posted: Sun Nov 19, 2006 10:11 pm
by tecktalkcm0391
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
Posted: Sun Nov 19, 2006 11:16 pm
by 4Boredom
still says Query Was Empty
I tried it removing the 's too
Posted: Sun Nov 19, 2006 11:20 pm
by 4Boredom
maybe the error is with articleid=1
thats all i can think of?
Posted: Mon Nov 20, 2006 9:12 am
by volka
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('');
Re: Displaying from DB based on $articleid
Posted: Mon Nov 20, 2006 9:39 am
by onion2k
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.
Posted: Mon Nov 20, 2006 11:22 am
by RobertGonzalez
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?