Forum Moderators: open
if(mysql($query, $conn)){
echo 'success';
}
else{
echo 'fail';
}
function add_user(){
$conn = mysql_connect('localhost', 'root', '1likebeans');
mysql_select_db('zees', $conn);
if((!isset($_POST['age']) and empty($_POST['age']))){
$_POST['age']="";
}
if((!isset($_POST['hobbies']) and empty($_POST['hobbies']))){
$_POST['hobbies']="";
}
echo $_POST['userid'] . ' ' . $_POST['password'] . ' ' . $_POST['email'] . ' ' . $_POST['age'] . ' ' . $_POST['hobbies'];
$query = "INSERT INTO users (username, password, email, age, hobbies)
VALUES ('$_POST[userid]', '$_POST[password]', '$_POST[email]', '$_POST[age]', '$_POST[hobbies]')";
mysql_query($query, $conn);
if(mysql_query($query, $conn)){
echo 'success';
}
else{
echo 'fail';
}
mysql_close($conn);
}
echo mysql_error($conn);
topr8 I appreciate your advice but I tried to insert null in place of an empty age field before I changed it to a varchar. That does not work.