Jump to content

INSERT into table not doing anything


maL-AU

Recommended Posts

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.")");
} 
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.