PHP MySQL insert not working

前端 未结 6 1029
有刺的猬
有刺的猬 2021-01-14 07:01

Sorry if it\'s a quite simple problem. I am not too experienced with web languages.
Basically, it doesn\'t work.

$insert=
(
  \"INSERT INTO phpbb_members         


        
相关标签:
6条回答
  • 2021-01-14 07:38
    $insert=("INSERT INTO phpbb_members (emailAddress, uid, valid, firstandlast, propic, memberName) 
    VALUES ($me['email'], $uid, 1, $me['name'], $propic, $newuser)"); 
    

    Do wee need those extra brackets in the beginning and end? Try to remove it and execute.

    $sql = "SELECT * FROM Person";
    mysql_query($sql,$con);
    
    0 讨论(0)
  • 2021-01-14 07:40
    $insert=("INSERT INTO phpbb_members (emailAddress, uid, valid, firstandlast, propic, memberName)
    VALUES ('".$me['email']."','". $uid."',1,'". $me['name']."','" .$propic."','". $newuser."')");
    mysql_query($insert) or die('Error, insert query failed');
    
    0 讨论(0)
  • 2021-01-14 07:56

    If you'll use the following for testing, it will show you the error:

    mysql_query($insert) or die(mysql_error()."<br />".$insert);
    
    0 讨论(0)
  • 2021-01-14 07:56

    Try the following code,

     $insert=("INSERT INTO phpbb_members (emailAddress, uid, valid, firstandlast, propic, memberName) VALUES ('{$me['email']}', '{$uid}', '1', '{$me['name']}', '{$propic}', '{$newuser}')");
    mysql_query($insert) or die('Error, insert query failed');
    
    0 讨论(0)
  • 2021-01-14 07:58
    $insert="INSERT INTO phpbb_members (emailAddress, uid, valid, firstandlast, propic, memberName)
    VALUES ('".$me['email']."', $uid, 1, '".$me['name']."', '$propic', $newuser)";
    

    Missing singular quotes (for strings [varchar, char, text, etc]) and you need to close your quotes and concatenate when referencing an array. The above assumed $uid and $newuser are stored numerically in the DB.

    0 讨论(0)
  • 2021-01-14 08:01

    I think the problem may be in the way you've laid out the information to be inserted.

    This should work:

    $insert=("INSERT INTO phpbb_members (emailAddress, uid, valid, firstandlast, propic, memberName)
    VALUES ('$me[email]', '$uid', '1', '$me[name]', '$propic', '$newuser')");
            mysql_query($insert) or die('Error, insert query failed');
    

    Hope it helps!

    EDIT: I'm pretty sure the information to be inserted has to be inside ' '.

    0 讨论(0)
提交回复
热议问题