Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What operating system is the remote host running PHP using? Perhaps MySQL isn't enabled in <code>php.ini</code>. Also, please don't use <code>mysql_*</code> functions for new code. They are no longer maintained and the community has begun the <a href="http://news.php.net/php.internals/53799" rel="nofollow">deprecation process</a> (see the <a href="http://uk.php.net/manual/en/function.mysql-connect.php" rel="nofollow">red box</a>). Instead, you should learn about <a href="http://en.wikipedia.org/wiki/Prepared_statement" rel="nofollow">prepared statements</a> and use either <a href="http://php.net/pdo" rel="nofollow">PDO</a> or <a href="http://php.net/mysqli" rel="nofollow">MySQLi</a>. If you can't decide which, <a href="http://php.net/manual/en/mysqlinfo.api.choosing.php" rel="nofollow">this article</a> will help you. If you care to learn, <a href="http://www.php.net/manual/en/pdo.connections.php" rel="nofollow">this is a good PDO tutorial</a>.</p> <p>Have you tried using PDO or the MySQLi interface? If you're trying to learn PHP, you <em>should not be using the mysql_</em>* functions regardless. See if you can access the database by using a line similar to this:</p> <pre><code>$dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass); </code></pre> <p>If you need more detailed documentation, this code comes directly from the <a href="http://www.php.net/manual/en/pdo.connections.php" rel="nofollow">documentation itself</a>.</p> <p>EDIT: Also, try using PDO's error checking functionality. This example creates a database connection using PDO and tries to perform a simple query. It doesn't use prepared statements or any of those features, so it's not production-ready code (i.e. *don't just throw this into your code without understanding how to improve it) and you'll need to edit it to include a <code>SELECT</code> query that's relevant to your database, but it should at least tell PDO to provide more information about the errors it encounters. </p> <pre><code>&lt;?php error_reporting(E_ALL); ini_set('display_errors', 1); $dbhost = "localhost"; $dbname = "test"; $dbuser = "root"; $dbpass = "admin"; // database connection $conn = new PDO("mysql:host=$dbhost;dbname=$dbname",$dbuser,$dbpass); // query $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "SELECT * FROM booksa"; $q = $conn-&gt;query($sql) or die("ERROR: " . implode(":", $conn-&gt;errorInfo())); $r = $q-&gt;fetch(PDO::FETCH_ASSOC); print_r($r); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload