Jump to content

stikky

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

stikky's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. sorry, i don't understand what you mean. it's supposed to compare $login with the string "location:firstPage.php", and then go on to enter the data to the database if that is so, etc. do you mean the problem is with the code that is supposed to enter the data? i did wonder whether i needed to tell it to contact the DB etc etc all over again first. :-[
  2. Parse error: syntax error, unexpected T_STRING in /home/thecy3/public_html/test/login/enterdata.php on line 29 thats the message i get from the following code when i try to 'register' on this login system i am trying to make for a friend. i have checked all sorts of forums etc, so i realise that it's probably something stupid like a missing quote or bracket, but i just can't find it. if i comment out that line and eveything after it, and do "echo $login", everything works just as expected...so there must be something wrong with the line       if ($login == "location:firstPage.php") { what the heck can it be? oh, and btw, obviously i havn't been able to check what comes after that, so please don't laugh if it's awful...! "problem.php" <?php session_start(); $_SESSION['username'] = $_POST['name']; $_SESSION['password'] = $_POST['word']; $name = $_SESSION['username']; $word = $_SESSION['password']; $host = "localhost"; $account = "xxxxxxx"; $password = "xxxxxxx"; $dbname = "xxxxxxx"; $connect = mysql_connect($host,$account,$password) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db($dbname) or die ('I cannot select the database because: ' . mysql_error()); $sql = "SELECT * FROM users"; $result = mysql_query($sql,$connect) or die ('I cannot query the database because: ' . mysql_error()); $num = mysql_num_rows($result) or die ('I cannot count the rows because: ' . mysql_error()); $i=0; while ($i < $num) { $row = mysql_fetch_array($result) or die ('I cannot fetch the array because: ' . mysql_error()); if ($row[0] == $name) {     $login = "location:register.php";       } else {     $login = "location:firstPage.php";       } $i++; } if ($login == "location:firstPage.php") {         INSERT INTO users ( 'username' , 'password' , 'date' , 'ip' )         VALUES ('$name', '$word', '', '') or die ('I cannot select insert data to the database because: ' . mysql_error()); } else {     $_SESSION['samename'] = "yes"; } header($login); exit(); ?> ???
  3. thanks that works fine now, silly me!
  4. hello, i am a complete beginner and I have been having trouble getting variables taken from a form into a mySQL table. Yesterday, I only either got the variable names inserted (eg $fg), or I got a 'syntax error' message. Today I extracted the values first, but no matter what I try I still get this error message: Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''test1','test2','test3','test3','test4','test5','test7','test8','test9') VALUES ' at line 1 This is an improvement, as these are the correct values (the fieldnames are also in variables). Here is the code as it is now: extract($customer); extract($labels); $sql = "INSERT INTO testing ('$firstName','$lastName','$company','$street','$city','$county','$phone','$email','$query') VALUES ('$fN','$lN','$cp','$stt','$cy','$coy','$ph','$el','$qu');"; $result = mysql_query($sql,$dbh) or die("Query failed: ".mysql_error()); $customer is the array of values, $labels is the array of fieldnames. I have tried every variation on the theme I can think of. Please can someone help?
×
×
  • 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.