Bopo Posted March 20, 2009 Share Posted March 20, 2009 Hi Basically this is only a portion of my code, however I'm confident with the rest of it, basically no errors are being thrown, like connection errors or anything, and nothing is being saved into the table therefore I don't know where to go next, help appreciated. <?php if($password == $verifypassword) { $connection = mysql_connect("localhost", "loginname", "password"); if (!$connection) { die("There appears to be username and/or password issue, please check your credentials" . mysql_error()); } $selectdb = mysql_select_db("koicarp_blog", $connection); if(!$selectdb) { die("There is a problem connecting to the database" . mysql_error()); } $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $sql = "INSERT INTO adminlogin (username,password) VALUES ('$username', '$password')"; // place holders used to prevent sql injections if (!mysql_query($sql, $connection)) { die('Error: ' . mysql_error()); } echo "your username and password have been added succesfully, please delete this file"; mysql_close($connection); } else { echo "doesnt match"; exit(); } ?> Link to comment https://forums.phpfreaks.com/topic/150322-solved-possible-syntax-error/ Share on other sites More sharing options...
revraz Posted March 20, 2009 Share Posted March 20, 2009 echo $sql and see what it contains. What echos when you run your current script, the added success or the doesnt match? Link to comment https://forums.phpfreaks.com/topic/150322-solved-possible-syntax-error/#findComment-789451 Share on other sites More sharing options...
Bopo Posted March 20, 2009 Author Share Posted March 20, 2009 Hi Okay I did some troubleshooting, the problem is the code below if(ereg('[^A-Za-z0-9]', $username)) $message = "Please user uppercase & lowercase a to z characters"; echo "$message"; exit(); if(ereg('[^A-Za-z0-9]', $password)) $message = "Please user uppercase & lowercase a to z characters"; echo "$message"; exit(); Even if the condition is true or false, the script still exits, any idea's on solving this? Link to comment https://forums.phpfreaks.com/topic/150322-solved-possible-syntax-error/#findComment-789465 Share on other sites More sharing options...
Maq Posted March 20, 2009 Share Posted March 20, 2009 if(ereg('[^A-Za-z0-9]', $username)) { $message = "Please user uppercase & lowercase a to z characters"; echo "$message"; exit(); } if(ereg('[^A-Za-z0-9]', $password)) { $message = "Please user uppercase & lowercase a to z characters"; echo "$message"; exit(); } Link to comment https://forums.phpfreaks.com/topic/150322-solved-possible-syntax-error/#findComment-789466 Share on other sites More sharing options...
Bopo Posted March 20, 2009 Author Share Posted March 20, 2009 To be honest that's what I thought it was, but the examples I found never showed the use of those brackets, guess I should test more, thanks. Link to comment https://forums.phpfreaks.com/topic/150322-solved-possible-syntax-error/#findComment-789477 Share on other sites More sharing options...
Maq Posted March 20, 2009 Share Posted March 20, 2009 If you don't use brackets the IF statement will apply to a single line directly below it, if you want multiple lines correlated to that IF than you must use french braces. Link to comment https://forums.phpfreaks.com/topic/150322-solved-possible-syntax-error/#findComment-789478 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.