Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

if statement error

$
0
0


$username = "root"; 
$password = "duane";
$hostname = "localhost";

$con = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");
echo "Connected to MySQL<br>";
$selected = mysql_select_db("dummy") or die ("No existing database".mysql_error());

$number = "$_POST[number]";
$keyword = $message[2];

if($keyword == "balance"||"BALANCE"){
	$reply = mysql_query("SELECT * from profile where contact = '$number'");
	$info = mysql_fetch_array($reply);
	echo "Your remaining balance is: ".$info['credit']."<br />";
}else
if ($keyword == "menu"||"MENU")	{
	$data = mysql_query("SELECT * from food") or die (mysql_error());
	while ($row = mysql_fetch_array($data)) {
  			echo "<strong>Item(</strong>".$row{'menu_tag'}."<strong>):</strong> ".$row{'item'}
		." --<em>price</em>:".$row{'price'}."<br>";//display the results
	}
}else
if ($keyword == "snacks"||"SNACKS")	{
	$data = mysql_query("SELECT * from inventory") or die (mysql_error());
	while ($row = mysql_fetch_array($data)) {
		echo "<strong>Item(</strong>".$row{'tag'}."<strong>):</strong> ".$row{'item'}
		." --<em>price</em>:".$row{'price'}."<br>";//display the results
	}
}

 

there are no syntax errors. my problem is that it keeps on entering the FIRST if statement even if the $keyword is not "balance" @@


Viewing all articles
Browse latest Browse all 13200

Trending Articles