Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connects to MYSQL, but can't insert data?

Status
Not open for further replies.

Dissonance

Technical User
Dec 19, 2004
4
US
Well, I'm trying to get a script to insert some form data into a mysql database. Config.php contains the MYSQL connect, and I've echo'd $link and it's connected.

Register.php
Code:
<?php
include ('config.php');

$user=$_POST['username'];
$pass=$_POST['password'];
$md5pass = md5('$pass');

mysql_select_db("news");

$query = "INSERT INTO `users` ( `id` , `username` , `password` ) VALUES ( '', `".$user."` , `".$md5pass."`)";
mysql_query ($query);



// header('Location: index.php');
?>

 
Your query, for some reason, is failing. The trouble is, your code performs no error-trapping. The minimum necessary error-trapping that will give you debugging information is to change the line:

mysql_query ($query);

to read:

mysql_query ($query) or die(mysql_error());


Also, see my FAQ titled "Debugging PHP code" in this forum: faq434-2999


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top