Hi
Im very new to this forum and also to PHP in general - its a summer topic covered at my uni.
I am trying to create a simple form for uni, which, when you type in a serial number or licence number, it checks mysql, and if the licence/serial is in the db it displays "product supported" and if its not in the db it displays "product not supported" My script below is not working and automatically displays "product supported" even when its not. Could anyone please help and point me in the right direction ?
//code//
<?php
$serial = $_GET['serial'];
$licence = $_GET['licence'];
$referer = $_SERVER['HTTP_REFERER'];
# if either form field is empty return 1st page
if( ( !$serial ) and ( !$licence ) )
{ header( "Location:$referer" ); exit(); }
#connect to MySQL
$conn=@mysql_connect( "localhost", "root", "" )
or die( "Could not connect" );
#select the specified database
$rs = @mysql_select_db( "assignment", $conn )
or die( "Could not select database" );
#create the query (select all from table "supported" where values match the inputted data)
$sql = "select * from supported where serial=\"$serial\" or licence =( \"$licence\" )";
#execute the query
$rs = mysql_query( $sql, $conn )
or die( "Could not execute query" );
#get number of rows that match query
$num = mysql_num_rows( $rs );
#if there is a match the query produces a message
if( $num != 0 )
{
$msg = "<h3>Product is supported</h3>";
}
else if ($num != );
{
$msg1 = "<h3> Product is NOT supported</h3>";
}
// header( "Location:$referer" ); exit();
mysql_close($conn);
?>
<html>
<head>
<title>Product Supported</title>
</head>
<body style="color:green; background:black;">
<?php echo( $msg ),
//getting error relating to this line
else echo ( $msg1);
?>
</body>
</html>
//code ends//
Additional Details
Im Getting the error between this point:
<?php echo( $msg ),
//getting error relating to this line
else echo ( $msg1);
?>
I ve tried adding the array from where I set the variable for $msg1 but still it just displays the 1st echo $msg and errors $msg1
Any help is much appreciated!