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!

Error: Supplied argument is not a valid MySQL result resource

Status
Not open for further replies.

rmpuk

Technical User
Nov 19, 2001
32
GB

I'm getting this error when I upload the script to my webserver. However, it runs fine on my local installation. Am I right in thinking it's something to do with the way the remote server is configured, and if so, any ideas what I can do about it?

In my PHP script, I use the following line of code to select the data:

Code:
$result = mysql_query("SELECT * FROM tab1 WHERE catno=$formitem",$db);
then display the data as follows:

Code:
<?php printf(mysql_result($result,0,&quot;text1&quot;)) ?>

When the script runs, it says the error was caused by the second line of code.

Any ideas much appreciated!

Cheers,
RMP
 
Like this :

<?php
$link = mysql_connect(&quot;my_server&quot;, &quot;username&quot;, &quot;password&quot;);
mysql_select_db(&quot;my_db&quot;);
$result = mysql_query(&quot;SELECT * FROM tab1 WHERE catno='$formitem'&quot;);
printf(mysql_result($result,0,&quot;text1&quot;));
mysql_close($link);
?> Regards

Big Bad Dave

logo.gif


davidbyng@hotmail.com
 

Thanks, but that's the code I'm using already!

The strange thing is that it runs fine on my test box, but not on the remote one, so I think it might be to do with the config of the remote system. What though - I haven't a clue!

RMP
 

OK, fixed it.

Using <?php printf(mysql_error()); ?> found out that no database was selected as the server had prefixed my database name with my login name. Changed the select db to the right name and all was fine.

RMP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top