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
https://forums.phpfreaks.com/topic/78551-solved-elseif-problem/
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
https://forums.phpfreaks.com/topic/78551-solved-elseif-problem/#findComment-397490
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
https://forums.phpfreaks.com/topic/78551-solved-elseif-problem/#findComment-397491
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
https://forums.phpfreaks.com/topic/78551-solved-elseif-problem/#findComment-397493
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
https://forums.phpfreaks.com/topic/78551-solved-elseif-problem/#findComment-397497
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
https://forums.phpfreaks.com/topic/78551-solved-elseif-problem/#findComment-397739
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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