0

Okay this is my code, i can't get the else statement part to work...can anyone kindly assist me...i find nothing wrong with the syntax...thank u...

ps: no error...

<?php
session_start();
$host="localhost"; // Host name
$username=""; // Mysql username
$password=""; // Mysql password
$db_name="test"; // Database name
$tbl_name="testing"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die(mysql_error());

$invoiceno=$_POST['invoiceno'];

$sql="SELECT * FROM $tbl_name WHERE invoice_no = '$invoiceno'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result) or die(mysql_error());

if($row>0)
echo "Invoice No. found";
else
header("location:main_login.php");

?>
3
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by scarcella
1

Hi, i think i can see your question. My advice would either be put the curly brackets in ({) and maybe change the statement to if (mysql_num_rows($result) !=0) { ...

if (mysql_num_rows($result) !=0) {
        echo "Invoice No. found";
} else {
        header("location:main_login.php");
}

Thanks,
Marais

Edited by scarcella: n/a

Votes + Comments
0

Replace your line 17

$row = mysql_fetch_array($result) or die(mysql_error());

with

$row = mysql_num_rows($result);
0

heyy...thanks for the reply....its still the same....its just showing a blank page when i click the submit.

the previous file, the invoice number comes from here.

<title>Shipping Cross-Check System</title>
<form method="post" name="form">
<h1>Enter your Invoice No. to create a new shipment</h1>
<table>
<tr>
<td>Invoice No. :</td><td><input name="invoiceno" type="text" size"25"></input></td>
</tr>
</table>
<input type="submit" name="submit" value="Back" onclick="form.action='main_login.php';"></input>
<input type="submit" name="submit" value="Submit" onclick="form.action='display.php';"></input>

</FORM>
0

hahaha...its working....thank u soo much Mr. Karthik...owe you one...

0

Hmmm, maybe try changing this:

$sql="SELECT * FROM $tbl_name WHERE invoice_no = '$invoiceno'";

to this:

$sql="SELECT * FROM $tbl_name WHERE invoice_no = '".$invoiceno."'";

Let me know the result.

~Marais

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.