Php programmers

hi to all… any php programmers out here… i have a problem in my code… here is my code… theres a lot of errors…:frowning::frowning:


$username = $_POST['username'];
$password = $_POST['password'];

if ($username&&$password)

$connect = mysql_connect("localhost","root","") or die("Couldn't connect!");
mysql_select_db("uelogin") or die("Couldn't find db");

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

$numrows = mysql_num_rows($query);

echo $numrows;

	die("Please enter and username and a password!");


1 Like

Hey Ryan, it’s been a while!

Great that you want to practice your PHP.

The first thing I noticed in your code is the extension mysql_connect. That’s a big red flag. It has been deprecated in PHP 5.5.0 and removed in PHP 7.

Now you’ll want to use PDO:

So, get acquainted with PDO, and then we’ll talk :wink:

May I recommend that you do some useful reading about PHP? The fact that you’re using mysql_connect tells me that you probably got this information from an outdated blog post, or something. You’ll absolutely want to cherry pick the information that you gather about PHP.

Some useful resources:

Quite long, but definitely worth it if you’re serious about programming in PHP. I’d read this (PHP: The Right Way) before coding anything. Trust me, if you’re serious about this, you’ll thank me later.


thank you sir for the help… and god bless…:slight_smile:

1 Like