Jump to content

[SOLVED] elseif problem


adam291086

Recommended Posts

Ok when i execute the code i get the error below. What i dont understand is that i need all of the > to end the html code

 

Can anyone spot the problem,

 

Parse error: parse error, unexpected '>' in /homepages/12/d214897219/htdocs/adam/cycling/authentication/main.php on line 36

<?php
session_start();

// is the one accessing this page logged in or not?
if (!isset($_SESSION['db_is_logged_in']) 
   || $_SESSION['db_is_logged_in'] !== true) {

   // not logged in, move to login page
   header('Location: login.php');
   exit;
}

include 'config.php';



$result = mysql_query("SELECT * FROM  tbl_auth_user");
while($row = mysql_fetch_array($result))


{
  $home = $row['Home page'];
  $ryedale= $row['Ryedale Rumble'];
  $adam= $row['Adam'];
   }


if ($home=="yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>;
}

elseif ($ryedale=="yes")
{
echo ' <p><input type="button" name="edit ryedale page content" value="www.google.com" /></p>';
echo '<br></br>;
}

elseif ($adam=="yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>;
}

elseif ($ryedale || $adam || $ryedale =="no")
{
echo ' <p>you smell</p>';
echo '<br></br>;
}

include 'closedb.php';



?>


Link to comment
Share on other sites

if ($home=="yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>;

 

 

should be

 

if ($home=="yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>';

 

And theres the same problem on the other similar blocks following it.

Link to comment
Share on other sites

try this

 

<?php
session_start();

// is the one accessing this page logged in or not?
if (!isset($_SESSION['db_is_logged_in']) 
   || $_SESSION['db_is_logged_in'] !== true) {

   // not logged in, move to login page
   header('Location: login.php');
   exit;
}

include 'config.php';



$result = mysql_query("SELECT * FROM  tbl_auth_user");
while($row = mysql_fetch_array($result))


{
  $home = $row['Home page'];
  $ryedale= $row['Ryedale Rumble'];
  $adam= $row['Adam'];
   }


if ($home=="yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>';
}

elseif ($ryedale=="yes")
{
echo ' <p><input type="button" name="edit ryedale page content" value="www.google.com" /></p>';
echo '<br></br>';
}

elseif ($adam=="yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>';
}

elseif ($ryedale || $adam || $ryedale =="no")
{
echo ' <p>you smell</p>';
echo '<br></br>';
}

include 'closedb.php';



?>

Link to comment
Share on other sites

ok i have now change all the code to incorporate the changes. Now one button shows. But there should be three buttons in total.

It appears the else if statments aren't working

 

<?php
session_start();

// is the one accessing this page logged in or not?
if (!isset($_SESSION['db_is_logged_in']) 
  || $_SESSION['db_is_logged_in'] !== true) {

  // not logged in, move to login page
  header('Location: login.php');
  exit;
}

include 'config.php';

$search = $_SESSION['username'];


$result = mysql_query("SELECT * FROM  tbl_auth_user WHERE user_id ='$search' ");
while($row = mysql_fetch_array($result))


{
 $home = $row['Home page'];
 $ryedale= $row['Ryedale Rumble'];
 $adam= $row['Adam'];
  }


if ($home=="yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.googhchkjhdsfkjssdfle.com" /></p>';
echo '<br></br>';
}
elseif ($ryedale=="yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>';
}

elseif ($adam=="yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>';
}

elseif ($ryedale || $adam || $ryedale =="no")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>';
}
include 'closedb.php';



?>


Link to comment
Share on other sites

$result = mysql_query("SELECT * FROM  tbl_auth_user WHERE user_id ='$search' ") or die(mysql_error());

 

Thats the first thing i saw, try that and see if there is a problem with the query...

 

 

Also

 

change the while statement to

 

while($row = mysql_fetch_array($result))


{
  

$home = $row['Home page'];
$ryedale= $row['Ryedale Rumble'];
  $adam= $row['Adam'];
   


if ($home=="yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.googhchkjhdsfkjssdfle.com" /></p>';
echo '<br></br>';
}
elseif ($ryedale=="yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>';
}

elseif ($adam=="yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>';
}

elseif ($ryedale || $adam || $ryedale =="no")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>';
}

}

Link to comment
Share on other sites

nope, there is nothing worng with the query. This is so strange as it is showing one button. I have manually checked the data base and when logged in as the admin everything is  == 'yes'. Therefore all buttons should show. Any ideas?

 

Alright try this and tell me if it works....

 

And if it doesnt, check the coloumn names in your database....

 

while($row = mysql_fetch_array($result))


{
if ($row['Home page'] =="yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.googhchkjhdsfkjssdfle.com" /></p>';
echo '<br></br>';
}
if ($row['Ryedale Rumble'] == "yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>';
}

if ($row['Adam'] == "yes")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>';
}

if ($ryedale || $adam || $ryedale =="no")
{
echo ' <p><input type="button" name="edit home page content" value="www.google.com" /></p>';
echo '<br></br>';
}

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • 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.