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

Course Queries Syllabus Queries 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Syllabus Queries related to Course Queries. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 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."'";
profilepic.png
manpreet 2 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.