mysql - mysqli connect function in PHP -
i've started mysqli. when create mysqli connection database having problem function.
my code :
$link=mysqli_connect("host", "user","password","database_name", true) or die ('i cannot connect database because: ' . mysqli_connect_error()); $query="call `database_name`.`table_name`('107','0100000000',63,122)"; $result=mysqli_query($link,$query); $rs = mysqli_fetch_array($result); $image = $rs['image']; $title = $rs['title']; echo $title; mysqli_close($link);
when execute in php code throws error.
error :
can't connect mysql server on 'host_name' (110)
but when utilize mysql extension works fine.please guide me doing mistake.
thanks
the 5th argument in mysqli_connect()
port number.
true
evaluates 1
, that's not right port. remove argument not required - default used.
in mysql_connect()
5th argument 'new link', true
appropriate.
as migrating mysqli, might want read this answer gives basic changes old mysql extension.
by way, using syntax declaring new connection, thought might want know can have more 1 connection when using mysqli. have set new variable, ie;
$link1 = new mysqli($host,$username,$password,$database); $link2 = new mysqli($host2,$username2,$password2,$database2);
then can take connection utilize when executing queries etc. example;
procedural:
$result1 = mysqli_query($link1,$sql);
oo:
$result2 = $link2->query($sql);
php mysql database mysqli
No comments:
Post a Comment