maL-AU Posted September 26, 2011 Share Posted September 26, 2011 Hey guys, it seems that so far in my little script everything is working except for the MySQL insert Nothing seems to appear in the table it's supposed to insert too but i dont see any errors anywhere. Any help would be appreciated. I know it's very messy but it's my first actual 'project' <?php $apiKey="<omitted>"; $playeritemsURL="http://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/"; $fullURL=$playeritemsURL."?key=".$apiKey."&SteamID=".$_GET["SteamID64"]."&format=xml"; $playerLocalName=$_GET["SteamID64"].".xml"; $ch=curl_init($fullURL); $fh=fopen($playerLocalName, 'w'); ?> You entered ID: <?php echo $_GET["SteamID64"];?></br> <?php echo $fullURL; curl_setopt($ch,CURLOPT_FILE,$fh); curl_exec($ch); curl_close($ch); ?> </br> <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("csv_db", $con); $readXML=file_get_contents($playerLocalName); $xml=simplexml_load_file($playerLocalName); $output=$_GET["SteamID64"].".defindex.txt"; $fh=fopen($output, 'w') or die("can't open file"); //echo $xml->items->item->defindex[0]; foreach ($xml->xpath('//defindex') as $defindex) { fwrite($fh, $defindex."\n"); echo $defindex."</br>"; mysql_query("INSERT INTO ".$_GET["SteamID64"]." (defindex) VALUES (".$defindex.")"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/247900-insert-into-table-not-doing-anything/ Share on other sites More sharing options...
Muddy_Funster Posted September 26, 2011 Share Posted September 26, 2011 For better debuging change you code to be the following: $qry = "INSERT INTO ".$_GET["SteamID64"]." (defindex) VALUES (".$defindex.")" mysql_query($qry) or die ("ERROR!<br> $qry <br>Caused the following error when trying to create a new record:<br>".mysql_error()); } that should help you find out what's going wrong. Quote Link to comment https://forums.phpfreaks.com/topic/247900-insert-into-table-not-doing-anything/#findComment-1272943 Share on other sites More sharing options...
maL-AU Posted September 26, 2011 Author Share Posted September 26, 2011 Thanks, that did give me some output, unfortunately it's not helping as for all I know the syntax is completely fine. Any more ideas, thanks again. ERROR! INSERT INTO 76561198006264092 (defindex) VALUES (214) Caused the following error when trying to create a new record: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '76561198006264092 (defindex) VALUES (214)' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/247900-insert-into-table-not-doing-anything/#findComment-1272947 Share on other sites More sharing options...
maL-AU Posted September 26, 2011 Author Share Posted September 26, 2011 Disregard, fixed. Quote Link to comment https://forums.phpfreaks.com/topic/247900-insert-into-table-not-doing-anything/#findComment-1272949 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.