Page 1 of 1

printf Error - argument is not a valid MySQL result resource

Posted: Thu Feb 23, 2006 2:32 pm
by okelly
Code below is working fine in Apache,PHP4,MySQL on Win2k.
I'm getting Warning: mysql_result(): supplied argument is not a valid MySQL result resource when running on the live Unix Server.

The error is coming from the printf statement (second line from bottom below)
Can anybody indicate how to fix it. Thanks
Conor O'Kelly

---------------------------------
<?php
$ArticleID = $_GET['ArticleID'] ;
$result = mysql_query("SELECT articles.ArticleID, articles.Article, articles.ShortTitle FROM articles WHERE ArticleID='$ArticleID' ",$db);
echo "<table border=0 width=800 cellspacing=0 cellpadding=0>
<tr>
<td width=800 bgcolor=#FFCC00><img border=1 src=../images/banner2.jpg></td>
</tr>
</table>" ;
echo "<table border=0 width=800 height=100% cellspacing=0 cellpadding=0 valign=top align=left>
<tr>
<td width=171 valign=top rowspan=2 bgcolor=ffffcc><p>&nbsp;&nbsp;</p></td>
<td width=598 height=6% valign=top>&nbsp;<p>You are at: <a href=../index.htm>home</a>><a href=okelly01.php?ArticleID=56>clanns</a>><a href=okelly03.php?ArticleID=55>okelly</a></td>
<td width=32</td>
</tr>
<tr>
<td width=600 valign=top align=left> ";
echo "<h1>";
printf(" %s<br>\n", mysql_result($result,0,"ShortTitle"));
echo "</h1>";

Posted: Thu Feb 23, 2006 3:19 pm
by josh
Your error is actually here

Code: Select all

$result = mysql_query("SELECT articles.ArticleID, articles.Article, articles.ShortTitle FROM articles WHERE ArticleID='$ArticleID' ",$db);

try this

Code: Select all

echo ((!$result) ? 'Mysql says: '.myql_error() : '');
put that right after your query

Warning: mysql_result(): supplied argument is not a valid My

Posted: Thu Feb 23, 2006 3:29 pm
by okelly
Ok...

Mysql says: No database selected

So i guess it's in the config.php or the upload on to the mySQL server (??)
I'll check with ISP that I've correctly uploaded the data from the test server to the live server...

Is this correct?

thanks for your help

Posted: Thu Feb 23, 2006 3:38 pm
by josh

Posted: Thu Feb 23, 2006 3:54 pm
by okelly
cool thnx :D

it's reporting "not connected"....
i'll have a closer look at the server setup & make sure i got it right

Posted: Thu Feb 23, 2006 3:58 pm
by josh
mysql_connect()

a little rtfm goes a long way :wink: