PHP Help
#1

Hi,
I got this thing: on bottom:

Warning: mysql_close(): 5 is not a valid MySQL-Link resource in C:\xampp\htdocs\UCP\index.php on line 56

line 56is: <? mysql_close($con); ?>

any help?

con - is $con = mysql_connect(SQL_SERVER, SQL_USERNAME, SQL_PASSWORD);
Reply
#2

Код:
mysql_close();
Reply
#3

Nop nothing
Reply
#4

First:
Using mysql_close() isn't usually necessary, as non-persistent open links are automatically closed at the end of the script's execution. (Source)


Second:
As Corello2010 says, using mysql_close(); should work without any errors. If you still WANT to use that function, make sure you acces $con in the same page (so that the variable still exists), and that you don't have any other variables with the name $con.
Reply
#5

connections had successful? I think no,because '5 is not a valid MySQL-Link resource ' -> mysql connection #5 ($con) isn't a valid connection ...
try with this:
if(mysql_ping($conn) <=0) die "fail to connect";
Reply
#6

Quote:
Originally Posted by Farsek
Посмотреть сообщение
connections had successful? I think no,because '5 is not a valid MySQL-Link resource ' -> mysql connection #5 ($con) isn't a valid connection ...
try with this:
if(mysql_ping($conn) <=0) die "fail to connect";
$Con = mysql_connect() or die('Connection failed '.mysql_error());

OT:

Check if the connection was success.
Check if you can select database properly.
Reply
#7

Nop, don't work... Or this warning, or a lot of them
Reply
#8

Код:
$con = mysql_connect($SQL_SERVER, $SQL_USERNAME, $SQL_PASSWORD) or die('Connection failed '.mysql_error());
Don't forget your $!!!
Reply
#9

Notice: Undefined variable: SQL_SERVER in C:\xampp\htdocs\nfengine\database.php on line 11

Notice: Undefined variable: SQL_USERNAME in C:\xampp\htdocs\nfengine\database.php on line 11

Notice: Undefined variable: SQL_PASSWORD in C:\xampp\htdocs\nfengine\database.php on line 11
Reply
#10

Quote:
Originally Posted by Lefon
Посмотреть сообщение
Notice: Undefined variable: SQL_SERVER in C:\xampp\htdocs\nfengine\database.php on line 11

Notice: Undefined variable: SQL_USERNAME in C:\xampp\htdocs\nfengine\database.php on line 11

Notice: Undefined variable: SQL_PASSWORD in C:\xampp\htdocs\nfengine\database.php on line 11
Start with start.
http://www.w3schools.com/html/default.asp
http://www.w3schools.com/php/default.asp
http://dev.mysql.com/doc/refman/5.0/en/tutorial.html

$SQL_SERVER = "localhost";
$SQL_USERNAME = "root";
$SQL_PASSWORD ="pass"; // if mysql db don't have a pass,dont put $SQL_PASSWORD
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)