hello plz i need help with this urgently as it i supposed to be used tomorrow :S
i get this error from the following script
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/aybasuco/public_html/MySQL-Formmaker/lib/db_index.inc.php on line 42


thanks in advance for your valiable time

<?php
# MySQL-Formmaker 2002 by Kristof De Jaeger
# swentel@realize.be
# index page displaying databases.

$error = "";
$dbname = "";
$description = "";
/* 
  POST checking from new db insert if $_POST is set, otherwhise just form
  if everything is ok, redirect to table overview (which will be empty)
  otherwise, display errors etc
*/
if (isset($_POST["dbsubmit"]))
{
  $dbname = trim($_POST["newdbname"]);
  if (empty($dbname)) $error .= translate("error1")."<br />";
  if (eregi("[^[:alpha:]_]+",$dbname)) $error .= translate("error3")."<br />";
  if (strlen($dbname) > 64) $error .= translate("error2")."<br />";
  $found = in_array_cin($dbname);
  if ($found == 1) $error .= translate("error5")."<br />";
  $query = "select db_name from formmaker_db where db_name = '".mq_add($dbname)."'";
  $result = mysql_query($query);
  $row = mysql_fetch_object($result);
  if ($row) $error .= translate("error4")."<br />";
  $description = $_POST["description"];

  /* no errors -> insert & redirect to table index */
  if ($error == false)
  {
    $query = "insert into formmaker_db values ('','$dbname','".nl2br(mq_add($_POST['description']))."','0')";
    mysql_query($query);
    $dbid = mysql_insert_id();
    header("location: index.php?formaction=table_index&dbid=$dbid");
  }
}

include("header.inc.php");
/* display existing databases */
$query = "select db_id,db_name,db_description from formmaker_db order by db_name ASC";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
if ($rows > 0)
{
  echo '<span class="titles">'.
   translate("listofdbs").'</span><br /><br />
   <table border="0" cellpadding="4" cellspacing="0">
   <tr><td class="toprow">'.translate("name").'</td><td class="toprow">'.translate("description").'</td>
   <td class="toprow">'.translate("update").'</td><td class="toprow">'.translate("delete").'</td></tr>';
  $foo = '';
  while ($row = mysql_fetch_object($result))
  {
    echo '
    <tr>
      <td valign="top" class="list">'.mq_out($row->db_name).'</td>
      <td valign="top" class="list">'.mq_out($row->db_description).'</td>
      <td valign="top" class="list"><a href="index.php?formaction=table_index&amp;dbid='.$row->db_id.'">'.translate("details").'</a></td>
      <td valign="top" class="list"><a onclick="return confirmdelete(\''.translate("deleteq1").'\')" href="index.php?formaction=db_del&amp;dbid='.$row->db_id.'">'.translate("delete").'</a></td>
    </tr>';
  }
  echo '</table>';
}
else echo '<b>'.translate("nodbsyet").'</b>';

echo '<br /><br />';

# form form for creating new database

echo '<span class="titles">'.
  translate("createnewdb").'</span>
  <form action="index.php" method="post">';
  if (!empty($error)) echo '<span class="error">'.$error.'</span>';
  echo '<p>'.translate("name").' : <br /><input type="text" value="'.mq_out($dbname,1).'" name="newdbname"></input><br />
  * '.translate("help1").' * '.translate("dbeventcreate").'</p>
  <p>'.translate("description").' : <br /><textarea cols="50" rows="5" name="description">'.mq_out($description,1).'</textarea></p>
  <p><input type="submit" name="dbsubmit" value="'.translate("submitnewdb").'"></input></p>
  </form>';

include("footer.inc.php");
?>

i read the link you provided and didn't get a solution
maybe i am doing something wrong
and so i started this topic for someone to help me as i am stuck in time
thanks for your fast reply ..appreciated

so could someone plz get what is wrong with the supplied argument in line 42 ?
thanks in advance

Member Avatar for Dukane

Perhaps the query on line 41 is not being executed.

i read the link you provided and didn't get a solution
maybe i am doing something wrong
and so i started this topic for someone to help me as i am stuck in time
thanks for your fast reply ..appreciated

so could someone plz get what is wrong with the supplied argument in line 42 ?
thanks in advance

The error you are getting tells you exactly what the problem is.
The problem is that the 'supplied argument is not a valid MySQL result resource'.

If you re-read the topic I linked to, you will see it tells you to add error-checking to your queries to tell you what they are not successful.
Add in the error checking and see what errors it gives you.

for the urgent matter i said i used that google documents tools of creating forms and output in excel format
@ Dukane: i think so too
...and still to learn and find the mistake out i will try the error checking "Will" pointed to ..and will inform you with the results perhaps someone benifits from this

thanks alot Dukane & Will

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.