Firestorm3d Posted March 30, 2008 Share Posted March 30, 2008 ok im trying to set up a greasemonkey js that talks to a php script that sends the js gm_xmlhttprequest and posts it to php which is supposed to send it to a mysql database. now i dont know the posted indices so i can input them into a specially created table. this is what i have so far. this is the greasemonkey user script // ==UserScript== // @name PostAll_Ceti_Delta // @namespace gatevo.com // @description AE page HTTP POSTer // @include http://ceti.astroempires.com/* // ==/UserScript== var version = "0.1"; removeAds(); if ( window.location.toString().indexOf("base.aspx?base=") != -1 || window.location.toString().indexOf("map.aspx?loc=") != -1 ) { GM_xmlhttpRequest({ method:"POST", url:"http://localhost/firefoxinput.php", headers:{ "User-Agent":"COCK", "Content-Type":"application/x-www-form-urlencoded" }, data:"url=" + encodeURIComponent(window.location.toString()) + "&html=" + encodeURIComponent(document.body.innerHTML) }); } function removeAds() { var allTables, theAdTable; allTables = document.getElementsByTagName('table'); for (var i = 0; i < allTables.length; i++) { if (allTables[i].innerHTML.indexOf("Remove advertising") != -1) { theAdTable = allTables[i]; theAdTable.parentNode.removeChild(theAdTable); } } } this is the posting php script. i commented out all the parts that arent needed <?php $html = array($_POST); /*$guild = $_POST['guild']; $guildid = $_POST['guildid']; $playername = $_POST['playername']; $playerid = $_POST['playerid']; $coords = $_POST['coords']; $cc = $_POST['cc']; $defense01 = $_POST['defense01']; $defense02 = $_POST['defense02']; $defense03 = $_POST['defense03']; $defense04 = $_POST['defense04']; $defense05 = $_POST['defense05']; $defense06 = $_POST['defense06']; $defense07 = $_POST['defense07']; $defense08 = $_POST['defense08']; $defense09 = $_POST['defense09']; $defense10 = $_POST['defense10'];*/ $con = mysql_connect("localhost","root","*****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("data", $con); $create = "CREATE TABLE postallstruc ("; for($x = 0; $x < 100; $x++){ $create .= $html["$x"]." varchar(100), "; } $create .= ")"; mysql_query($create); /*mysql_query("INSERT INTO astro_players (guild_name', guild_id, player_name, player_id) VALUES ('$guild', '$guildid', '$playername', '$playerid')"); mysql_query("INSERT INTO astro_bases (coord , cc , Defense01 , Defense02 , Defense03 , Defense04 , Defense05 , Defense06 , Defense07 , Defense08 , Defense09 , Defense10) VALUES ('$coords' , '$cc' , '$defense01', '$defense02', '$defense03', '$defense04', '$defense05', '$defense06', '$defense07', '$defense08', '$defense09', '$defense10')"); mysql_close($con); //echo $_POST[$html];*/?> so what am i doing wrong? Link to comment https://forums.phpfreaks.com/topic/98587-i-got-a-good-one-for-you-guys/ Share on other sites More sharing options...
redarrow Posted March 30, 2008 Share Posted March 30, 2008 what is suppose to do? what dosent it do? sorry my cristal ball not working ......... Link to comment https://forums.phpfreaks.com/topic/98587-i-got-a-good-one-for-you-guys/#findComment-504563 Share on other sites More sharing options...
Firestorm3d Posted March 30, 2008 Author Share Posted March 30, 2008 it takes data from a web based game and post it into a database. its a log for base locations Link to comment https://forums.phpfreaks.com/topic/98587-i-got-a-good-one-for-you-guys/#findComment-504569 Share on other sites More sharing options...
redarrow Posted March 30, 2008 Share Posted March 30, 2008 create a table php example is your code cresteing the table.... <?php // Connect to our database // ---------------------------------- // $conn = dbconnect(); $sql = 'CREATE TABLE `zones` ( `zid` TINYINT( 3 ) UNSIGNED NOT NULL AUTO_INCREMENT, `zdesc` VARCHAR( 150 ) NOT NULL, `zwidth` SMALLINT( 3 ) DEFAULT 0 NOT NULL, `zheight` SMALLINT( 3 ) DEFAULT 0 NOT NULL, `zmax` MEDIUMINT(7) unsigned NOT NULL default 12288, PRIMARY KEY ( `zid` ) )'; echo 'Creating table: \'zones\'....'; mysql_query( $sql, $conn ); ?> Link to comment https://forums.phpfreaks.com/topic/98587-i-got-a-good-one-for-you-guys/#findComment-504570 Share on other sites More sharing options...
Firestorm3d Posted April 1, 2008 Author Share Posted April 1, 2008 so i got the script to work but now i need some help with strings. I am trying to take the source of a web site and cut it up into variables and send them to a mysql data base. Link to comment https://forums.phpfreaks.com/topic/98587-i-got-a-good-one-for-you-guys/#findComment-506939 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.