Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

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

Course Queries Syllabus Queries
Max. 2000 characters
Replies

usr_profile.png
Dipti Singh

User

( 5 months 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."'";

usr_profile.png
Charles Kyobe

User

( 5 months 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';

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif