PHP Syntax Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
khushi21
Forum Newbie
Posts: 3
Joined: Thu May 26, 2005 10:14 pm
Contact:

PHP Syntax Help

Post by khushi21 »

Hi
Im trying to make a page in my website where If someone comes up and want to know rate of calling to particular country It will fetch the info from database and sho it over there. But I'm getting some errors, saying

#############################
"Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in G:\it301projects2005\semester1\sumit\rateprocess.php on line 13
###############################


Below are my files :

Code: Select all

<?

include("database.php");
include("form.php");

function getrate($subcountry)
{
 	global $database;

	$q = "SELECT country,rate FROM ".TBL_RATES." WHERE country LIKE `%$subcountry%`";
      $result = $database->query($q);
   	///* Error occurred, return given name by default */
   	$num_rows = mysql_numrows($result);
   	//if(!$result || ($num_rows < 0))
	//	{
     	 //		echo "Error displaying info";
	   //  		 return;
   		//}
//   	 else
//		{
			echo "<table align=\"left\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">\n";
   			echo "<tr><td><b>Country</b></td><td><b>Rate/minute</b></td></tr>\n";
  			 for($i=0; $i<$num_rows; $i++)
				{
      					$crate = mysql_result($result,$i,"country");
      					$rat  = mysql_result($result,$i,"rate");

      					echo "<tr><td>$crate</td><td>$rat</td></tr>\n";
   				}
  	 		echo "</table><br>\n";
		//}
      
}
?>			

<html>
<title> rate</title>
<body>
<h1>rate page</h1>
<font size="5" color="#ff0001">
<?
if($form->num_errors > 0){
   echo "<font size=\"4\" color=\"#ff0000\">"
       ."!*** Error with request, please fix</font><br><br>";
}
?>
<table align="left" border="0" cellspacing="5" cellpadding="5">
<tr><td>

<?
 getrate($_POST['country']);
?>
</td></tr>

</tr>
</table>
</body>
</html>
##################
the other form file is:

Code: Select all

<?


include("session.php");
?>





<html>
<title>rate Page</title>
<body>




<h1>Rate Description</h1>
<p> Please fill below the country name where you want to make call and see how much it cost you by using our services</p>
<?
if($form->num_errors > 0){
   echo "<td><font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font></td>";
}
?>

<form action="rateprocess.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Country Name:*</td><td><input type="text" name="country" maxlength="30" value="<? echo $form->value("country"); ?>"></td><td><? echo $form->error("country"); ?></td></tr>



<tr><td colspan="2" align="Center">
<input type="hidden" name="subfind" value="1">
<input type="submit" value="Find Now!"></td></tr>

</body>
</html>

Can somebody help me please!!!!!!!!!!!!!!!!!


Thanks in advance for ur help.

JCART | Please use

Code: Select all

tags when posting php-code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Post database.php. The problem most likely has to do with what the 'query' method of the database class is returning.
Post Reply