Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Unknown syntax erroe?!?

mysqli syntax

  • Please log in to reply
1 reply to this topic

#1 toxifyshadow

toxifyshadow

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 120 posts

Posted 12 April 2010 - 07:17 AM

Now I have a new error, Now it says:
"Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /www/99k.org/t/o/x/toxigen/htdocs/signup.php on line 29"
This is a signup page, when you fill in the forms it says your account has been created, you are now ready to log in, but it won't add you to the database.
My new code is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>Toxigen - Sign Up</title>
  <link rel="stylesheet" type="text/css" href="css.css" />
</head>
<body bgcolor="black"><font color="white">
  <h3>Toxigen - Sign Up</h3>

<?php
  require_once('appvars.php');
  require_once('connectvars.php');

  // Connect to the database
  $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); //I have a page for these vars

  if (isset($_POST['submit'])) {
    // Grab the profile data from the POST
    $username = mysqli_real_escape_string($dbc, trim($_POST['username']));
    $password1 = mysqli_real_escape_string($dbc, trim($_POST['password1']));
    $password2 = mysqli_real_escape_string($dbc, trim($_POST['password2']));

    if (!empty($username) && !empty($password1) && !empty($password2) && ($password1 == $password2)) {
      // Make sure someone isn't already registered using this username
      $query = "SELECT * FROM mismatch_user WHERE username = '$username'";
      $data = mysqli_query($dbc, $query);
      if (mysqli_num_rows($data) == 0) {
        // The username is unique, so insert the data into the database
        $query = "INSERT INTO users (username, password,) VALUES ('$username', SHA('$password1'), NOW())";
        mysqli_query($dbc, $query);

        // Confirm success with the user
        echo '<p>Your new account has been successfully created. You\'re now ready to <a href="login.php">log in</a>.</p>';

        mysqli_close($dbc);
        exit();
      }
      else {
        // An account already exists for this username, so display an error message
        echo '<p class="error">An account already exists for this username. Please use a different address.</p>';
        $username = "";
      }
    }
    else {
      echo '<p class="error">You must enter all of the sign-up data, including the desired password twice.</p>';
    }
  }

  mysqli_close($dbc);
?>

  <p>Please enter your username and desired password to sign up.</p>
  <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <fieldset>
      <legend style="color:white;">Registration Info</legend>
      <label for="username">Username:</label>
      <input type="text" id="username" name="username" value="<?php if (!empty($username)) echo $username; ?>" /><br />
      <label for="password1">Password:</label>
      <input type="password" id="password1" name="password1" /><br />
      <label for="password2">Password (retype):</label>
      <input type="password" id="password2" name="password2" /><br />
    </fieldset>
    <input type="submit" value="Sign Up" name="submit" />
  </form>
</font></body> 
</html>


Will someone tell me what went wrong?

And on a line it has DB_HOST and stuff, I have a page (connectvars.php) that defines those vars.

Edited by toxifyshadow, 12 April 2010 - 08:49 AM.

  • 0
Posted Image

#2 toxifyshadow

toxifyshadow

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 120 posts

Posted 12 April 2010 - 08:03 AM

Now I have a new error, so it's not fixed.

Edited by toxifyshadow, 12 April 2010 - 08:41 AM.
New Error

  • 0
Posted Image





Also tagged with one or more of these keywords: mysqli, syntax

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download