Jump to content

HELP: mysql_query(): supplied argument is not a valid MySQL-Link resource


Recommended Posts

I keep tinkering around, trying to fix this error: mysql_query(): supplied argument is not a valid MySQL-Link resource

 

Here is the code in question:

 

$dbhost = 'localhost';

$dbuser = 'xxxx';

$dbpass = 'xxxx';

 

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = 'books';

mysql_select_db($dbname);

 

$query = "INSERT INTO bookresponses (name, email, bridge, beatles, catch, memoriam, wild, matarese, esebius, french, wave, link, body, earth, questions " .

"VALUES ('$name', '$email', '$bridge', '$beatles', '$catch', '$lord', '$wild', '$lud', '$church', '$french', '$wave', '$link', '$body', '$earth', '$questions')";

 

$result = mysql_query($conn,$query)

or die('Error querying database.');

 

mysql_close($conn);

 

 

Thanks for any help and suggestions in advance!

If you output the query statement in $query and output mysql_error() as part of your error reporting, it will help by letting you see what the query actual is and by indicating what mysql found wrong with the query.

I am really struggling here.  I've changed the code to:

 

$dbhost = 'localhost';

$dbuser = 'xxxx';

$dbpass = 'xxxx';

 

$conn = mysqli_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = 'boompah1_books';

mysqli_select_db($dbname);

 

$query = "INSERT INTO bookresponses (name, email, bridge, beatles, catch, memoriam, wild, matarese, esebius, french, wave, link, body, earth, questions " .

"VALUES ('$name', '$email', '$bridge', '$beatles', '$catch', '$lord', '$wild', '$lud', '$church', '$french', '$wave', '$link', '$body', '$earth', '$questions')";

 

$result = mysqli_query($conn, $query)

or die('Error querying database.');

 

mysql_close($conn);

 

 

But now I get: Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in /home/boompah1/public_html/librarylasso.com/books.php on line 34

Error querying database.

Stick with mysql for now not mysqli, because you need to enable the mysqli extension in php.ini if you want to use it. And in mysqli_select_db() its $conn, $dbname

 

Plus

In your query, make it mysql_query($query, $conn) or die(mysql_error());

then it will tell you what is happening wrong in your queries

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.