Jump to content

Recommended Posts

can anyone tell me what is wrong with this query

 

<?php

$Inject[$y]="INSERT INTO [ClientsEmails] WHERE CompanyName='".$Company[$y]."' (username, password) VALUES ('".$username[$y]."','".$password[$y]."')";
?>

 

 

keep getting error saying syntax error near WHERE on line /\(that line)

 

Link to comment
https://forums.phpfreaks.com/topic/118836-solved-invalid-syntax-with-query/
Share on other sites

thats how it is in the DB and my DB wants me to use it..

 

also your sposed to be able to use a WHERE in insert statements

 

\/

 

http://www.sql-tutorial.com/sql-where-sql-tutorial/

 

The WHERE keyword can be used to insert, update and delete data from table(s

Don't take every tutorial as pure truth.  There can be mistakes.  The MySQL manual for INSERT highlights the 3 syntax options as:

 

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [iGNORE]
    [iNTO] tbl_name [(col_name,...)]
    {VALUES | VALUE} ({expr | DEFAULT},...),(...),...
    [ ON DUPLICATE KEY UPDATE
      col_name=expr
        [, col_name=expr] ... ]

Or:

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [iGNORE]
    [iNTO] tbl_name
    SET col_name={expr | DEFAULT}, ...
    [ ON DUPLICATE KEY UPDATE
      col_name=expr
        [, col_name=expr] ... ]

Or:

INSERT [LOW_PRIORITY | HIGH_PRIORITY] [iGNORE]
    [iNTO] tbl_name [(col_name,...)]
    SELECT ...
    [ ON DUPLICATE KEY UPDATE
      col_name=expr
        [, col_name=expr] ... ]

 

No WHERE. =P  It logically doesn't make much sense....

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.