Error: no MySQL-Link resource supplied in

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cturner
Forum Contributor
Posts: 153
Joined: Sun Jul 16, 2006 3:03 am
Location: My computer

Error: no MySQL-Link resource supplied in

Post by cturner »

Can someone please explain to me why this error has occurred?
Warning: mysql_close(): no MySQL-Link resource supplied in /home/blu/public_html/folder/delete.php on line 31. Thanks in advance.
Here is my code:

Code: Select all

session_start();
if (isset($_SESSION['username']) && ($_SESSION['password'])) {
	print "Welcome to the Admin Centre!";

require "config.php";

$query = "DELETE FROM diary_contents WHERE id LIMIT 1";

$r = mysql_query ($query);

if (mysql_affected_rows() == 1) {
	print '<p>The diary entry has been deleted. <a href=diary.php>Click here</a> to continue.</p>';
} else {
	print "<p>Could not delete the entry because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}

} else {
	print "You are not logged in. Please <a href=login.php>click here</a> to login.";
}
mysql_close(); // line 31
ob_end_flush();
klarinetking
Forum Commoner
Posts: 59
Joined: Mon Jul 24, 2006 9:43 am

Post by klarinetking »

You need to supply the link identifier with mysql_close.

ie. If you connected like this:

Code: Select all

$link = mysql_connect(...);
You close the connection like this:

Code: Select all

mysql_close($link);
Post Reply