Jump to content

proctk

Members
  • Posts

    300
  • Joined

  • Last visited

    Never

Everything posted by proctk

  1. after some searching I come up with the below which give the error I posted. I'm surprised that I have not been able to find script that uses mysql to get birthdays within x days. error message, any ideas, thank you for the help SQL Error: SELECT DOB, STR_TO_DATE(CONCAT(EXTRACT(DAY FROM DOB),'-',EXTRACT(MONTH FROM DOB),'-',EXTRACT(YEAR FROM CURDATE())),'%y-%m-%d') AS ThisYearsDate FROM users WHERE CURDATE() BETWEEN 'ThisYearsDate' You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 $query_get_member_bdays = ("SELECT DOB, STR_TO_DATE(CONCAT(EXTRACT(DAY FROM DOB),'-',EXTRACT(MONTH FROM DOB),'-',EXTRACT(YEAR FROM CURDATE())),'%y-%m-%d') AS ThisYearsDate FROM users WHERE CURDATE() BETWEEN 'ThisYearsDate'");
  2. the below code gives this error message SQL Error: SELECT * FROM users WHERE DOB BETWEEN NOW() AND NOW() + INTERVAL('10 day') You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 $query_get_member_bdays = ("SELECT * FROM users WHERE DOB BETWEEN NOW() AND NOW() + INTERVAL('10 day')");
  3. what do you mean make sure dob is indexed
  4. Hi I have a column in a mysql table which is formated as 'date' called DOB. I want to create a query that will get all birthdays cumming up in the next ten days. any help is excellent
  5. I figured out the error issue its a path issue. I have another question I want to add to the files name = $user_name.-.file_name
  6. change made but set getting the same error posted initially
  7. what do you mean use $_file ''' I'm a rookie''
  8. Hi I'm trying to use the below code to upload images into a file folder called adImage I'm getting this error message Warning: copy(C:/Program Files/xampp/htdocs/adImages/dvdPlayer.jpg) [function.copy]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\etreasures\portal\addTreasure.php on line 36 upload failed! n line 36 = $res = copy($HTTP_POST_FILES['file']['tmp_name'], $path . $HTTP_POST_FILES['file']['name']); $path = $_SERVER['DOCUMENT_ROOT'] . '/adImages/'; $max_file_size = 300000; if(isset ($_POST['Submit'])){ if (!isset($HTTP_POST_FILES['file'])) exit; if (is_uploaded_file($HTTP_POST_FILES['file']['tmp_name'])) { if ($HTTP_POST_FILES['file']['size']>$max_file_size) { echo "The file is too big<br>n"; exit; } if (($HTTP_POST_FILES['file']['type']=="image/gif") || ($HTTP_POST_FILES['file']['type']=="image/pjpeg") || ($HTTP_POST_FILES['file']['type']=="image/jpeg") || ($HTTP_POST_FILES['file']['type']=="image/png")) { if (file_exists($path . $HTTP_POST_FILES['file']['name'])) { echo "The file already exists<br>n"; exit; } $res = copy($HTTP_POST_FILES['file']['tmp_name'], $path . $HTTP_POST_FILES['file']['name']); if (!$res) { echo "upload failed!<br>n"; exit; } else { echo "upload sucessful<br>n"; } echo "File Name: ".$HTTP_POST_FILES['file']['name']."<br>n"; echo "File Size: ".$HTTP_POST_FILES['file']['size']." bytes<br>n"; echo "File Type: ".$HTTP_POST_FILES['file']['type']."<br>n"; } else { echo "Wrong file type<br>n"; exit; } $image = $HTTP_POST_FILES['file']['name'];
  9. Below is code for page that displays a query based on search results. There is also a feature to sort the data based on a value selected by the user from a select option. The initial query returns the results but when I select a sort value all found values are lost. i echoed the query to see what is happening all appears good as the variable value for $sortBy changes but the query does no keep the results and the screen is returned to blank <?php session_start(); include ("Connections/dblocal.php"); $search = mysql_real_escape_string($_POST['search']); $start = 0; if(isset($_GET['start'])) { $start = intval($_GET['start']); } $end = $start + 5; $sortBy = 'ad_date'; if (isset($_POST['sortBy'])) { $sortBy = $_POST['sortBy']; $search = $_POST['sortSearch']; } $query_sql_get_ads = ("SELECT * FROM ads WHERE title LIKE '%$search%' OR category LIKE '%$search%' OR sub_category LIKE '%$search%' order by $sortBy desc LIMIT $start, $end"); $sql_get_ads = mysql_query($query_sql_get_ads)or die("SQL Error: $query_sql_get_ads<br>" . mysql_error()); echo $query_sql_get_ads; //echo $sortBy.'<br>'; //echo $search; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Quick Search results</title> <link href="design/default.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="outer"> <?php include('design/banner.php'); ?> <div id="twoColumnRight"> <table class="forms" style="margin-top:25px;"> <form name="sortSearch" method="post" action="<?Php echo $PHP_SELF; ?>"> <tr> <td colspan="7"><div align="right">Sort By: <select name="sortBy" onchange="this.form.submit()"> <option value="">--Select--</option> <option value="ad_type">Type</option> <option value="title">Title</option> <option value="price">Price</option> <option value="views">Views</option> <option value="Status">Status</option> <option value="ad_date">End date</option> </select> <input name="sortSearch" type="hidden" value="<?php echo $_SESSION['temp_search'] ?>" /> </div> </form> </td></tr> <tr> <td colspan="7" class="header"> Search Results </td> </tr> <tr> <td style="width:20%;"><div align="center"></div></td> <td style="width:10%;"><div align="center">Type</div></td> <td style="width:20%;"><div align="center">Item Title </div></td> <td style="width:10%;"><div align="center">Price</div></td> <td style="width:20%;"><div align="center">End Date </div></td> <td style="width:10%;"><div align="center">views</div></td> <td style="width:10%;"><div align="center">Status</div></td> </tr> <?php $color1 = "#CCFFCC"; $color2 = "#BFD8BC"; $row_count = 0; if(isset($_POST['searchSubmit'])){ while($r = mysql_fetch_array($sql_get_ads)){ $row_color = ($row_count++ % 2) ? $color1 : $color2; ?> <tr> <td bgcolor="<?php echo $row_color ?>" style="padding:.2em;"><div align="center"><img src="adImages/<?php echo $r['image']; ?>" height="40" width="40"/></div></td> <td bgcolor="<?php echo $row_color ?>"><div align="left"><?php echo $r['ad_type']; ?></div></td> <td bgcolor="<?php echo $row_color ?>"><div align="left"><a href="treasureDetails.php?id=<?php echo $r['ad_id'].'&seller='.$r['member_id']; ?>"><?php echo $r['title']; ?></a></div></td> <td bgcolor="<?php echo $row_color ?>"><div align="center"><?php echo $r['price']; ?></div></td> <td bgcolor="<?php echo $row_color ?>"><div align="center"> <?php $date_array = explode("-",$r['ad_date']); $ad_date = mktime(0, 0, 0, $date_array[1], $date_array[2]+30, $date_array[0]); $end_date = date("Y-m-d", $ad_date); echo $end_date; ?> </div> </td> <td bgcolor="<?php echo $row_color ?>"><div align="center"><?php echo $r['views']; ?></div></td> <td bgcolor="<?php echo $row_color ?>"> <?php if($r['status'] == 'Sold'){ $status_color = '#FF0000; font-weight:bold;'; }else{ $status_color = '#000000;'; } ?> <div align="center" style="color:<?php echo $status_color; ?>"><?php echo $r['status']; ?></div></td> </tr> <?php } $back = $_SERVER['PHP_SELF']."?start=$end"; ?> <tr> <td colspan="7"><div align="right"><?php echo "<input type='button' value='Next' onClick='window.location=\"$back\"'>"; ?> <?php echo '<input type=button value="Prev" onClick="history.go(-1)">'; ?></div></td> </tr> <?php } ?> </table> </div> <div id="twoColumnLeft"> <?php if(isset($_SESSION['user_id'])) {?> <?php include('design/leftlinks.php'); ?> <?php }else{ include('design/externalLinks.php'); } ?> </div> <div id="footer"> <?php include('design/footer.php'); ?> </div> </div> </body> </html>
  10. I don't want the value to change. Its not keeping its keeping its value once I select a the Sort by. I confirmed the by echoing the values $search and $SortBy. The first search both values are displayed buy when i select a value from the sort select on the same page the value of $search is lost but the value of $sortBy changes with the selected value hope this helps
  11. thank you for all the help problem is fixed
  12. below is code that works as a search function. It does the trick but when the user executes the $sortBy block of code the search value is lost. how do the variable $search to kepp its value so that it can be used with the sort feature <?php include ("Connections/dblocal.php"); $search = mysql_real_escape_string($_POST['search']); echo $search; $start = 0; if(isset($_GET['start'])) { $start = intval($_GET['start']); } $end = $start + 5; $sortBy = 'ad_date'; if (isset($_POST['sortBy'])) { $sortBy = $_POST['sortBy']; } echo $sortBy; $query_sql_get_ads = ("SELECT * FROM ads WHERE title LIKE '%$search%' OR category LIKE '%$search%' OR sub_category LIKE '%$search%' order by $sortBy desc LIMIT $start, $end"); $sql_get_ads = mysql_query($query_sql_get_ads)or die("SQL Error: $query_sql_get_ads<br>" . mysql_error()); ?>
  13. the last header statement at the bottom
  14. The part of the code that sends the email is giving a error because its sending a second header. Warning: Header may not contain more than a single header, new line detected. in /mnt/w0400/d11/s01/b02a5c57/www/etreasures.ca/Scripts/CodeChangePassword.php on line 50 I cannot figure out why this is happening. <?php session_start(); include ("../Connections/db.php"); $user_id = $_SESSION['user_id']; $email = $_SESSION['email_address']; $new_password = $_POST['new_password']; $confirm_password = $_POST['confirm_password']; if($new_password != $confirm_password){ $msg .= 'Passwords do not match.<br />'; urlencode($msg); header("Location: ../portal/editprofile.php?msg=$msg"); exit(); } if(($new_password =="")) { $msg .= 'Enter Password.<br />'; urlencode($msg); header("Location: ../portal/editprofile.php?msg=$msg"); exit(); } $db_password = md5($new_password); $sql = mysql_query("UPDATE members SET password='$db_password' WHERE user_id='$user_id'"); $subject = "You changed your password at Etreasures!"; $message = "Save this email as it contains the password that you selected. Not to worry your password has been encrypted to protect your privacy New Password: $new_password http://www.etreasures.ca Thanks! etreasures.ca This is an automated response, please do not reply!"; mail($email, $subject, $message, "From:eTreasures.ca <webmaster@etreasures.ca>"); $msg = "Your Password has been changed. You will receive an email with your new password!"; urlencode($msg); header("Location: ../portal/editprofile.php?msg=$msg"); ?>
  15. Below is code that I'm trying to edit so that when the link is clicked the form is shown and when the link is clicked a second time the form will be hidden any idea how I can do this [code=php:0]   <p style="font-size:10px"><a href="index.php?pw_id=pw">Get new Password</a></p>     <?PHP // displays the lost password form $pw_id = $_REQUEST['pw_id']; if ($pw_id == 'pw'){ ?> <form id="form1" name="form1" method="post" action="codeLostPassword.php">   Email Address:   <input type="text" name="email_address" id="email_address" />   <input name="recover" id="recover" type="hidden" value="recover" />     <input type="submit" name="Submit" value="Submit" id="Submit" />   </form> <?php }else{   }   ?> [/code]
  16. proctk

    select error

    Well,  I did some more testing on my local server which is setup using xampp 1.5.5 and runs mysql 5.0.27. i still get the same message. so in light of this I will post all the code on this page [code=php:0] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/internalsite.dwt" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <!-- InstanceBeginEditable name="doctitle" --> <title>email members</title> <!-- InstanceEndEditable --> <!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> <link href="../css/main.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="outer"> <div id="banner"> <h1><a href="index.php" title="Home Page">FamilyClick.ca</a></h1> </div>   <div id="sub">     <div id="center"><!-- InstanceBeginEditable name="EditRegion3" -->     <form method="post" action="codesendmembersemail.php"> <table class="columntable"> <tr><td class="tableheader">Send Email to all Members</td></tr> <tr><td class="border" style="padding-bottom:10px;"> Title or Subject: <input name="subject" type=text maxlength=100 size=40> </td></tr> <tr><td class="border">Message: <textarea wrap name="message" rows=10 cols=40></textarea> <input type=submit name="submit" value="SUBMIT"> </td> </tr> </table>     </form>     <!-- InstanceEndEditable -->         </div>       <div id="left"><!-- InstanceBeginEditable name="EditRegion4" -->       <?php include('../leftlinks.php'); ?>               <!-- InstanceEndEditable --></div>   </div>   <div id="right"><!-- InstanceBeginEditable name="EditRegion5" -->   <p>     <?php   include ('../config/db.php'); $get_childdob = mysql_query("SELECT FROM children AS c JOIN (SELECT id, CONCAT(IF(DAYOFYEAR(childdob) > DAYOFYEAR(NOW()),   YEAR(NOW()), YEAR(NOW()) + 1), DATE_FORMAT(childdob, '-%m-%d')) AS nextBD   FROM children) AS sub ON c.id = sub.id WHERE sub.nextBD BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 20 DAY")or die (mysql_error()); while($row_get_childdob=mysql_fetch_assoc($get_childdob)){ $fname = $row_get_childdob['childfirstname']; $lname = $row_get_childdob['childlastname']; $owner_id = $row_get_childdob['owner_id']; $childdob = $row_get_childdob['childdob']; echo $name; if(isset($_POST['childdob_submit'])){ $subject = "Birthday Reminder from Family Click"; $message = " $fname lname birth is on $chiddob. be sure to give them a call or send them a message wishing them a Happy Birthday. Visit www.familyclick.ca to get their conact information and check out their gift wish list.         This message was sent to you by Family Click             This is an automated message, please do not reply!"; $x = 1; $hold = 50; // quantity of emails sent before 3 sec delay $query_email_owner = mysql_query("SELECT email_address FROM users WHERE  user_id = '$owner_id'");   $email_count=mysql_num_rows($query_email_owner); while($row_email_owner=mysql_fetch_assoc($query_email_owner)){ $email_address = $row_email_owner['email_address'];     mail($email_address, $subject,   $message, "From:FamilyClick.ca <kevin.proctor@familyclick.ca>");   $x++;     if($x == $hold) { // When $x is equal to $hold, a 3 sec delay will occur avoiding php to timeout     sleep(3);     $x = 0;   } // end of while loop   } } }   ?>   </p>   <form id="form1" name="childrenbday" method="post" action="<?php $PHP_SELF ?>">     <p style="text-align:center; margin-top:10px;"><input style="width:90%; height:30px; text-align:center;" type="submit" name="childdob_submit" value= "Children Birthdays <?php echo $childdob_count; ?>" /></p>     </form>   <p>&nbsp; </p>   <!-- InstanceEndEditable -->     <p>&nbsp;</p>     <p>&nbsp;</p>   </div>   <div id="footer">             <p>Copyright &copy; 2006 familyclick.ca</p>         <ul title="footer menu">             <li><a href="#" title="">Top</a></li>             <li><a href="#" title="">Privacy Policy</a></li>             <li><a href="#" title="">Site Map</a></li>         </ul>   </div> </div> </body> <!-- InstanceEnd --></html> [/code]
  17. proctk

    select error

    version 4.0.27 - I just called my provider and that is what they told me. is this good enough, if not have any recommendations for web posting providers that supports what I'm trying to do
  18. proctk

    select error

    Gave what you posted a try and below is the message I get and the code that I'm working with. Is there anything that I need to change to match column names in my table thank you for the help error message [b]You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM children AS c JOIN ( SELECT id, CONCAT(IF(DAYOFYEAR(c[/b] [code=php:0] $get_childdob = mysql_query("SELECT FROM children AS c JOIN (SELECT id, CONCAT(IF(DAYOFYEAR(childdob) > DAYOFYEAR(NOW()),   YEAR(NOW()), YEAR(NOW()) + 1), DATE_FORMAT(childdob, '-%m-%d')) AS nextBD   FROM children) AS sub ON c.id = sub.id WHERE sub.nextBD BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL 20 DAY")or die (mysql_error()); [/code]
  19. proctk

    select error

    I have been working at this for three days now. I'll posy an update to where I'm at. what I'm trying to do: show all members that are having a birthday in the next 20 days. This web site has been a great help to me. I really want to solve this problem. If someone helps me get it solved I will make a $20.00 donation to php freaks error message [b]You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(CONCAT(EXTRACT(DAY FROM CURDATE()),'-',EXTRACT(MONTH FROM CURD[/b] [code=php:0] $get_childdob = mysql_query("select STR_TO_DATE(CONCAT(EXTRACT(DAY FROM CURDATE()),'-',EXTRACT(MONTH FROM CURDATE()),'-',EXTRACT(YEAR FROM CURDATE()))),'%d-%m-%Y') as ThisYearsDate FROM children WHERE ThisYearsDate < DATE_SUB(CURDATE(),INTERVAL 20 DAYS")or die (mysql_error()); $get_childdob = mysql_query($query)or die(mysql_error()); [/code]
  20. proctk

    select error

    this is what I have this far and still having issues [code=php:0] mysql_query("SELECT STR_TO_DATE(CONCAT(EXTRACT(DAY FROM childdob),'-',EXTRACT(MONTH FROM childdob),'-',EXTRACT(YEAR FROM CURDATE()))),'%d-%m-%y') as ThisYearsDate FROM children WHERE ThisYearsDate < DATE_SUB(CURDATE(),INTERVAL 20 DAYS")or die (mysql_error()); [/code]
  21. proctk

    select error

    ops I missed up the copy and past You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(CONCAT(EXTRACT(DAY FROM childdob),'-',EXTRACT(MONTH FROM child
  22. proctk

    select error

    error message any idea what is causing this You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(CONCAT(EXTRACT(DAY FROM childdob),'-',EXTRACT(MONTH FROM child [code=php:0] $get_childdob = mysql_query("SELECT STR_TO_DATE(CONCAT(EXTRACT(DAY FROM childdob),'-',EXTRACT(MONTH FROM childdob),'-',EXTRACT(YEAR FROM CURDATE()),'%d-%m-%y') as newdate, owner_id FROM children WHERE childdob < DATE_SUB(CURDATE(),INTERVAL 20 DAYS); ")or die (mysql_error()); [/code]
  23. There has to be a way to take a date from a table and change the year section of the date to the current year and then compare that date to the current year and display it if the date is within 20 days and once the date is past not to display it any more. I have seached google many times and I have not had any luck getting an answer to this question. I'm trying to limit it to one mysql query. help please
  24. I think I have deterimed part of t he problem.  the date of birth will always be within the date range as it looking at the year of birth, we need to change the year of birth to the current YEAR. i have been googling for hours and connot figure this out
×
×
  • 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.