Jump to content

WTF? WTF? And WTF some more?


Modernvox

Recommended Posts

Sorry guyz, a little ticked off at this point. For 2 days now, I have failed to get my registration page set up. I am wanting to check to see if username is already in use before adding the users registration. I keep getting the same error on line 20 unexpected ')'

 

 <?php
if (isset($_POST['regname']) | $_POST['regstate'] | $_POST['regcity'] | 

$_POST['regemail'] | $_POST['username'] | $_POST['password'] | $_POST['confirmpass']))

$reg_name= $_POST['regname'];
$reg_state= $_POST['regstate'];
$reg_city= $_POST['regcity'];
$reg_email= $_POST['regemail'];
$reg_username= $_POST['username'];
$reg_password= $_POST['password'];
$reg_confirmpass= $_POST['confirmpass'];
$database= "register";

$dbx =mysqli_connect("localhost", "", "") 
           or die(‘Error connecting to MySQL server.’); 

mysql_select_db($database) or die( "Unable to select database");
$sql = "SELECT COUNT(*) FROM users WHERE username = '{$_POST['username']}'";
$sql_result = mysql_query($sql);
if (mysql_result($sql_result, 0) > 0) {
Echo "This username is already in use.Please choose another.";
}

else
$query = "INSERT INTO users (reg_name, reg_state, reg_city, 

reg_email, reg_username, reg_password, reg_confirmpass) VALUES 

('regname', $regstate', 'regcity', 'regemail', 'username', 'password', 'confirmpass')";


?> 

My brain is total goo at this point

Link to comment
https://forums.phpfreaks.com/topic/189582-wtf-wtf-and-wtf-some-more/
Share on other sites

The error you are listing for line 20 actually occurs on line 4 of what you posted, because there is an extra ) on the end of line 4.

 

You also have a couple of smart/curly-quotes in the following (you must have copy pasted that from a word processor, rather than a programming editor) -

 

           or die(‘Error connecting to MySQL server.’); 

The error you are listing for line 20 actually occurs on line 4 of what you posted, because there is an extra ) on the end of line 4.

 

You also have a couple of smart/curly-quotes in the following (you must have copy pasted that from a word processor, rather than a programming editor) -

 

           or die(‘Error connecting to MySQL server.’); 

 

? Don't quite understand what your implying

The use of isset is incorrect here

if (isset($_POST['regname']) | $_POST['regstate'] | $_POST['regcity'] | 

$_POST['regemail'] | $_POST['username'] | $_POST['password'] | $_POST['confirmpass']))

 

You should read up on the proper use of isset. Your not listing your variables properly, you should separate each variable with a coma not a pipe character.

 

Also statements which span multiple lines must be wrapped in curly braces {}. Read up on the use of if

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.