Jump to content

ansonb

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

ansonb's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks, That helps. So what if I wanted to select all from the last 60 days. Would that be: $sql = "SELECT * FROM podcasts WHERE DATE(airdate) < 60";
  2. I am working on a podcast list script. It displays the results of my mysql query correctly, but shows the results in 1 long list. $query3 = "SELECT * FROM podcasts WHERE show_id = $show_id ORDER BY airdate DESC"; $result3 = mysql_query($query3) or die(mysql_error()); I would like to further filter the results instead of 1 hugely long list. For example, view by year, month etc... The 'airdate' is stored in the database as DATETIME. Is there a way to seperate the parts of the date: year, month, day using php ?? And if so how would I go about displaying only the podcasts for a specific year or month etc. ?? website located at http://www.eliteweboffers.com/lwr/podcasts.php Thanks.
  3. Thank You. Duh, I knew it was simple.
  4. I need help with my if/else statement. function show_list() { $query = "SELECT show_id,show_name,host,description_short,show_graphic1 FROM shows"; $result = mysql_query($query) or die(mysql_error()); echo "<table>"; while($row = mysql_fetch_array($result)) { echo "<tr> <td rowspan='3' width='155' class='show_image'> <a href='". $site ."show_page.php?show_id=". $row['show_id'] ."'> <img src='". $site ."images/". $row['show_graphic1'] ."' height='150' width='150'></img></a> </td> <td class='show_name'> <h1>"; if ($row['host'] == "") { echo $row['show_name']" with " $row['host']; } else { echo $row['show_name']; } echo " </h1> </td> </tr> <tr> <td height='100'>" . $row['description_short'] . "</td> </tr> <tr> <td align='right'> <a href='". $site ."show_page.php?show_id=". $row['show_id'] ."'>More Info</a> </td> </tr>"; } echo "</table>"; } This function is for a page showing a list of shows from a database. Not all shows have a host. So it does not need to show "with host name" for those shows. I tried if / else statement stating that if there "is" data in the row to display one thing and if there "is not" data in the row to display another. Here is that piece of code. if ($row['host'] == "") { echo $row['show_name']" with " $row['host']; } else { echo $row['show_name']; } I keep getting this error "Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/ansonb/lwr_config.php on line 46" What am I doing wrong ? I'm sure it is something simple, I just can't figure it out.
  5. Thank You DavidAM. It works. I am a little rusty, haven't done coding in a while. I'm not quite sure what you meant about the commas in #1 of you reply. Can you show me a code example of what you mean? Anything to make it less confusing helps. Also, in #5 you suggested not using a while loop since I only need one row. What should I use instead ? And can you please post code example of this ?? Thank You. PS Sorry fenway. I posted to this topic by accident. You can move it.
  6. Thank You, I will try this and see what happens.
  7. I am having issues in writing a program. The basic idea is a internet radio website. I have a page listing all shows on the station with a brief description. When you click on a specific show from that page, i need it to open a page showing more detail on just that show. The show list page is loading with no problem, but the show detail pages keep coming up with "Error in your sql syntax at line 1" See what I have at http://www.eliteweboffers.com/lwrs/shows.php Here is the code from config.php <?php mysql_connect($host,$user,$password); mysql_select_db($db); //Functions function show_list() { $query = "SELECT * FROM shows"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo " <table border='0'> <tr> <td rowspan='2'> <a href='". $site ."show_page.php?". $row['id'] ."' name='show_id' value='". $row['id'] ."'> <img src='". $site,$row['picture'] ."' height='180' width='180'></img></a> </td> <td> " . $row['show'] . " </td> </tr> <tr> <td> " . $row['description-short'] . " </td> </tr> </table> ";} } function show_page() { $show_id=$_POST[show_id]; $query = "SELECT * FROM shows WHERE id = $show_id"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ echo " <table border='0'> <tr> <td rowspan='2'> <img src='". $site,$row['picture'] ."' height='180' width='180'></img> </td> <td> " . $row['show'] . " </td> </tr> <tr> <td> " . $row['description-short'] . " </td> </tr> </table> ";} } ?> If i change the line $show_id=$_POST[show_id]; to $show_id=1; It loads the show detail page properly for the first show. I don't want to have to use "if" statements for every single show id. What am I doing wrong ? Can anyone help ??? Here is the code from shows.php <?php include ('/home/ansonb/lwr_config.php'); show_list(); ?> Here is the code from show_page.php <?php include ('/home/ansonb/lwr_config.php'); show_page(); ?> Any help would be greatly appreciated. Thank you !
  8. Oh sorry. Well can you help me ???
  9. It is not working. I am frustrated and can not figure it out. Here is the entire PHP code. Please inspect and tell me what I am doing wrong. Thanks. "<?php require_once('../../includes/header.php'); if (file_exists(SITE_ROOT.'/themes/'.THEME.'/account/register.php')){//account register from the theme! require_once(SITE_ROOT.'/themes/'.THEME.'/account/register.php'); } else{//not found in theme ?> <h2><?php _e("Register")?></h2> <?php $show_form = true; if ($_POST && checkCSRF('register_user')){ if(checkMathCaptcha('register')) { $name = cP('name'); $email = cP('email'); $password = cP('password'); $password_confirmation = cP('password_confirmation'); $mailinglist = cP('mailinglist'); $agree_terms = cP('agree_terms'); if( isset($_POST['mailinglist']) ) { $mailinglist = 1; } else { $mailinglist = 0; } if ($agree_terms == "yes"){ if (isEmail($email)){ if ($password == $password_confirmation){ $account = new Account($email); if ($account->exists){ echo "<div id='sysmessage'>".T_("Account already exists")."</div>"; } else { if ($account->Register($name,$email,$password)){ $token=$account->token(); $url=accountRegisterURL(); if (strpos($url,"?")) $url.='&account='.$email.'&token='.$token.'&action=confirm'; else $url.='?account='.$email.'&token='.$token.'&action=confirm'; $message='<p>'.T_("Click the following link or copy and paste it into your browser address field to activate your account").'</p> <p><a href="'.$url.'">'.T_("Confirm account").'</a></p><p>'.$url.'</p>'; $array_content[]=array("ACCOUNT", $name); $array_content[]=array("MESSAGE", $message); $bodyHTML=buildEmailBodyHTML($array_content); sendEmail($email,T_("Confirm your account")." - ".SITE_NAME,$bodyHTML);//email registration confirm request $show_form = false; echo "<div id='sysmessage'>".T_("Instructions to confirm your account has been sent").". ".T_("Please, check your email")."</div>"; } else _e("An unexpected error has occurred trying to register your account"); } } else echo "<div id='sysmessage'>".T_("Passwords do not match")."</div>"; } else echo "<div id='sysmessage'>".T_("Wrong email")."</div>"; } else echo "<div id='sysmessage'>".T_("Terms agreement is required")."</div>"; } else echo "<div id='sysmessage'>".T_("Wrong captcha")."</div>";//wrong captcha } if (trim(cG('account'))!="" && trim(cG('token'))!="" && trim(cG('action'))=="confirm"){ $show_form = false; $email = trim(cG('account')); $token = trim(cG('token')); $account = new Account($email); if ($account->exists){ if ($account->Activate($token)){ echo "<div id='sysmessage'>".T_("Your account has been succesfully confirmed")."</div>"; $bodyHTML="<p>".T_("NEW account registered")."</p><br/>".T_("Email").": ".$account->email." - ".$account->signupTimeStamp(); sendEmail(NOTIFY_EMAIL,T_("NEW account")." - ".SITE_NAME,$bodyHTML);//email to the NOTIFY_EMAIL $account->logOn($account->password()); echo '<p><a href="'.accountURL().'">'.T_("Welcome").' '.$account->name.'</a></p><br/>'; } else echo "<div id='sysmessage'>".T_("An unexpected error has occurred trying to confirm your account")."</div>"; } else echo "<div id='sysmessage'>".T_("Account not found")."</div>"; } if ($show_form){ ?> <div> <form id="registerForm" action="" onsubmit="return checkForm(this);" method="post"> <p><label for="name"><?php _e("Name")?>:<br /> <input type="text" id="name" name="name" value="<?php echo $name;?>" maxlength="250" onblur="validateText(this);" lang="false" /></label></p> <p><label for="email"><?php _e("Email")?>:<br /> <input type="text" id="email" name="email" value="<?php echo $email;?>" maxlength="145" onblur="validateEmail(this);" lang="false" /></label></p> <p><label for="password"><?php _e("Password")?>:<br /> <input type="password" id="password" name="password" value="" onblur="validateText(this);" lang="false" /></label></p> <p><label for="password_confirmation"><?php _e("Confirm password")?>:<br /> <input type="password" id="password_confirmation" value="" name="password_confirmation" onblur="validateText(this);" lang="false" /></label></p> <p><label for="mailinglist"><input type="checkbox" id="mailinglist" name="mailinglist" value="<?php echo $mailinglist;?>" style="width: 10px;" /></label>Join Mailing List</p> <p><label for="agree_terms"><input type="checkbox" id="agree_terms" name="agree_terms" value="yes" style="width: 10px;" /> <?php _e("Accept")?> <a href="<?php echo termsURL();?>"><?php _e("Terms")?></a> - <?php echo SITE_NAME?></label></p> <br /> <?php if (CAPTCHA){ mathCaptcha('register');?> <p><input id="math" name="math" type="text" size="2" maxlength="2" onblur="validateNumber(this);" onkeypress="return isNumberKey(event);" lang="false" /></p> <br /><?php }?> <?php createCSRF('register_user');?> <p><input name="submit" id="submit" type="submit" value="<?php _e("Submit")?>" /></p> </form> </div> <?php } }//if else require_once('../../includes/footer.php'); ?>"
  10. Yes, I realize I could do it that way with radio boxes. But I really want 1 checkbox, not 2 radio boxes. Is that or is that not possible ???
  11. I am having trouble with checkboxes and the information they post to my database. I have a site registration form and one of the fields is a checkbox to accept or decline joining our mailing list. "<input type="checkbox" id="mailinglist" name="mailinglist" value="yes" style="width: 10px;" checked />" or "<input type="checkbox" id="mailinglist" name="mailinglist" value="no" style="width: 10px;" />" I want the box to be checked in the form to begin with. Then if they wish to decline joining the mailing list, they simply uncheck it. My problem is: If the box IS checked, I want to post a value of "yes" into the mailinglist field of the database. But, if it IS NOT checked, I want to post a value of "no" into this field. I can not figure out the code to use to accomplish this. It keeps posting "yes" into the database regardless of if it is checked or not ! Please Help !! Thanks !!
×
×
  • 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.