Jump to content

Caliber Mengsk

Members
  • Posts

    11
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Caliber Mengsk's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, I know this trick is done a lot with things like forums, but how do you do it? For example, say I have a url: http://mysite.com/index.php?var1=abcd&var2=1234 On some sites like forums and such, they are able to change this into directories and still have it call the one page. For example, the new URL would be something like: http://mysite.com/abcd/1234 I'm guessing it's more .htaccess, but I'm not sure. Any help?
  2. Try this: <?php require("./include/mysqldb.php"); $con = mysql_connect("$dbhost","$dbuser","$dbpass"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("$dbame", $con); $result = mysql_query("SELECT * FROM Search_profiles_up WHERE upgrade_one ='1' ORDER BY RAND() LIMIT 40"); print "<table width=\"293\" height=\"111\" border=\"0\"> <tr>"; $right = false; while($row = mysql_fetch_array($result)) { print "<td width=\"142\"><img src=" . $row['search_small_image'] . " width=\"144\" height=\"169\" /><br />"; . $row['star'] . "<br />" . $row['username_search'] . "<br />"; . $row['phone_search'] . "</td>"; if($right) { print "</tr><tr>"; } $right=!$right; } print "</tr></table>"; mysql_close($con); ?>
  3. Not certain what you mean. You didn't really describe it the best. Image reference maybe of what you want? (Can be basic and quick, made in mspaint or something) Are you effectively wanting profile images like this but you are getting them like this
  4. Ok, so this may seem a little odd, but I'm trying to make a web based console for minecraft using php and ajax. I make it sound so simple. I've gotten proc_open to open the server, and I can read (somewhat) what comes out, but, it just locks up while reading out, until the process timeout hits. I know I'm getting some of the data (first two lines at least), then the server goes into it's waiting line (where it times out). When getting the pipe information, it reads a whole bunch of > symbols. This is because normally the server would be printing a > that blinks to say waiting for input. Also, I can't send commands to the program after it's open this way. Pretty much, I am needing the process to stay open as a session, or I need some way to access an already open process. Any ideas? Here's the code that I've got right now: <?php session_start(); $descriptorspec = array( 0 => array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will write to 2 => array("pipe", "w")//, "a") // stderr is a file to write to ); $cwd = ''; $_SESSION['process'] = proc_open('java -Xincgc -Xmx1G -jar "C:\Users\Rob\Dropbox\Other Stuff\minecraft\craftbukkit-1.8.1.jar"', $descriptorspec, $pipes); if (is_resource($_SESSION['process'])) { // $pipes now looks like this: // 0 => writeable handle connected to child stdin // 1 => readable handle connected to child stdout // Any error output will be appended to /tmp/error-output.txt fwrite($pipes[0], ''); fclose($pipes[0]); $last_returned = ""; stream_set_read_buffer($pipes[1], 1); while($returned = stream_get_contents($pipes[1])) { echo $returned; } fclose($pipes[1]); // It is important that you close any pipes before calling // proc_close in order to avoid a deadlock $return_value = proc_close($_SESSION['process']); echo "Waiting for new commands..."; } ?>[code] which outputs: [code] 161 recipes 17 achievements > > > > > > > > > > > >Waiting for new commands... So, again, any ideas?
  5. ^__________^ Glad I could be of help. Just for future reference (If you read this post again) If it's something that one browser is having issues with, and the others aren't it's not PHP code that's the problem. PHP Is server side, and the browser never sees anything of php until you echo it out, so if only IE is giving trouble, it has to be with the HTML/Javascript (client side).
  6. Try a closing tag on your input also. <input type="text" name="showValue"></input> OR the shorter way <input type="text" name="showValue" /> Either way is a wc3 standard of doing things. EDIT: And being technical, for w3c standard br's also need a closing tag (technically ) <br />
  7. Nevermind, I figured it out ^___^. Effectively just put a for look that calls the function independently rather then calling it linearly inside of the function. Freezes up the gif animations and such though. I thought of a way around that, but I don't feel like doing it XD. It's for internal use only anyway. function getData() { var i = 0; complete = 0; document.getElementById("Status").innerHTML = "Getting data. Please be patient.<br /><img src='images/loading.gif' />"; document.getElementById("Data").innerHTML = ""; var d = new Date(); for(i=rangeStart;i<=rangeEnd;i+=1) { loadXMLDoc(i); } } function loadXMLDoc(i) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("Data").innerHTML += xmlhttp.responseText; if(xmlhttp.responesText != "") { document.getElementById('system' + i).src = 'images/on.png'; } complete += 1; if(complete >= (rangeEnd-rangeStart)) { document.getElementById('Status').innerHTML = "<span class='good'>Completed getting information</span>"; } //Don't know why, but the above line didn't like +=. //document.getElementById("Status").innerHTML += "System " + i + " finished.<br />"; }else{ document.getElementById('system' + i).src = 'images/checking.gif'; //document.getElementById("Status").innerHTML += "Failed to get data from system " + i + ". " + xmlhttp.status + "<br />"; } } //document.getElementById("Status").innerHTML += "Getting data from system " + i + "<br />"; var url = "getData.php?s=" + document.getElementById('serial').value + "&ip=" + i + "&random=" + Math.random(); xmlhttp.open("GET",url,true); xmlhttp.send(); }
  8. **Long post, so please bear with me. I'm completely new to ajax, I got my first ajax script running as of yesterday, so that's how fresh I am. I got it working for my most basic of basic needs. It opens a PHP page that connects to one of 40+ computers on a network based on ip, grabs the data from a MySQL database, and echos out the data to be received by Ajax. If I just use the one connection, it works fine. no problems. The thing is, I modified the php script that Ajax calls to look at all 40+ computers. That didn't work out so well as it kept timing out. This was pretty much expected being that each computer has several thousand results, resulting in tens of thousands (possibly hundreds of thousands) of columns of database data to look through collectively. So, what I decided to do, to make it easier on the system is to request the computer's information one at a time through ajax, rather then all at the same time through PHP, since ajax had no problems with searching one computer. Problem is, I now get "an error that says xmlhttp.status invalid_state_err dom exception 11". Also, through chrome's javascript debugging, I can look at the value of that xmlhttp.status and hover over it to see that it's value is 200, aka good file received. I can also find the ready state is indeed at 4 like it should be. I know it's not the PHP, as I can manually type in the requested URL that Ajax calls and it works fine (one computer at a time) but as soon as I try to call the ajax script more then once, it breaks like this. Any help? Ajax Script <head> <style> table{border:1px black solid;} tr{border:1px black solid;} td{border:1px black solid;} </style> <script type="text/javascript"> function loadXMLDoc() { var i; document.getElementById("Status").innerHTML = ""; for(i=2;i<=41;i++) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("Data").innerHTML = document.getElementById("Data").innerHTML + xmlhttp.responseText; //Don't know why, but the above line didn't like += as it stopped the next line from showing up. document.getElementById("Status").innerHTML += "System " + i + " finished.<br />"; }else{ document.getElementById("Status").innerHTML += "Failed to get data from system " + i + ". " + xmlhttp.status + "<br />"; } } document.getElementById("Status").innerHTML += "Getting data from system " + i + "<br />"; var url = "index.php?s=" + document.getElementById('serial').value + "&ip=" + i + "&random=" + Math.random(); xmlhttp.open("GET",url,true); xmlhttp.send(); } document.getElementById("Status").innerHTML += "Search complete through all systems."; } </script> </head> <html> <body> <input id='serial' /> <button type="button" onclick="loadXMLDoc()">Get Results</button> <div id="Status"><h2></h2></div> <div id="Data"><h2>Results will be here.</h2></div> </body> </html> I should note that if I get rid of the for loop and set i = to the ending digits of the ip address, it works fine. Like I said, individual ip's work, but I need to search through all the ip's between 2 and 41, and possibly more later down the road. I'd also like to note I tried setting it up as an array with xmlhttp[ i ] and it still returned the same results. Also, Chrome is saying that it gets the error 100+ times, which doesn't make sense since the for loop is only 40 long.
  9. I knew it was something stupid simple. I actually use to use fetch assoc when I first learned php/mysql. O-o I wonder why I stopped using it... @_@ Been a couple years since I've programmed either also. Thanks for the help!
  10. yeah, I was going to agree with codeproda A letter surrounded by ' generally means character, where as surrounded by " means string. The odd part is though that most commands allow for 'word' to be a string, for example, echo can. I feel that the reason for that is it's seeing the 'word' as an array. 'w' 'o' 'r' 'd' And, I feel that most commands simply parse a character array as a string, but some commands (like explode) need it to be implicit... O-o. To be honest though, I would have figured your code to work even with the ' instead of ". I guess it depends on the os and version of PHP.
  11. So, I'm working on trying to create a simple get data script right now. The people that worked at this place before me set up a database to get data from at a later time, and didn't set up an interface for doing so. I have no problem programming a few webpages to see everything, problem is, I'm getting results like this: id: 1 id: 1 Date: Fri Jun 17 05:43:54 2011 Date: Fri Jun 17 05:43:54 2011 Write_transfer_rate_average: 129.25x Write_transfer_rate_average: 129.25x Write_transfer_rate_start: Write_transfer_rate_start: Write_transfer_rate_middle: Write_transfer_rate_middle: Write_transfer_rate_end: 10.0x Write_transfer_rate_end: 10.0x As you can see, it's printing out the results twice, even though my code doesn't say to do that. At this point, I'm just doing a select all. "SELECT * FROM 2011testing" I don't see anything in my php code that would duplicate it, but here is that if it's needed. index.php <?php include('db.php'); $conn = db_conn('**TAKEN OUT FOR SECURITY**', '**TAKEN OUT FOR SECURITY**', '**TAKEN OUT FOR SECURITY**', '**TAKEN OUT FOR SECURITY**'); if($conn == false) { echo "Didn't connect correctly."; }else{ $failed = false; $sql = mysql_query("SELECT * FROM 2011testing") or $failed = true; if(!$failed) { while($row = mysql_fetch_array($sql)) { $x = 0; foreach($row as $r) { echo mysql_field_name($sql,$x) . ": " . $r . "<br />"; $x+=.5; //will be 1 instead of .5 after I figure out this problem. } echo "==================================================================================<br />"; } echo "Completed data collection."; }else{ echo "Failed to complete."; } } @db_disconn($conn); //@ comment for if the connection didn't work. I still want to display the rest of the page. ?> db.php <?php function db_conn($server, $username, $password, $db) { $connected = true; @$link = mysql_connect($server, $username, $password); if($link) { mysql_select_db('testing', $link); }else{ $connected = false; } if($connected) { return $link; } } function db_disconn($link) { mysql_close($link); } ?> Lastly, here is the table structure: 2011testing | CREATE TABLE `2011testing` ( `id` int(11) NOT NULL AUTO_INCREMENT, `Date` longtext COLLATE utf8_unicode_ci, `Write_transfer_rate_average` longtext COLLATE utf8_unicode_ci, `Write_transfer_rate_start` longtext COLLATE utf8_unicode_ci, `Write_transfer_rate_middle` longtext COLLATE utf8_unicode_ci, `Write_transfer_rate_end` longtext COLLATE utf8_unicode_ci, `Read_transfer_rate_average` longtext COLLATE utf8_unicode_ci, `Read_transfer_rate_start` longtext COLLATE utf8_unicode_ci, `Read_transfer_rate_middle` longtext COLLATE utf8_unicode_ci, `Read_transfer_rate_end` longtext COLLATE utf8_unicode_ci, `Random_seek_time_buffered` longtext COLLATE utf8_unicode_ci, `Random_seek_time_cached` longtext COLLATE utf8_unicode_ci, `Vendor` longtext COLLATE utf8_unicode_ci, `Model` longtext COLLATE utf8_unicode_ci, `Firmware` longtext COLLATE utf8_unicode_ci, `Serial_Number_External` longtext COLLATE utf8_unicode_ci, `Serial_Number_Internal` longtext COLLATE utf8_unicode_ci, `Status_Info` longtext COLLATE utf8_unicode_ci, `Vendor_Code` longtext COLLATE utf8_unicode_ci, `Date_recieved` longtext COLLATE utf8_unicode_ci, `User_Changes_Remaining` longtext COLLATE utf8_unicode_ci, `Vendor_Resets_Remaining` longtext COLLATE utf8_unicode_ci, `Current_Region` longtext COLLATE utf8_unicode_ci, `Test_ran` longtext COLLATE utf8_unicode_ci, `Note` longtext COLLATE utf8_unicode_ci, `Log` longtext COLLATE utf8_unicode_ci, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=341 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci I don't see ANY reason why it is outputting duplicate results in either my php or mysql. Can anyone help with this? I do think I've had this problem before, but I just simply don't remember how I went about fixing this. OH! Mysql version is 14.14 Dist 5.1.46, OS is opensuse. Obviously it's not a problem connecting to the database, as I am actually getting results... just to many of them. XD Thanks in advance. I know it's probably something stupid simple, but I just can't figure it out for the life of me.
×
×
  • 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.