yandoo Posted June 27, 2008 Share Posted June 27, 2008 Hi there, I haave a little problem and its a bit fiddlie and was for some help, basically i have a simple button on a menu: <img src="Images/Buttons/admin.png"onclick="window.location.href='http://localhost/RFW/admin.php'" width="100" height="35" /> I am trying to add a If statement conditional so that the button only appears to users with access level of 2. So i ended up with: <?php if (@$row_user_conditional['Access'] == "2") { echo "<img src="Images/Buttons/admin.png"onclick="window.location.href='http://localhost/RFW/admin.php'" width="100" height="35" />"; Trouble is i keep getting errors?? Im thinking that the "", '' or `` speach braces are conflicting with the existing ones i have in the button code...Is there away around this please??? Thank You Quote Link to comment https://forums.phpfreaks.com/topic/112207-solved-if-conditionals-speach-mark-braces-conflict/ Share on other sites More sharing options...
xyn Posted June 27, 2008 Share Posted June 27, 2008 <?php if (@$row_user_conditional['Access'] == "2") { echo "<img src=\"Images/Buttons/admin.png\" onclick=\"window.location.href='http://localhost/RFW/admin.php'\" width=\"100\" height=\"35\" />"; } ?> or <?php if (@$row_user_conditional['Access'] == "2") { ?> <img src="Images/Buttons/admin.png"onclick="window.location.href='http://localhost/RFW/admin.php'" width="100" height="35" /> <? } ?> Quote Link to comment https://forums.phpfreaks.com/topic/112207-solved-if-conditionals-speach-mark-braces-conflict/#findComment-575997 Share on other sites More sharing options...
yandoo Posted June 27, 2008 Author Share Posted June 27, 2008 Hi there, I made the changes and gete this error message: Parse error: syntax error, unexpected $end in C:\wamp\www\RFW\home.php on line 68 heres the full page: <?php require_once('Connections/RFW.php'); ?> <?php $colname_user_conditional = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_user_conditional = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']); } mysql_select_db($database_RFW, $RFW); $query_user_conditional = sprintf("SELECT * FROM customer WHERE Username = '%s'", $colname_user_conditional); $user_conditional = mysql_query($query_user_conditional, $RFW) or die(mysql_error()); $row_user_conditional = mysql_fetch_assoc($user_conditional); $totalRows_user_conditional = mysql_num_rows($user_conditional); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Home</title> <style type="text/css"> <!-- .style11 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 14px; } --> </style> <link href="border.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style12 { font-family: Geneva, Arial, Helvetica, sans-serif; font-weight: bold; } .style13 {font-family: Geneva, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 24px; } --> </style> </head> <body> <table width="90%" height="90%" border="0" align="center" class="border"> <tr> <td height="102" colspan="8" align="center"><p><img src="Images/bnner900.jpg" width="900" height="180" /></p> </td> </tr> <tr> <td align="center" width="20%"> </td> <td align="center" width="12%"> <img src="Images/Buttons/home.png"onClick="window.location.href='http://localhost/RFW/home.php'"></a></td> <td align="center" width="12%"><img src="Images/Buttons/products.png"onClick="window.location.href='http://localhost/RFW/products.php'" width="100" height="35" /></a></td> <td align="center" width="12%"><img src="Images/Buttons/login.png"onClick="window.location.href='http://localhost/RFW/login.php'" width="100" height="35" /></td> <td align="center" width="12%"><img src="Images/Buttons/contact.png"onClick="window.location.href='http://localhost/RFW/contact.php'" width="100" height="35" /></td> <td align="center" width="13%"><img src="Images/Buttons/aboutus.png"onClick="window.location.href='http://localhost/RFW/about.php'" width="100" height="35" /></td> <td align="center" width="12%"><?php if (@$row_user_conditional['Access'] == "2") { ?> <img src="Images/Buttons/admin.png"onclick="window.location.href='http://localhost/RFW/admin.php'" width="100" height="35" /> <? } ?></td> <td align="center" width="20%"> </td> </tr> <tr> <td height="268" colspan="8" align="center" valign="top"><p> </p> <p class="style13">Welcome to Ronin Fightwear.co.uk </p> <p class="style12">Train Together, Fight Alone</p></td> </tr> </table> </body> </html> <?php mysql_free_result($user_conditional); ?> What am i missing??? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/112207-solved-if-conditionals-speach-mark-braces-conflict/#findComment-576012 Share on other sites More sharing options...
xyn Posted June 27, 2008 Share Posted June 27, 2008 you're missing a } somewhere Quote Link to comment https://forums.phpfreaks.com/topic/112207-solved-if-conditionals-speach-mark-braces-conflict/#findComment-576023 Share on other sites More sharing options...
shelluk Posted June 27, 2008 Share Posted June 27, 2008 Before the mysql_free_result($user_conditional); at the end! Not ended if (@$row_user_conditional['Access'] == "2") { Quote Link to comment https://forums.phpfreaks.com/topic/112207-solved-if-conditionals-speach-mark-braces-conflict/#findComment-576099 Share on other sites More sharing options...
br0ken Posted June 27, 2008 Share Posted June 27, 2008 Here's the full code if you haven't already figured it out. <?php require_once('Connections/RFW.php'); ?> <?php $colname_user_conditional = "-1"; if (isset($_SESSION['MM_Username'])) { $colname_user_conditional = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']); } mysql_select_db($database_RFW, $RFW); $query_user_conditional = sprintf("SELECT * FROM customer WHERE Username = '%s'", $colname_user_conditional); $user_conditional = mysql_query($query_user_conditional, $RFW) or die(mysql_error()); $row_user_conditional = mysql_fetch_assoc($user_conditional); $totalRows_user_conditional = mysql_num_rows($user_conditional); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Home</title> <style type="text/css"> <!-- .style11 {font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 14px; } --> </style> <link href="border.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .style12 { font-family: Geneva, Arial, Helvetica, sans-serif; font-weight: bold; } .style13 {font-family: Geneva, Arial, Helvetica, sans-serif; font-weight: bold; font-size: 24px; } --> </style> </head> <body> <table width="90%" height="90%" border="0" align="center" class="border"> <tr> <td height="102" colspan="8" align="center"><p><img src="Images/bnner900.jpg" width="900" height="180" /></p> </td> </tr> <tr> <td align="center" width="20%"> </td> <td align="center" width="12%"> <img src="Images/Buttons/home.png"onClick="window.location.href='http://localhost/RFW/home.php'"></a></td> <td align="center" width="12%"><img src="Images/Buttons/products.png"onClick="window.location.href='http://localhost/RFW/products.php'" width="100" height="35" /></a></td> <td align="center" width="12%"><img src="Images/Buttons/login.png"onClick="window.location.href='http://localhost/RFW/login.php'" width="100" height="35" /></td> <td align="center" width="12%"><img src="Images/Buttons/contact.png"onClick="window.location.href='http://localhost/RFW/contact.php'" width="100" height="35" /></td> <td align="center" width="13%"><img src="Images/Buttons/aboutus.png"onClick="window.location.href='http://localhost/RFW/about.php'" width="100" height="35" /></td> <td align="center" width="12%"><?php if (@$row_user_conditional['Access'] == "2") { ?> <img src="Images/Buttons/admin.png"onclick="window.location.href='http://localhost/RFW/admin.php'" width="100" height="35" /> <? } ?></td> <td align="center" width="20%"> </td> </tr> <tr> <td height="268" colspan="8" align="center" valign="top"><p> </p> <p class="style13">Welcome to Ronin Fightwear.co.uk </p> <p class="style12">Train Together, Fight Alone</p></td> </tr> </table> </body> </html> <?php mysql_free_result($user_conditional); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/112207-solved-if-conditionals-speach-mark-braces-conflict/#findComment-576216 Share on other sites More sharing options...
yandoo Posted June 29, 2008 Author Share Posted June 29, 2008 Hi there, Thank YOu all very much, thats it! Quote Link to comment https://forums.phpfreaks.com/topic/112207-solved-if-conditionals-speach-mark-braces-conflict/#findComment-577642 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.