desithugg Posted July 30, 2006 Share Posted July 30, 2006 umm php "if" function isn't working againmy username is "desithugg" no capitalmy table looks like this________________item | Owner | idred | desithugg | 1________________[code]<?phpmysql_connect("localhost", $my_sql_password, $my_sql_username) or die("Could not connect: " . mysql_error());mysql_select_db("tpf");$result = mysql_query("SELECT owner FROM pokeballs where id = '1'");if (!$result) { echo 'Could not run query: ' . mysql_error(); exit;}$row = mysql_fetch_row($result);$owner = $row[0];?>[/code]and btw. in the next peice the $user_currently_loged variables outputs my username[code]<?PHPif ($owner != "$user_currently_loged"){ echo "<center>Sorry the item you specified to use does not belong to you."; exit(); }?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16034-php-if-not-working/ Share on other sites More sharing options...
para11ax Posted July 30, 2006 Share Posted July 30, 2006 What exactly is happening? Is the query failing, but it's skipping the if statement? Quote Link to comment https://forums.phpfreaks.com/topic/16034-php-if-not-working/#findComment-65955 Share on other sites More sharing options...
desithugg Posted July 30, 2006 Author Share Posted July 30, 2006 o sorry forgot to mention the username mataches the owner but it is still giving that error "Sorry the pokeball you specified to use does not belong to you." Quote Link to comment https://forums.phpfreaks.com/topic/16034-php-if-not-working/#findComment-65960 Share on other sites More sharing options...
redarrow Posted July 30, 2006 Share Posted July 30, 2006 Try this please ok.[code]<?phpmysql_connect("localhost", $my_sql_password, $my_sql_username) or die("Could not connect: " . mysql_error());mysql_select_db("tpf");$query ="SELECT owner FROM pokeballs where id = '1' ";$result=mysql_query($query) or die(mysql_problam());if (!$result) { echo 'Could not run query: ' . mysql_error(); exit;}while($row=mysql_fetch_assoc($result)){$owner = $row[0];}?>[/code][code]<?PHPmysql_connect("localhost", $my_sql_password, $my_sql_username) or die("Could not connect: " . mysql_error());mysql_select_db("tpf");$query ="SELECT * FROM pokeballs where id = '1' ";$result=mysql_query($query)or die(mysql_problam());while($row=mysql_fetch_assoc($result)){$owner = $row[0];if (! $owner) { echo "<center>Sorry the item you specified to use does not belong to you."; exit(); }}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16034-php-if-not-working/#findComment-65965 Share on other sites More sharing options...
para11ax Posted July 30, 2006 Share Posted July 30, 2006 You might also want to add "or die (mysql_error());" to your query to make sure it is executing correctly and to get an error if not:[code=php]$result = mysql_query("SELECT owner FROM pokeballs where id = '1'") or die (mysql_error());[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16034-php-if-not-working/#findComment-65968 Share on other sites More sharing options...
desithugg Posted July 30, 2006 Author Share Posted July 30, 2006 iv found the error for some resonthe include is not working so it compares the owner with "" a blank username im not sure why<?php$reqlevel = 1;include("membersonly.inc.php");?>and its not working no matter which file i try to include Quote Link to comment https://forums.phpfreaks.com/topic/16034-php-if-not-working/#findComment-65972 Share on other sites More sharing options...
desithugg Posted July 30, 2006 Author Share Posted July 30, 2006 umm im goind to try require Quote Link to comment https://forums.phpfreaks.com/topic/16034-php-if-not-working/#findComment-65976 Share on other sites More sharing options...
AndyB Posted July 30, 2006 Share Posted July 30, 2006 If the include isn't working (or require doesn't work) why aren't you seeing the error messages??? Quote Link to comment https://forums.phpfreaks.com/topic/16034-php-if-not-working/#findComment-65978 Share on other sites More sharing options...
desithugg Posted July 30, 2006 Author Share Posted July 30, 2006 dont know its just a blank page the $user_currently_loged variable is set in the page i want to include and when i add include and try to echo the variable its not working so im assuming thats the reason Quote Link to comment https://forums.phpfreaks.com/topic/16034-php-if-not-working/#findComment-65979 Share on other sites More sharing options...
AndyB Posted July 30, 2006 Share Posted July 30, 2006 [code]<?phperror_reporting(E_ALL);$reqlevel = 1;include("membersonly.inc.php");?>[/code]Save that as test.php and run it. Tell us exactly what you see. Quote Link to comment https://forums.phpfreaks.com/topic/16034-php-if-not-working/#findComment-65994 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.