PHP MySQLi INSERT INTO Errno 1064 near 'where doi='''

Course Queries Syllabus Queries 3 years ago

6.02K 2 0 0 0

User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 3 years ago

I realize that similar questions like this one have been asked before, some answered some not, but after trying each of the accepted answers I am no further ahead in 'seeing' my syntax error. I need a fresh set of eyes to look at this as I've been moving single and double quotes around for the last couple of hours to no avail. Here's my PHP/MYSQL string:

$sql_2 = "INSERT INTO program_tracking_datalake.altmetric_daily SET doi='" . $remote_doi . "',alt_wikipedia_mentions='" . $wiki  . "',alt_video_mentions='" . $video . "',alt_tweet_mentions='" . $tweet . "',alt_syllabus_mentions='" . $syllabus . "',alt_rdt_mentions='" . $rdt . "',alt_qna_mentions='" . $qna  . "',alt_policy_mentions='" . $policy . "',alt_pinterest_mentions='" . $pinterest . "',alt_peer_review_mentions='" . $peer . "',alt_msm_mentions='" . $msm . "',alt_linkedin_mentions='" . $linkedin . "',alt_gplus_mentions='" . $gplus . "',alt_fbwall_mentions='" . $fbwall . "',alt_f1000_mentions='" . $f1000 . "',alt_blog_mentions='" . $blog . "',alt_historical_mentions_1d='" . $oneDay . "',alt_historical_mentions_3d='" . $threeDay . "',alt_historical_mentions_1w='" . $oneWeek . "',alt_historical_mentions_1m='" . $oneMonth . "',alt_historical_mentions_3m='" . $threeMonth . "',alt_historical_mentions_6m='" . $sixMonth . "',alt_historical_mentions_1y='" . $oneYear . "',alt_historical_mentions_at='" . $allTime . "',alt_pubmed_id='" . $outputs['data'][$j]['attributes']['identifiers']['pubmed-ids'][0] . "'  where doi='".$local_doi."'";
0 views
0 shares

profilepic.png
manpreet 3 years ago

You're mixing UPDATE and INSERT syntax:

UPDATE table set col='val',col2='val2' where id='3';

INSERT INTO table (col, col2) VALUES ('val', 'val2');

Insert statements do not take a "where" clause.

update: you can use "set" style inserts, but still you cannot use "where col=val" unless you're doing some INSERT ... SELECT, but you can do "where 1" for some unknown reason.

INSERT INTO table set col='val',col2='val2';


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Similar Forum