Jump to content

Mod-Jay

Members
  • Posts

    155
  • Joined

  • Last visited

    Never

Everything posted by Mod-Jay

  1. Could you edit the code to a way i could use it?
  2. The following code is supposed to submit everything in the database on a table, Currently its doing the first row in the database. Not sure whats wrong.. function getNews(){ $query = $this->con->query("SELECT * FROM `". $this->prefix ."news`"); while ($result = $query->fetch_assoc()) { if($result['serveradded'] == 1){ $queryy = $this->con->query("SELECT * FROM `". $this->prefix ."news` WHERE serveradded=1"); while ($resultt = $queryy->fetch_assoc()) { return "<tr><td>The Advertisement ". ucfirst($resultt['name']) ." was created</td><td>". $resultt['date'] ."</td></tr>"; } } elseif($result['servupdate'] == 1){ $queryyy = $this->con->query("SELECT * FROM `". $this->prefix ."news` WHERE servupdate=1"); while ($resulttt = $queryyy->fetch_assoc()) { return "<tr><td>". $result['type'] ." ". ucfirst($resulttt['name']) ." was Updated by ". ucfirst($resulttt['updatedby']) ." </td><td>". $resulttt['date'] ." </td></tr>"; } } elseif($result['newuser'] == 1){ $queryyyy = $this->con->query("SELECT * FROM `". $this->prefix ."news` WHERE newuser=1"); while ($resultttt = $queryyyy->fetch_assoc()) { return "<tr><td>Account Created: ". ucfirst($resultttt['name']) ." was created</td><td>". $resultttt['date'] ."</td></tr>"; } } } }
  3. echo "[ - <a href='". $dir ."game_play.php'>Play</a> - ]"; You should look into the function echo.
  4. Random Error that im getting on my webhost, not localhost. Fatal error: Call to a member function fetch_assoc() on a non-object in /home/*****/index.php on line 127 Line 127: while ($premium = $row->fetch_assoc()) { Code: <div class="toplist-content"> <table cellspacing="0"> <tbody> <?php $row = $home->getList(1); while ($premium = $row->fetch_assoc()) { ?> <tr class="table"> <td class="name"><a href="server.html"> <h3> <?php echo ucfirst($premium['servername']); ?> </a> <font size='1.5'><?php echo ucfirst(substr($premium['serverdesc'],0,25)). "..."; ?> </h3> </font> </td> <td class="revision"><h3> <?php echo ucFirst($premium['revision']); ?> </h3></td> <td class="votes"><h3> <?php echo $premium['vote']; ?> </h3></td> <td class="status"><?php if($home->getStatus($premium['host'], $premium['port']) == true) { echo "<span class='ticket open'>Online</span>"; } else { echo "<span class='ticket closed'>Offline</span>"; } ?> </td> </tr> <?php } ?> </tbody> </table> </div> The getList() function : function getList($premium) { $query = $this->con->query("SELECT * FROM `".$this->prefix."servers` WHERE `premium` = '".$premium."' && `ban` = '0' ORDER BY (SELECT COUNT(*) FROM `".$this->prefix."votes` WHERE `serverId` = '".$this->prefix."servers.id') DESC") or die(mysqli_error()); return $query; }
  5. Please Delete this thread.
  6. Hello, I am trying to make a(n) ajax button start a php script. Im having a bit of trouble and i was hoping you could take a look at the code. I have 3 Different files Index.php , Javascript.js, And save.php. What i want this script to do is Save a file without having to restart the page. Index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Save File</title> <script type="text/javascript" src="js/Javascript.js"></script> </head> <body> <?php $page = $_GET['page']; if($_GET['page']) { $contents = file_get_contents("../toplist/" . $page); ?> <button type='button' onClick="MakeRequest()" name='submit' value='Save code'>Save Code</button> <div id="SavedFile"> </div> <?php echo "<textarea id=\"code\" name='content' rows=\"*\" cols=\"*\">" .htmlspecialchars($contents) . "</textarea>"; echo "<input type='hidden' value='$page' name='page' id='page'/>"; ?> </body> </html> Javascript.js function getXMLHttp() { var xmlHttp try { //Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch(e) { //Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("Your browser does not support AJAX!") return false; } } } function HandleResponse(response) { document.getElementById('SavedFile').innerHTML = response; } function MakeRequest() { var xmlHttp = getXMLHttp(); var page = document.getElementById("page").value; var content = document.getElementById("code").value; xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4) { HandleResponse(xmlHttp.responseText); } } document.savecode.submit(); xmlHttp.open("POST", "edit.save.php", true); xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlHttp.send("page="+page+"&content="+content+""); } Save.php <?php $page = $_GET['page']; $content = $_GET['code']; $handle = fopen('../toplist/' . $page, 'w'); if (!is_writable($page)) { die('File is not writable!'); chmod("../toplist/" . $page, 0755); } $write = fwrite($handle, $content); if ($write === FALSE){ die('Write error!'); } else { echo "File saved"; } fclose($handle); ?> Thanks in advanced for trying.
  7. How would i do that in POST. ? That = load the button.
  8. Im trying to make an AJAX button to load a php code. I dont know whats wrong with it atm. Could you take a look at the code and try to help? Ajax: function MakeRequest() { var xmlHttp = getXMLHttp(); xmlHttp.onreadystatechange = function() { if(xmlHttp.readyState == 4) { HandleResponse(xmlHttp.responseText); } } document.savecode.submit(); xmlHttp.open("GET", "edit.php?save=true", true); xmlHttp.send(null); } function getXMLHttp() { var xmlHttp try { //Firefox, Opera 8.0+, Safari xmlHttp = new XMLHttpRequest(); } catch(e) { //Internet Explorer try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) { alert("Your browser does not support AJAX!") return false; } } } function HandleResponse(response) { document.getElementById('SavedFile').innerHTML = response; } PHP: <?php echo "<input type='submit' onClick=\"document.savecode.submit();\" name='submit' value='Save code' />"; echo "<form name='savecode' action='edit.php?save=true' method='POST' ><textarea id=\"code\" name='code' rows=\"*\" cols=\"*\">" .htmlspecialchars($contents) . "</textarea>"; echo "<input type='hidden' value='$page' name='page' id='page'/>"; echo "</form>"; ?> <div id="SavedFile"> </div>
  9. One my question. it is posible that i can call a javascript function to call a php function and allow it to execute without reloading the page?
  10. im designing something that uses 5 different forms, the text box is in the form and is using a line break when it ends, so if i removed the form and put it somewhere else all id have to do it work the the inputs and make the design alot better.
  11. Curious how would i put a text box outside of a form and still use it?
  12. Thanks also, i have a search for online webpages, it searched everything on a page instantly and shows up like you would do ctrl+f, is there a way i can make the screen move with the highlighted words?
  13. Is it posible to put a submit button somewhere out of a form and still use that submit button with the form?
  14. Hello, i Want the following code and the Variable $page To load a file in a folder. And get all of its contents. How would i do this? <?php $page = "{$_GET['page']}"; if(md5($_GET['page'] == '')) { } ?>
  15. Could you do the favor of perfecting the code.
  16. Atm the loop on line 18 , is making it only register as one file each msg_body div, and im trying to make it so it registers them All in the folder.
  17. None. IT just did not work. Do you have an msn?
  18. The header than i want the $file displayed in a the list_body div
  19. Okay i want line 18's DIV to actually not end on each repeat. im getting confused on how to do it. but everything i try it doesnt work. 1 <?php 2 function getDirectory( $path = '../toplist/', $level = 3 ){ 3 4 $ignore = array( 'cgi-bin', '.', '..', 'images', 'js', 'css', 'admin'); 5 $dh = @opendir( $path ); 6 7 while( false !== ( $file = readdir( $dh ) ) ){ 8 //$files = "<div class=\"msg_body\"><a href='edit.php?file=$file'>". $file ."</a> "; 9 if( !in_array( $file, $ignore ) ){ 10 11 $spaces = str_repeat( ' ', ( $level * 4 ) ); 12 if( is_dir( "$path/$file" ) ){ 13 echo "<p class=\"msg_head\"><strong>$spaces - $file</strong></p>"; 14 // echo "<strong>$spaces - $file<br /></strong>"; 15 getDirectory( "$path/$file", ($level+1) ); 16 } else { 17 18 echo "<div class=\"msg_body\">$spaces $file<br /></div>"; 19 // echo "$spaces $file<br />"; 20 } 21 22 } 23 24 } 25 closedir( $dh ); 26 27 } 29 ?>
×
×
  • 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.