简体   繁体   中英

mysql_connect doesn't return anything

Heres my code. Simple.

<?php
echo 'start<br>';

//Do the conntection
$checkconnection = mysql_connect('localhost', 'root', 'rootpass');

//Check if it's valid
if(!$checkconnection) {

    echo 'CheckFailed';

} else{


    echo 'CheckSucess';

}

echo 'end'; ?>

but I only can see 'start'. There is no 'CheckFailed', 'CheckSucess', 'end'

What should I do?

I already install mysql, create database, create tables, of course.

<?php
// Create connection
$con=mysqli_connect("localhost","root","root","database");

// Check connection
if (mysqli_connect_errno($con))
{
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  return false;
}

$result = mysqli_query($con, "SELECT * FROM table;");
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM