Jump to content

[SOLVED] If Conditional's ""speach mark braces conflict?


yandoo
 Share

Recommended Posts

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 :D

 

Link to comment
Share on other sites

<?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" />
<?
}
?>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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);
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.