vipul_vj vipul_vj - 1 year ago 124
MySQL Question

Php sign-up error

<?php include './includes/connect_db.php' // connecting to mysql server ?>
<?php include './includes/select_db.php' // selecting database ?>
$sql="insert into table 'users' values ('$username','$password','$email')";
echo "query executed";
echo "query did not run ".mysql_error();
} ?>

<?php include './includes/close_db.php' ; //closing connection ?>

the table consists of 4 fields, (id,username,password,email).
"id" is the primary key and auto incremented.
everything is working fine except the query and php is not diplaying what error is in query despite display_error is ON is .ini file.

Answer Source

couple of problems there.. Firstly, you dont need to start and close the php interpreter so many times (using php open and close tags for your includes).. just open it once.

You haven't defined connect - and I'd recommend keeping it outside of your if statement. From what I can see there, it won't connect where it is anyway.. but I can't see how you've defined it.

Set up your db connection first, and then change your $sql to read;

$sql="INSERT INTO 'users' 
values ('{$username}','{$password}','{$email}')";

That should then work fine for you.

Best of luck with it!

  • Eoghan
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download