views:

40

answers:

3

Ok the error is showing up somewhere in this here code

    if($error==false) {

        $query = pg_query("INSERT INTO chatterlogins(firstName, lastName, gender, password, ageMonth, ageDay, ageYear, email, createDate) VALUES('$firstNameSignup', '$lastNameSignup', '$genderSignup', md5('$passwordSignup'), $monthSignup, $daySignup, $yearSignup, '$emailSignup', now());");
        $query = pg_query("INSERT INTO chatterprofileinfo(email, lastLogin) VALUES('$email', now())";);
        $_SESSION['$userNameSet'] = $email;
        header('Location: signup_step2.php'.$rdruri);

    }

anyone see what I did wrong??? sorry for being so unspecific but ive been staring at it for 10 mins and I can't figure it out.

+2  A: 
$query = pg_query("INSERT INTO chatterprofileinfo(email, lastLogin) VALUES('$email', now())";);

The semicolon (;) near the end is misplaced. It should be inside the string:

$query = pg_query("INSERT INTO chatterprofileinfo(email, lastLogin) VALUES('$email', now());");
Ayman Hourieh
thanks that worked ^.^
MrEnder
I will accept your answer as soon as it lets me lol ^.^
MrEnder
A: 

in your example, monthSignup, daySignup, and yearSignup aren't quoted.

GSto
A: 

When the query fails pg_query() returns false. pg_last_error() returns the error message of the last operation.
Hopefully all those variables -$firstNameSignup, $lastNameSignup, $genderSignup ... except $passwordSignup- have been properly escaped via pg_escape_string()

if($error==false) {
  $query = "
    INSERT INTO
      chatterlogins
      (
        firstName, lastName, gender, password,
        ageMonth, ageDay, ageYear, email, createDate
      )
      VALUES
      (
        '$firstNameSignup', '$lastNameSignup', '$genderSignup', md5('$passwordSignup'),
        $monthSignup, $daySignup, $yearSignup, '$emailSignup', now()
      )
  ";
  echo '<pre>Debug: query=', htmlspecialchars($query) , '</pre>';
  $rc = pg_query($query);
  if ( !$rc ) {
    die('pg_query failed: ' . htmlspecialchars(pg_last_error()) );
  }


  $query = "
    INSERT INTO
      chatterprofileinfo
      (email, lastLogin)
    VALUES
      ('$email', now())
  ";
  echo '<pre>Debug: query=', htmlspecialchars($query) , '</pre>';
  $rc = pg_query($query);
  if ( !$rc ) {
    die('pg_query failed: ' . htmlspecialchars(pg_last_error()) );
  }

  $_SESSION['$userNameSet'] = $email;
  header('Location: signup_step2.php'.$rdruri);
}
VolkerK