Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple simple MySQL query question

Status
Not open for further replies.

kpdvx

Programmer
Dec 1, 2001
87
US
this is my code:
$result = mysql_query("issue_id, online_date, issue_title, image, first_rant, second_rant from issues where online_date=$current_date");

@extract(mysql_fetch_array($result));

echo $issue_title;

Ok. that code fails, and i get this error:
Notice: Undefined variable: issue_title

Can anyone help me out? it seems like this would work...

Also, here is my connection code if it may help:

<?
// Connecting, selecting database
$link = mysql_connect(&quot;localhost&quot;, &quot;root&quot;)
or die(&quot;Could not connect&quot;);
echo &quot;Connected to Database successfully.&quot;;
mysql_select_db(&quot;test&quot;)
or die(&quot;Could not connect to Database.&quot;);
?>
 
try this:
$myrow=mysql_fetch_array($result);
echo $myrow[2];
in place of :
@extract(mysql_fetch_array($result));
echo $issue_title; ***************************************
Party on, dudes!
[cannon]
 
is the select statement not necesassry???

$result = mysql_query(&quot;SELECT issue_id, online_date, issue_title, image, first_rant, second_rant from issues where online_date=$current_date&quot;);
 
why you do not do like this:

$result = mysql_query(&quot;SELECT issue_id, online_date, issue_title, image, first_rant, second_rant from issues where online_date=$current_date&quot;);

$array=mysql_fetch_array($result);
echo $array[&quot;issue_title&quot;];

This will work just fine.

Karver: When you use *_fetch_array it will return an array where the keys are the field names and not the order in the select. To get that, you should use *_fetch_row instead. Anikin
Hugo Alexandre Dias
Web-Programmer
anikin_jedi@hotmail.com
 
Hehe yeah, read this very late and posted while brain was not in top gear ..:) ***************************************
Party on, dudes!
[cannon]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top