php - PDO Prepare Query - SQL Error Failed to run query: SQLSTATE[42000] -


I'm having trouble running this query

  // enter the power stats { $ STH = $ db - & gt; Ready (insert "statsRounds (version, timeFormat, mapNumber, mapName, duration, startTic, endTic, avgEfficiencyPts, redPowerPercent, bluePowerPercent) value ($ wdlround-> VERSIONNUMBER, $ wdlround-> timeFormat, $ wdlround-> gt; ; MapNumber, $ wdlround-> MapName, $ wdlround-> durationTics, $ wdlround-> startTic, $ wdlround-> endTic, $ wdlround-> averageEfficiencyPoints, $ wdlround-> RedPowerPercent , $ Wdlround- & gt; bluePowerPercent) "); // execute the query $ STH - & gt; Executed (); } // attempt cache (PDOException $ ex) {die ("Failed to run the query:" $ Ex-> getMessage ()); }  

I get an error on the execution

  Failed to run the query: SQLSTATE [42000]: Syntax error or access violation: 1064 You have a Error is your SQL syntax; Line 17  

I - the manual is that to use to correct syntax 'SMARTCTF01, 18,193, 0, .22.20.55.00, 6, revisited Lazarus' Checks to match '$ wdlround-> versionNumber to match the value of the $ wdlround-> bluePowerPercent values ​​that they match with their server version and they do so, the connection to the DB is fine too. I have also posted the DB table, see here:

I am not sure what I am doing wrong here!

edit:

/ p>

  // Enter the $ mystr = "statsRounds of the ECHO query ('version', 'time', 'mapNumber' , 'MapName', 'duration', 'startTic', 'endTic', 'avgEfficiencyPts', 'redPowerPercent', 'bluePowerPercent') values ​​(, ". $ Wdlround-> timeFormat" "$ wdlround-> Versionnumbr "," $ Vdlrund- & gt; .. Mapnumbr ".," $ Vdlrund - & gt; Mpanme "," $ Vdlrund- & gt; Durtiontiks "," $ Vdlrund- & gt; Starttik "," $ Vdlrund- & gt; Indic "," $ Vdlrund- & gt; Avergiffisianseepoints ".........". Vdlrund-> Redpover percent. ",". $ Vdlrund-> Bluapoverpersent. ")"; Echo "MYSTR = $ mystr" 
"; Results in <
   

MYSTR = INSERT INTO statsRounds ('version', 'time', 'mapNumber', 'mapName', 'duration', ' StartTic ',' endTic ',' avgEfficiencyPts', 'redPowerPercent', 'bluePowerPercent') Value (4, 2014.07.22.21.03.11, 6, Laser Revision - SMARTCTF01, 16418, 0, 130,136, 107.83333333333, 108 33333333333, 9 3.333333333333)

output

your post Your INSERT query looks like

  statsRounds (version, time, ......) value (4, 2014.07.22.20.55.00 & lt in Insert - here with 'value' around '' 6, ......)  

The problem is time a VARCHAR column (according to the post link for DB schema) ) And there is no quotation of the value for it. You should do this with a value like '' 2014.07.22.20.55.00 ' Similarly, quote around the value for all VARCHAR / CHAR columns.

Your INSERT statement should look like

  statsRounds (version, time, MapNumber, MapName, Durstion, StartTic, EndTic, AvgEfficiencyPts, RedPowerPercent, bluePowerPercent) putting Revisited values ​​( '4', '2014.07.22.20.55.00', 6, 'Lazarus - SMARTCTF01', 18193, 0, 112948, 103.66666666667, 150, 80)  
< / Div>

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -