Jump to content

[SOLVED] Possible Syntax Error


Bopo

Recommended Posts

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

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?

 

 

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();   
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.