Jump to content

Mod-Jay

Members
  • Posts

    155
  • Joined

  • Last visited

    Never

About Mod-Jay

  • Birthday 02/18/1996

Contact Methods

  • Website URL
    http://mod-justin.com

Profile Information

  • Gender
    Male
  • Location
    On the Computer..

Mod-Jay's Achievements

Member

Member (2/5)

0

Reputation

  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?
×
×
  • 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.