I have this problem:
<?php
$link = mysql_connect('123.123.123.123', 'user', 'pass');
if (!$link) {
die('con_error: ' . mysql_error());
}
mysql_select_db('db', $link) or die(mysql_error());
echo 'connect!'."\n\n";
var_dump($link);
//var_dump($link->mysql_query('SELECT * FROM table LIMIT 1'));
mysql_close($link);
exit();
?>
There are no errors and print "connect!". But then, i can't select anything - i get this error:
Fatal error: Call to a member function mysql_query() on a non-object i
var_dump($link)
prints resource(2) of type (mysql link)
and i cant find what does it means!
All connection attributes are correct. I can connect to DB from command line... What should i do?
$link
is not an object, you cannot call methods through it!
What you want is
mysql_query('SELECT * FROM table LIMIT 1', $link);
but please note that mysql_*
functions are deprecated, use PDO
instead.