Jump to content

can somebody please look at my queries?


esandra

Recommended Posts

ive had these queries working okay until i checked on it today, it's not working anymore..

these are the errors:::

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\arrastre\add.php on line 105

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\wamp\www\arrastre\add.php on line 117

 

 

if(isset($_POST['add'])){

if($billnmbr=="" or $orno=="" or $payor=="" or $arrastre=="" or $wharfage=="" or $total=="" or $date=="" or $tcl==""){

echo "At least one field was left blank.";

}

else{

$query = mysql_query("select * from `arrastre` WHERE `billnmbr`='$billnmbr'"); /*****************this is my line 105************/

$count = mysql_num_rows($query);

if($count==1){

echo "This billnumber is already in the database.";

}

 

else{

$bll = strtoupper($billnmbr);

$payr = strtoupper($payor);

$query="insert into `arrastre` (`billnmbr`, `orno`, `payor`, `arrastre`, `wharfage`, `total`, `date`, `tcl`)

values ('$bll', '$orno', '$payr', '$arrastre', '$wharfage', '$total', '$date', '$tcl')";

$result=mysql_query($query);

 

$query = mysql_query("select * from `arrastre` where `billnmbr`= '$billnmbr'", $link); /************and this is my line 117*************/

$count = mysql_num_rows($query);

if($count==1){

echo "last bill number added: ".$billnmbr;

}

}

Thank you very much for your time and have a nice day.

Link to comment
https://forums.phpfreaks.com/topic/213347-can-somebody-please-look-at-my-queries/
Share on other sites

Your queries are failing due to some kind of error and assuming you have not changed your code, it is likely a problem with the database server, with your database, or with your table.

 

If you echo mysql_error(); on the next line after the line with your mysql_query() statements, it will tell you why the query(ies) are failing.

Try This

if(isset($_POST['add'])){
if($billnmbr=="" or $orno=="" or $payor=="" or $arrastre=="" or $wharfage=="" or $total=="" or $date=="" or $tcl==""){
echo "At least one field was left blank.";
}
else{
$query = mysql_query("SELECT billnmbr FROM arrastre WHERE billnmbr='$billnmbr'"); /*****************this is my line 105************/
$count = mysql_num_rows($query);
if($count==1){
echo "This billnumber is already in the database.";
}

else{
$bll = strtoupper($billnmbr);
$payr = strtoupper($payor);
$query="insert into `arrastre` (`billnmbr`, `orno`, `payor`, `arrastre`, `wharfage`, `total`, `date`, `tcl`)
values ('$bll', '$orno', '$payr', '$arrastre', '$wharfage', '$total', '$date', '$tcl')";
$result=mysql_query($query);

$query = mysql_query("SELECT billnmbr='$billnmbr' FROM arrastre WHERE billnmbr='$billnmbr'", $link); /************and this is my line 117*************/
$count = mysql_num_rows($query);
if($count==1){
echo "last bill number added: ".$billnmbr;
}
}

 

OR

Add

 or die(mysql_error()) ;

Thats at the End of Both

Off topic slightly, but if all you need to do is return the number of times the number appears in the database, SELECT COUNT(`billmnbr`) AS num would be much more efficient than using mysql_num_rows().

Archived

This topic is now archived and is closed to further replies.

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