Syntax Error?

Discussion in 'PHP' started by wierdo, Dec 8, 2007.

  1. #1
    I could find it but it would take all day, and I don't have time.

    It's somewhere in this bit of code.

    $stringstuff = '$_POST["fname"], $_POST["lname"],  $_POST["email"], $_POST["pass"], $_POST["color"], $_POST["pages"], $_POST["descrip"], $_POST["logo"], $_POST["price"], $_POST["country"], $_POST["state"], $_POST["age"], $_POST["domainstat"], $_POST["domain"], $_POST["loginf"], $_POST["traffic"], $_POST["space"], $_POST["updated"], $_POST["code"]';
    
    mysql_query("INSERT INTO webmembers (fname, lname, email, pass, color, pages, descrip, logo, price, country, state, age, domainstat, domain, loginf, traffic, space, updated, code) VALUES('$stringstuff')") or die(mysql_error());
    PHP:
    Thanks
     
    wierdo, Dec 8, 2007 IP
  2. selling vcc

    selling vcc Peon

    Messages:
    361
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I don't see any error... are you sure?
     
    selling vcc, Dec 8, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    Replace the single quotes with double quotes, and the double quotes with single quotes. Then wrap your variables between curly brackets and single quotes.

    
    $stringstuff = "'{$_POST['fname']}', '{$_POST['lname']}',  '{$_P...";
    
    PHP:
    EDIT:

    Also, please include your error messages in the future.
     
    nico_swd, Dec 8, 2007 IP
  4. wierdo

    wierdo Well-Known Member

    Messages:
    1,646
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    140
    #4
    That didn't fix it.

    Parse error: parse error, unexpected ',' in * on line 21

    Affected Code:
    
    $stringstuff = "'{$_POST['fname']}', '{$_POST['lname']}',  '{$_POST['email']}', '{$_POST['pass']}', '{$_POST['color']}', '{$_POST['pages']}', '{$_POST['descrip']}', '{$_POST['logo']}', '{$_POST['price']}', '{$_POST['country']}', '{$_POST['state']}', '{$_POST['age']}', '{$_POST['domainstat']}', '{$_POST['domain']}', '{$_POST['loginf']}", '{$_POST['traffic']}', '{$_POST['space']}', '{$_POST['updated']}', '{$_POST['code']}'";
    
    mysql_query("INSERT INTO webmembers (fname, lname, email, pass, color, pages, descrip, logo, price, country, state, age, domainstat, domain, loginf, traffic, space, updated, code) VALUES($stringstuff)") or die(mysql_error());
    PHP:
    Thanks

    EDIT: Hehe, I see my error, nevermind. It's a lot easier to find with it highlited.

    Now I have another error, Parse error: parse error, unexpected T_VARIABLE in * on line 23

    $stringstuff = "'{$_POST['fname']}', '{$_POST['lname']}',  '{$_POST['email']}', '{$_POST['pass']}', '{$_POST['color']}', '{$_POST['pages']}', '{$_POST['descrip']}', '{$_POST['logo']}', '{$_POST['price']}', '{$_POST['country']}', '{$_POST['state']}', '{$_POST['age']}', '{$_POST['domainstat']}', '{$_POST['domain']}', '{$_POST['loginf']}', '{$_POST['traffic']}', '{$_POST['space']}', '{$_POST['updated']}', '{$_POST['code']}'";
    
    mysql_query("INSERT INTO webmembers (fname, lname, email, pass, color, pages, descrip, logo, price, country, state, age, domainstat, domain, loginf, traffic, space, updated, code) VALUES("$stringstuff")") or die(mysql_error());
    
    PHP:
     
    wierdo, Dec 8, 2007 IP
  5. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #5
    Check your code again... look at the code above, where the syntax is highlighted. It's easy... I'm not telling you. :D
     
    nico_swd, Dec 8, 2007 IP
  6. wierdo

    wierdo Well-Known Member

    Messages:
    1,646
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    140
    #6
    I think I edited after you replied or something. Anyways, I have fixed the PHP errors (found another one). Now it's just a MySQL error, whoopee... Thanks!
     
    wierdo, Dec 8, 2007 IP