Jump to content

[SOLVED] Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result


eekhoorn

Recommended Posts

Strange one this, I have checked the forum and tried everything I can that is related and it still won't work.

 

I keep getting the following error on all my code:

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource

 

I have just moved service provider and the code worked perfectly on my old site but no longer works with my new provider the code is as below.

 

Header code:

<?php
include("../counter/counter.php");
require("connection.php");
$rs = mysql_select_db("leonrcou_leonaurbooks", $conn);
?>

 

the connection works fine as I have tested this seperately.

 

The main code is as follows and is a simple query:

<?php
$sql="SELECT `book_title`
	 FROM `book_database`
	 WHERE `book_id` = `$bookid`";

$rs=mysql_query($sql,$conn);

while($row = mysql_fetch_array($rs) )
{
echo("".$row["book_title"]."");
}
?>

 

I have checked the database and everything is the same as previously

 

Its baffling me trying to figure out what is wrong as the code was working yesterday on a separate server, any help would be fantastic thanks.

 

Gav

Link to comment
Share on other sites

It might be because you havent defined what type of value you want returned

 

So try replacing

 

while($row = mysql_fetch_array($rs) )

 

For

 

while($row = mysql_fetch_array($rs, MYSQL_ASSOC))

 

I think that might work  ???

 

~ Chocopi

Link to comment
Share on other sites

try this:

 

<?php
$sql="SELECT `book_title`
	 FROM `book_database`
	 WHERE `book_id` = `$bookid`";

$rs=mysql_query($sql);

while($row = mysql_fetch_array($rs) )
{
echo("".$row["book_title"]."");
}
?>

 

If this does not solve the prob than show ur db connectivity code.

Link to comment
Share on other sites

Both generate the same error, my connection code is:

 

<?php

 

$user = "username";

 

$conn = mysql_connect("localhost", "$user", "password");

 

?>

 

it connects fine as I placed a message in before to tell me if ti was connected ok.

 

I'm starting to think that it may be my hosting provider, as the .com is still on the old server and works fine but the .co.uk is on the new server and is generating errors.

 

Gav

Link to comment
Share on other sites

try this:

 

<?php
$sql="SELECT `book_title`
	 FROM `book_database`
	 WHERE `book_id` = `$bookid`";

$rs=mysql_query($sql);

while($row = mysql_fetch_object($rs) )
{
echo("".$row["book_title"]."");
}
?>

 

May be it will work for u.

Link to comment
Share on other sites

Just generates: Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource

 

Thanks for the help, I have sent a mail to the hosting provider now to see if they can shed any light on the matter!

 

http://www.leonaur.co.uk/collections/collections.php?seriesid=1

http://www.leonaur.co.uk/books/booknumber.php?bookid=94

 

There are a couple of links out interest as to the live version of the problem.

 

Gav

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.