Jump to content

Recommended Posts

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

$bil = 1;

$id_month     = isEmptyField($_POST['id_month']);

$id_location  = isEmptyField($_POST['loc']);

      $query="Select * from stock where id_location=$id_location and id_month=$id_month";

$run=mysql_query( $query);

$numrows = mysql_num_rows($run);    ******error here******

 

if($numrows == 0)

{

     echo "No results found.";

}

else

{

while($row = mysql_fetch_array($run1, MYSQLI_ASSOC)){

 

echo "<tr>"; 

echo "<td> $bil </td>"; 

echo "<td>" . $row['partnumber'] . "</td>"; 

echo "<td >" . $row['stockIn'] . "</td>"; 

echo "<td>" . $row['stockOut' ]. "</td>"; 

echo "<td >" . $row['id_month' ]. "</td>"; 

echo "<td >" . $row['id_location'] . "</td>"; 

echo "<td >" . $row['status'] . "</td>"; 

echo "</tr>";

 

}

 

 }

 echo " </thead>";

echo "</table>";

?>

 

 <?php 

     $bil++;

 } mysql_free_result($run);  ******error here******

 

 ?>

The error is in the query. You need to put single quotes around strings.

 

Php has a built in function to find empty fields - empty(). Not sure where u got what ur using.

 

Also need to choose one, either use myself or mysqli, can't use both. And where is $ run1 coming from?

Edited by richei

The error is in the query. You need to put single quotes around strings.

 

Strings can have either single or double quotes around them. However, double quotes are needed if the string contains something PHP needs to expand like a variable. More information about strings can be found here:

http://www.php.net/manual/en/language.types.string.php

 

 

Also need to choose one, either use myself or mysqli, can't use both.

 

I may have missed it, but I don't see where the OP (merpati) is using MySQLi. They all look to be regular MySQL functions. Of course, the OP should consider using something other than mysql_* functions since they are deprecated (http://www.php.net/manual/en/mysqlinfo.api.choosing.php). He/she may already be looking into that though.

 

 

And where is $ run1 coming from?

 

That's a good point. I would imagine that's supposed to be $run. 

 

 

 

@merpati - have you tried using mysql_error() to see if there are any SQL errors being reported? More information can be found here:

http://www.php.net/manual/en/function.mysql-error.php

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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