Home  >  Q&A  >  body text

When querying data from MYSQL, using mysql_query() always returns false, but is there no problem with the SQL statement?

<?php

//Create database connection

$conn=mysql_connect("localhost","arvin","123");

// Determine whether the data inventory connection is normal

if(!$conn)

{

die('Could not connect:'.mysql_error());

}

//Open the database

$selected=mysql_select_db("study",$conn);

//Write SQL statement

$sql1="select * from phone";

$result=mysql_query($sql1,$conn);

var_dump($result)1542898645295133.jpg;

?>



“Arvin“Arvin2131 days ago1580

reply all(1)I'll reply

  • Summer

    Summer2018-11-23 10:05:40

    I have never written a native database connection, but I feel that selecting a database is not used here

    reply
    0
  • “Arvin

    I changed the PHP version to 7.2 and then used mysqli_query() and it became normal. . As for the previous one, I don’t know what the problem was. I can only use the higher version temporarily to check.

    “Arvin · 2018-11-23 10:08:35
  • Cancelreply