yandoos Posted July 22, 2015 Share Posted July 22, 2015 (edited) Hello I'm really not sure what going on but I;m trying to insert a record but it's not working. i just get a white screen. Can you see what the problem is and advise me how to fix it please? <form action="add_galleries.php" enctype="multipart/form-data" method="post"> <input name="mem_id" type="hidden"> <input name="userid" type="text"> <input name="name" type="text"> <input name="email" type="text"> <select name="user_level"> <option value="0">Regular</option> <option value="1">Admin</option> </select> <input name="pass" type="password"> <input name="submit" type="Submit" value="Add New Gallery"/> </form> and the insert query: <?php ini_set('display_errors', 1); error_reporting(E_ALL); include "include/session.php"; require('config.php'); require('include/functions.php'); if (isset($_POST['submit'])) { $pass = $_POST['pass']; $pass1 = md5($pass); $name = mysqli_real_escape_string(mysqli $link, $_POST['name']); $email = mysqli_real_escape_string(mysqli $connection, $_POST['email']); $user_level = mysqil_real_escape_string(mysqli $connection, $_POST['user_level']); $userid = mysqli_real_escape_string(mysqli $connection, $_POST['userid']); $pass2 = mysqli_real_escape_string(mysqli $connection, $_POST['pass1']); echo $name; echo'<br/>'; echo $userid; echo '<br/>'; echo $email; echo'<br/>'; echo $user_level; echo'<br/>'; echo $pass1; echo'<br/>'; $connection = mysqli_connect($dbhost_name, $username, $password, $database); $sql = mysqli_query($connection,"INSERT INTO plus_signup (name, userid, user_level, password, email) VALUES ('$name', '$userid', '$user_level', '$pass2', '$email'"); $result = mysqli_query($connection,$sql) or die (mysql_error()); } ?> Thank you Edited July 22, 2015 by yandoos Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted July 22, 2015 Share Posted July 22, 2015 To help with the debugging process, the following lines of code can be added to the top of your script: error_reporting(E_ALL); ini_set('display_errors', 1); When you're escaping the "user_level" variable, you're calling mysqil_real_escape_string() instead of mysqli_real_escape_string(). Here is your code: $user_level = mysqil_real_escape_string(mysqli $connection, $_POST['user_level']); In your calls to mysqli_real_escape_string(), you need to remove the "mysqli" references. The following, for example $email = mysqli_real_escape_string(mysqli $connection, $_POST['email']); Should be $email = mysqli_real_escape_string($connection, $_POST['email']); Also, you're using the $connection object before it's actually defined. The object is defined here, near the bottom of your script: $connection = mysqli_connect($dbhost_name, $username, $password, $database); Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted July 22, 2015 Share Posted July 22, 2015 Also, I forgot to mention that you're using $link in the following line which I assume should be $connection: $name = mysqli_real_escape_string(mysqli $link, $_POST['name']); Quote Link to comment Share on other sites More sharing options...
Barand Posted July 22, 2015 Share Posted July 22, 2015 try changing $sql = mysqli_query($connection,"INSERT INTO plus_signup (name, userid, user_level, password, email) VALUES ('$name', '$userid', '$user_level', '$pass2', '$email'"); $result = mysqli_query($connection,$sql) or die (mysql_error()); to $sql = "INSERT INTO plus_signup (name, userid, user_level, password, email) VALUES ('$name', '$userid', '$user_level', '$pass2', '$email'"; $result = mysqli_query($connection,$sql) or die (mysql_error()); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.