index.php

<title>Administration</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>

<?php 


if($_GET['AppID']<0){ $AppID=0; }else{ $AppID=$_GET['AppID']; }

include'config.php';

$sql = 'SELECT `Status` , `Site` , `Domain` , `Username` , `Password` , `Email` , `Notes`'       
. ' FROM `tblapp` '
. ' WHERE `ApplicationID`='.$AppID.' AND `Status` '
. ' LIKE \'Applying\' LIMIT 0, 30'; $result = mysql_query($sql); echo "Applications for Review:"; mysql_num_rows($result); $row = mysql_fetch_array($result); ?> <table width="651" border="2"> <tr>
<td><strong>Application # <?php echo "$AppID"; ?></strong></td> </tr> <tr> <td> <form action="update.php" method="post" name="form1" target="_self"> <p><strong>Status:</strong> <select name="Status" id="Status"> <option>selected><?php echo "$row[Status]"; ?></option> <option>Rejected</option> <option>Accepted</option> </select> <input name="ID" type="hidden" id="ID" value="<?php echo "$AppID"; ?>"> </p> <p> <strong>Site Description:</strong><br> <?php echo "$row[Site]"; ?>
<p>
<input name="Save" type="submit" id="Save" value="Save">
<input name="Reset" type="reset" id="Reset" value="Reset">
</p>
</form> </td> </tr> </table> <p> <?php $idplus = $AppID + 1; $idminus = $AppID - 1; ?> <a href="index.php?AppID=<?php echo "$idminus"; ?>">Previous </a> | <a href="index.php?AppID=<?php echo "$idplus"; ?>">Next</a> <?php mysql_close($Hosting); ?> </p> </body> </html>

i keep on getting this error

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/script/public_html/free/admin/index.php on line 22

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home2/script/public_html/free/admin/index.php on line 24

I get those errors where php is supposed to get the number of rows in the query and where php is supposed to echo the query..everything else is fine though...its weird...i played around w. it so much...but i cant figure it out

    those errors usually occur when somehting is wrong with the $result variable. First off, i might have missed it, but I do not see a connection string to the database. Also, try outputting the mysql_error() on everything and see what you get. switch your sql execution statement to the one below and see what happens.

    if(!($result = mysql_query($sql, $connectionToDatabase))){
         print("MySQL reports: " . mysql_error() . "\n");
         exit();
    }
    

      config.php

       <?php
      # Database Details
      $Hostname = "localhost";
      $Database = "";
      $Username = "";
      $Password = "";
      $Hosting = mysql_connect($Hostname, $Username, $Password) or die(mysql_error());
      
      # Select Database
      mysql_select_db($Database,$Hosting);
      
      
      ?>
      

      I'm not puting my username, db, and pass for security info.
      Also i have include "config.php" as one of the first lines in index.php

        The error is usually because of a problem in the sql.

        $sql = 'SELECT `Status` , `Site` , `Domain` , `Username` , `Password` , `Email` , `Notes`'       
        . ' FROM `tblapp` '
        . ' WHERE `ApplicationID`='.$AppID.' AND `Status` '
        . ' LIKE 'Applying' LIMIT 0, 30';

        My guess would be that last line. The single quotes around Applying would need to be slashed if that's static, but if it's supposed to be a variable, you're missing the $. Either way, you shouldn't use like, you should use =. Like is for wildcard matches and degrades performance when a straight equal comparison is used.

          Write a Reply...