Cristoforo
Cristoforo

Reputation: 17

SELECT PHP and MySQL not working

I have this code for the select and printing values. mysql_numn_rows returns null :/

<?php
mysql_connect('localhost','root','');
mysql_select_db("db2517");



$username = "Cristoforo";
$query = mysql_query("SELECT * users WHERE username='$username' ");

$numberOfRows = mysql_num_rows($query);
echo "num: $numberOfRows";


?>

Upvotes: 0

Views: 445

Answers (2)

Shanu k k
Shanu k k

Reputation: 1285

Better use mysqli or pdo instead of mysql.here you missed from in your query so your Query should be

$query = mysql_query("SELECT * from users WHERE username='$username' ");

Upvotes: 0

mageDev0688
mageDev0688

Reputation: 566

First I would like to suggest you user PDO or MYQLI

In your query you have missed the from so replace your query:

From

$query = mysql_query("SELECT * users WHERE username='$username' ");

To

$query = mysql_query("SELECT * from users WHERE username='$username' ");

Upvotes: 1

Related Questions