Jump to content

maL-AU

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

maL-AU's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey all, I've been trying to set up a small script that would create a different column every time a file is updated, kind of for a form of logging. I need it to replace the number at the end of the column name with the next if said column already exists, for example: say i try to make a column named 'column1' ALTER TABLE `table1` ADD `column1` VARCHAR(4) NOT NULL except column 1 already exists, so mysql_error returns "Duplicate column name 'column1'" so it would then try ALTER TABLE `table1` ADD `column2` VARCHAR(4) NOT NULL and so on, until it successfully creates a column, or by doing it some otherway, but the idea would remain the same. I know this is insanely inefficient but is this possible? Any help would be greatly appreciated, Thanks.
  2. 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
  3. 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.")"); } ?>
×
×
  • 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.