Jump to content

whats wrong with my code?


therelelogo

Recommended Posts

hi,

 

a little confused why my code doesn't seem to work:

<?php
// Connect to MySQL

// Delete Bobby from the "example" MySQL table
mysql_query("SELECT email_add_public FROM members WHERE login='{$_SESSION['SESS_LOGON_NAME']}'") 
or die(mysql_error());  

if ($mysql_query == 'NO') {
echo"[make public]";
}else if (email_add_public == 'YES') {
echo"[make private]";
}
?>

 

i've also tried single and double "=" with $mysql_query and email_add_public and it just doesnt seem to return anything?

 

any help appreciated thanks

Link to comment
Share on other sites

<?php
// Connect to MySQL

// Delete Bobby from the "example" MySQL table
$query = mysql_query("SELECT email_add_public FROM members WHERE login='{$_SESSION['SESS_LOGON_NAME']}'") 
or die(mysql_error());  
$fetch = mysql_fetch_array($query);
if ($fetch[email_add_public] == 'NO') {



echo"[make public]";



}else if ($fetch[email_add_public] == 'YES') {



echo"[make private]";



}
?>

Link to comment
Share on other sites

$result = mysql_query("SELECT UPPER(email_add_public) FROM members WHERE login='{$_SESSION['SESS_LOGON_NAME']}'");
if(false !== $result && 0 !== mysql_num_rows($result)) {
  list($email_add_public) = mysql_fetch_row($result);
  switch($email_add_public) {
    case 'NO' : echo 'NO'; break;
    case 'YES': echo 'YES'; break;
  }
} else echo('No such record');

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.