[SOLVED]Odd problem
Posted: Tue Jul 20, 2004 2:15 pm
Okay, this takes me right back to square one with php, no understanding what the heck is wrong with the MySQL querty I just wrote. (this is so 2 years ago...)
Anyway, here is the code...
The db_connect() function:
The problem is, it displays the query (echo $registeration_query;), but does not display "Success" (echo "Success"). The really hilarious thing is that I took the oputput of echo $registeration_query;, and punced it into phpmyadmin as a custiom query...and it bloody worked...So I really don't know what the heck is wrong...
Please help...
Code: Select all
db_connect(); //connect to database...
//damn, this is one long query....
$registeration_query = "INSERT INTO `users` (`username`, `pass`, `email`, `age`,
`religion`, `smoke`, `drink`, `sex_pref`, `status`, `occupation`,`website`, `phys_height`,
`phys_body_type`, `phys_eye_colour`, `phys_hair_colour`, `from_country`,
`gender`, `about_self`, `user_status`) VALUES ('".mysql_escape_string($_POST['username'])
."', '".mysql_escape_string(md5($_POST['pass']))."', '".mysql_escape_string($_POST['email'])
."', '".$_POST['age']."', '".$_POST['religion']."', '".$_POST['smoke']."', '".$_POST['drink']
."', '".$_POST['pref']."', '".$_POST['status']."', '".mysql_escape_string($_POST['occupation'])
."', '".mysql_escape_string($_POST['website'])."', '".mysql_escape_string($_POST['height'])
."', '".mysql_escape_string($_POST['bodytype'])."', '".mysql_escape_string($_POST['eye_colour'])
."', '".mysql_escape_string($_POST['hair_colour'])."', '".mysql_escape_string($_POST['from_country'])
."', '".$_POST['gender']."', '".mysql_escape_string($_POST['about_self'])."', 'normal')";
//whew
echo $registeration_query;
$result = mysql_query($registeration_query, $db) or die(mysql_error());
echo "Success!";Code: Select all
function db_connect() {
$host="localhost";
$username="";
$password="";
$database = "my_db";
if ($db = mysql_connect($host, $username, $password)){
mysql_select_db($database, $db);
return true; }
else {
return mysql_error(); }
}Please help...