Help me <3

<?php $host="localhost"; $user="root"; $password="edita23022004"; $db="login"; mysql_connect($host,$user,$password); mysql_select_db($db); if(isset($_POST['form-username'])){ $uname=$_POST['form-username']; $password=$_POST['form-password']; $result=mysql_query("select * from login where user='".$uname."'AND Pass='".$password."' limit 1"); if(mysql_num_rows($result)==1){ echo " You Have Successfully Logged in"; exit(); } else{ echo " You Have Entered Incorrect Password"; exit(); } } ?>

Hey Guys,
this is my Code and the error:
FATAL ERROR syntax error, unexpected ‘is’ (T_STRING) on line number 16

Hi,

Thanks for sharing your code!
Can you press the </> and re-paste the code (from a formatted version)? It’s not really legible as is.

No, no, no, no, and no.

Where did you find this piece of code, and how old is the resource?

You’re attempting to use mysql_connect.

mysql_connect — Open a connection to a MySQL Server

Warning This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used.

I appreciate your willingness to learn PHP. That’s great! However, please try to find up-to-date resources when attempting such scripts. This is, first of all, deprecated, and not even secure. Of course you could not know this without researching the topic a little bit, and that’s fine.


Please forget everything you ever read about this piece of code, and mysql_connect.

Instead, learn how to use PDO, the much better alternative.

Everything you need is here: https://phpdelusions.net/pdo

Hope this helps you!

2 Likes