Jump to content

Mod-Jay

Members
  • Posts

    155
  • Joined

  • Last visited

    Never

Posts posted by Mod-Jay

  1. 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>";
    			}
    
    		}
    
    	}
    
    }

  2. 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;
    }
    

  3. 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.

  4. 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>
    

  5. 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.

  6. 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?

  7. 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.