Jump to content

[SOLVED] invalid syntax ?? with query


ag3nt42

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

Archived

This topic is now archived and is closed to further replies.

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