0

hi, i'm working with php short hand for the first time and i'm trying to edit this code:

<?=($c->is_admin == 'Yes')?'<a href="msg_update.php" input type="submit" class="button" value="protected page">Update Home Page Message</a>'
:
'
            <p>
                This is not the page you were looking for.
            </p>
'

?> 

i want to do something like this :

<?=($c->is_admin == 'Yes')?'<a href="msg_update.php" input type="submit" class="button" value="protected page">Update Home Page Message</a>'
$con = @mysql_connect(my login stuff);
mysql_select_db(more stuff); // database
if (!$con)
  {
  echo'connection error';
  die('Could not connect: ' . mysql_error());
  }
:
'
            <p>
                This is not the page you were looking for.
            </p>
'

?> 

any ideas why it wont work?

2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by cereal
0

Try this:

<?php

$ok = '<a href="msg_update.php" input type="submit" class="button" value="protected page">Update Home Page Message</a>'; # this is mix of input and a tags, it's not correct
$error = '<p>This is not the page you were looking for.</p>';
$con = @mysql_connect(my login stuff);
$connection_err = false;
mysql_select_db(more stuff);
if(!$con) { $error .= "\nConnection error". mysql_error(); $connection_err = true; }

echo ($c->is_admin != 'Yes' || $connection_err === true) ? $error:$ok;
?>

Edited by cereal

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.