javascript - The correct way to use PHP's mysql_connect functionality? -
i creating registration form using jquerys ajax feature, sending data form php script.
below js code sends data script , attaches feedback div, means page doesn't have refreshed:
$.ajax( { url: "public/includes/usercreate.php", type: "post", data: { username: user_username, forename: user_forename, surname: user_surname, email: user_email01, password: user_password01 }, success: function(html) { $('#web_content').html(html); } }); i can use following code attaches echo contents web_content div:
<?php $new_username = $_post['username']; $new_forename = $_post['forename']; $new_surname = $_post['surname']; $new_email = $_post['email']; $new_password = $_post['password']; echo "username is: " . $new_username; echo "forename is: " . $new_forename; echo "surname is: " . $new_surname; echo "email is: " . $new_email; echo "password is: " . $new_password; ?> i insert values database. first test mysql functionality following code doesn't seem work.
here code doesn't work:
mysql_connect("localhost","root","mypass"); mysql_select_db("mydatabase"); mysql_query("insert users (user_username, user_email, user_password) values ('testman', 'tom@mail.com', 'qwerty' ) "); what problem here?
all return false on failure. should checking return values, , if false returned check mysql_error.
there many possible causes, have error reporting turned on?
Comments
Post a Comment