
sivarts
Members-
Posts
22 -
Joined
-
Last visited
Never
Everything posted by sivarts
-
How to automatically delete records by date every night??
sivarts replied to sivarts's topic in PHP Coding Help
You're right. That really confuses me. Here what I did - when I added the mysql_select_db to the connection script it gave all sorts of errors (on other oages using that connection script) so I just added it to the CRON script and presto! It works!! I think I have been relying on DreamWeaver to do too for me. Thanks Gentlemen for your assistence! -
How to automatically delete records by date every night??
sivarts replied to sivarts's topic in PHP Coding Help
Here's the connection info: <?php # FileName="Connection_php_mysql.htm" # Type="MYSQL" # HTTP="true" $hostname_myconnection = "localhost"; $database_myconnection = "xxxxxxxx_xxxxx"; $username_myconnection = "xxxxxxxx_xxxxx"; $password_myconnection = "xxxxxxxx"; $myconnection = mysql_pconnect($hostname_myconnection , $username_myconnection , $password_myconnection ) or trigger_error(mysql_error(),E_USER_ERROR); ?> I am not having any other issues with pages that use this script, so I am totally lost. Also,The mixed case example I had above was something I had done just for the example. I am not using mixed case except for the connections directory folder (which again, no probs with the other 40 scripts that use it). All path names look correct and do exist. Thanks for the help!! -
How to automatically delete records by date every night??
sivarts replied to sivarts's topic in PHP Coding Help
You are so right, AndyB now I get: Error: No database selected with query DELETE FROM events_music WHERE event_date < '2006-08-29' doesn't this usually mean I have a prob in the connection string? I can't seem to figure that out if it is the case since all my other Admin pages use the same connection. Any other Ideas what that could mean? -
How to automatically delete records by date every night??
sivarts replied to sivarts's topic in PHP Coding Help
You'll have to forgive me. I am fairly new to the whole new to the whole world of PHP (starting to love it though) Here's my script: [code]<?php // set varibles for todays date $today = date('Y-m-d'); // include connection info include('Connections/myConnections.php'); //select records to delete mysql_query("DELETE FROM events_music WHERE event_date < '$today' "); // close connection to db mysql_close(); ?>[/code] Real simple. Just pulling some records from the DB based on a MySQL formatted date. I am running PHP/MySQL 5 on my local machine and the servier is running PHP4.4 and MySQL 4.1.20-standard-log with Apache version 1.3.37 (Unix) where I am running Apache 2.0.x under windows. As far as I can tell, this code is compliant. Could you point me to some info where I could add some error reporting (sorry I am pretty new at this)? -
How to automatically delete records by date every night??
sivarts replied to sivarts's topic in PHP Coding Help
I've done what micha1701 suggested and it works great on my local machine however, I cannot get it to run on the server usuing CRON or even my running the script from my browser. Does anyone have an idea why this might be?? I have called my host and they say everything looks 'good' so basically they are no help to me. Hopefully someone here can help. -
Would be nice to actually be able to see some of your code. Also, DOCTYPE can affect how CSS will render in your browser.
-
Ricklord is right, IE renders padding all wrong. Try an jsut using margins when you can. check out www.posistioniseverything.com (maybe .org) for a list of even more IE specific bugs.
-
Can anyone please help??
-
Hi Folks. Wondering if any one can help me out here. I've done a tutorial posted on the Adobe Developer center to build a simple calendar that will 'link' the days that have events to those events. Catch my drift (kinda tired...)? I have gone over the code so many times and even copy/pasted the code from the examples provided from MacroDobia. Basically, I have a recordset that gets all the dates (in MySQL format) for the events (named getEvtDates) and dumps them into an array (see below $dates). I know that the recordset is working and the array is being created (simply with print_r($dates); ) but I still don't have any links in my calendar. Anyone have some time to help me out? It's pretty frustrating... P.S. I am using Dreamweaver to generate most of my code (which I am really good about reading and modifying). Here's the code with some comments... [code]<?php function build_calendar($month,$year,$day) { /* Declaring the variables */ $daysOfWeek = array('Su','Mo','Tu','We','Th','Fr','Sa'); $firstDayOfMonth = mktime(0,0,0,$month,1,$year); $noDays = date('t',$firstDayOfMonth); $dateComponents = getdate($firstDayOfMonth); $dayOfWeek = $dateComponents['wday']; $monthName = date('F',mktime(0,0,0,$month,1,$year)); global $getEvtDates; //this is the name of the recordset global $_GET; if (mysql_num_rows($getEvtDates) > 0) { mysql_data_seek($getEvtDates,0); while ($row_getEvtDates = mysql_fetch_assoc($getEvtDates)) { $dates[] = $row_getEvtDates['event_date']; } } /* Computing the previous month. */ if($month == 1) { $mn=12; $yn=$year-1; } else { $mn=$month-1; $yn=$year; } /* Computing the next month. */ if($month == 12) { $mn2=1; $yn2=$year+1; } else { $mn2=$month+1; $yn2=$year; } /* Calendar header: next and previous month links */ $calendar = "<table>"; $calendar .= "<tr><td><p><a href=get_days_events.php?y=$yn&m=$mn&d=$day><</a></p></td>"; $calendar .="<td colspan=5 align=center><p><strong>$monthName, $year</strong></p></td>"; $calendar .="<td><p><a href=get_days_events.php?y=$yn2&m=$mn2&d=$day>></a></p></td></tr>"; $calendar .="<tr>"; /* Calendar header: Display the days of the week */ foreach($daysOfWeek as $day) { $calendar .= "<td><p>$day</p></td>"; } $calendar .= "</tr>"; $calendar .= "<tr>"; $currentDay = 1; /* Fill in the beginning of the calendar body */ if ($dayOfWeek > 0) { $calendar .= "<td colspan='$dayOfWeek'> </td>"; } /* Generate the calendar body */ while ($currentDay <= $noDays) { if ($dayOfWeek == 7) { $dayOfWeek = 0; $calendar .= "</tr><tr>"; } $date = $year."-".$month."-".$currentDay; //here's where the trouble might start if (in_array($date,$dates)) { $calendar .= "<td><p><a href='get_days_events.php?y=$year&m=$month&d=$currentDay'>$currentDay</a></p></td>"; } else { $calendar .= "<td><p>$currentDay</p></td>"; } $currentDay++; $dayOfWeek++; } /* Filling in the end of the calendar body */ if ($dayOfWeek != 7) { $remainingDays = 7 - $dayOfWeek; $calendar .= "<td colspan='$remainingDays'> </td>"; } $calendar .= "</table>"; return $calendar; } if (isset($_GET['m']) && isset($_GET['y']) && isset($_GET['d'])){ $month = $_GET['m']; $year = $_GET['y']; $day = $_GET['d']; } else { $dateComponents = getdate(); $month = $dateComponents['mon']; $year = $dateComponents['year']; $day = $dateComponents['mday']; } echo build_calendar($month,$year,$day); ?>[/code] I know it will be difficult to test this out since you do not have records to play with. But hopefully some one can notice what I am missing. CHEERS (and goodnight!)
-
Thanks gentlemen for providing me with some code. Both scripts work and I was easily able to edit them to suit my purpose exactly. Cheers
-
Thanks tomfmason and Barand!! I'll let you know how these work out... Can't tell you how many times the nice people on this forum (like you two) have saved my ass!! All the best to you!
-
Hi fellow freaks- I have a drop down menu with the following choices- Today, This Week, Next week, This Month. What I want to do is get records from the DB where the results would be from one of the date ranges above. Does anyone know a good way to do this? I tried writing an if/else clause that would perform a query to the DB based on the POST value of the form (where today=1,This Week=2,...) but that won't work since I cannot figuer out how to get the date 7(14,30)days from now. How does one add a number of days to todays date? I searched for about 4 hours on line but could not find anything that a newbie like me could understand to use. I need to some how get a variable $endDate to specify the date range in my SQL query. (which I assume I can write liek this: Select * From myTable WHERE event_date < $endDate --{there are no past dates in the DB at any time}). All my dates are stored in YYYY-MM-DD format (which I cannot change - although I wish I could have used timestamps!). Also, could any one clue me in on how to write something like this: if($_POST['getDays'] = 1) { // go to this page (how do I write this logic to forward to a new page??) } else { if($_POST['getDays'] = 2) { // go to this page } etc... There are so many functions in PHP and I am getting frustrated looking through all the documentaion on line. Does any of this make sense?? I am very lost as what to do-Any help would be much appreciated.
-
Hello fellow freaks- I have built the calendar using the following tutorial on the Dreamweaver developer site: Building a Blog with DW, PHP and MySQL Part three:Creating a search feature and archiving your blog. I built the claendar and it works fine, but the dates that have records (taken from a recordset and dumped into an array) do not become links as they should. I have been racking my brains over this for too long now and I just can't figure it out. Plus two of my variable are not set which gives me two errors. Heres the code for the function: <?php function build_calendar($month,$year,$day) { /* Declaring the variables */ $daysOfWeek = array('Su','Mo','Tu','We','Th','Fr','Sa'); $firstDayOfMonth = mktime(0,0,0,$month,1,$year); $noDays = date('t',$firstDayOfMonth); $dateComponents = getdate($firstDayOfMonth); $dayOfWeek = $dateComponents['wday']; $monthName = date('F',mktime(0,0,0,$month,1,$year)); global $rsArticleDates; global $_GET; if (mysql_num_rows($rsArticleDates) > 0){ mysql_data_seek($rsArticleDates,0); while($row_rsArticleDates = mysql_fetch_assoc($rsArticleDates)){ [b]$dates[][/b] = $row_rsArticleDates['ArticleDate']; } } /* Computing the previous month. */ if($month == 1) { $mn=12; $yn=$year-1; } else { $mn=$month-1; $yn=$year; } /* Computing the next month. */ if($month == 12) { $mn2=1; $yn2=$year+1; } else { $mn2=$month+1; $yn2=$year; } /* Calendar header: next and previous month links */ $calendar = "<table>"; $calendar .= "<tr><td><a href=day.php?m=$mn&y=$yn&d=$day><</a></td>"; $calendar .="<td colspan=5 align=center>$monthName, $year</td>"; $calendar .="<td><a href=day.php?m=$mn2&y=$yn2&d=$day>></a></td></tr>"; $calendar .="<tr>"; /* Calendar header: Display the days of the week */ foreach($daysOfWeek as $day) { $calendar .= "<td>$day</td>"; } $calendar .= "</tr>"; $calendar .= "<tr>"; $currentDay = 1; /* Fill in the beginning of the calendar body */ if ($dayOfWeek > 0) { $calendar .= "<td colspan='$dayOfWeek'> </td>"; } /* Generate the calendar body */ while ($currentDay <= $noDays) { if ($dayOfWeek == 7) { $dayOfWeek = 0; $calendar .= "</tr><tr>"; } [b]$date = [/b]$year."-".$month."-".$currentDay; if (in_array($date,$dates)) { $calendar .= "<td><a href='day.php?m=$month&y=$year&d=$currentDay'>$currentDay</a></td>"; } else { $calendar .= "<td>$currentDay</td>"; } $currentDay++; $dayOfWeek++; } /* Filling in the end of the calendar body */ if ($dayOfWeek != 7) { $remainingDays = 7 - $dayOfWeek; $calendar .= "<td colspan='$remainingDays'> </td>"; } $calendar .= "</table>"; return $calendar; } if (isset($_GET['m']) && isset($_GET['y']) && isset($_GET['d'])){ $month = $_GET['m']; $year = $_GET['y']; $day = $_GET['d']; } else { $dateComponents = getdate(); $month = $dateComponents['mon']; $year = $dateComponents['year']; $day = $dateComponents['mday']; } echo build_calendar($month,$year,$day); ?> The two variables on BOLD are the errors (undefined variable). Has anyone done this tut or know what is wrong with the code? I know my recordset is giving valid results (I have tested it). Any help would be much appreciated!!!
-
Thanks, Barand. I SHOULD have realized that is what was happening. People in this forum rock.
-
I've used KTML from InterAkt online. The 4.0 version is free to download (after a account activation :-( ) http://www.interaktonline.com/Downloads/Free-Products/ it has worked well for smaller gigs thus far. Cheers!
-
Hi All- I've been racking my brains over this so I though I would show it to the experts. I am building a simple calendar but when I try and preview in my browser I get the following message: Fatal error: Maximum execution time of 60 seconds exceeded in C:\htdocs\MYSITE\MYFILE.php on line 147 here's what is around line 147 (line 147 is just a } ) /* Generate the calendar body */ while ($currentDay <= $noDays) { if ($dayOfWeek == 7) { $dayOfWeek = 0; $calendar .= "</tr><tr>"; } $calendar .= "<td>$currentDay</td>"; [b] } // this is line 147[/b] $currentDay++; $dayOfWeek++; /* Filling in the end of the calendar body */ if ($dayOfWeek != 7) { $remainingDays = 7 - $dayOfWeek; $calendar .= "<td colspan='$remainingDays'> </td>"; } Can anyone tell my why I might be having this problem?? Here's the complete function: <?php function build_calendar($month,$year,$day) { /* Declaring the variables */ $daysOfWeek = array('Su','Mo','Tu','We','Th','Fr','Sa'); $firstDayOfMonth = mktime(0,0,0,$month,1,$year); $noDays = date('t',$firstDayOfMonth); $dateComponents = getdate($firstDayOfMonth); $dayOfWeek = $dateComponents['wday']; $monthName = date('F',mktime(0,0,0,$month,1,$year)); /* Computing the previous month. */ if($month == 1) { $mn=12; $yn=$year-1; } else { $mn=$month-1; $yn=$year; } /* Computing the next month. */ if($month == 12) { $mn2=1; $yn2=$year+1; } else { $mn2=$month+1; $yn2=$year; } /* Calendar header: next and previous month links */ $calendar = "<table>"; $calendar .= "<tr><td><a href=day.php?m=$mn&y=$yn&d=$day><</a></td>"; $calendar .="<td colspan=5 align=center>$monthName, $year</td>"; $calendar .="<td><a href=day.php?m=$mn2&y=$yn2&d=$day>></a></td></tr>"; $calendar .="<tr>"; /* Calendar header: Display the days of the week */ foreach($daysOfWeek as $day) { $calendar .= "<td>$day</td>"; } $calendar .= "</tr>"; $calendar .= "<tr>"; $currentDay = 1; /* Fill in the beginning of the calendar body */ if ($dayOfWeek > 0) { $calendar .= "<td colspan='$dayOfWeek'> </td>"; } /* Generate the calendar body */ while ($currentDay <= $noDays) { if ($dayOfWeek == 7) { $dayOfWeek = 0; $calendar .= "</tr><tr>"; } $calendar .= "<td>$currentDay</td>"; } $currentDay++; $dayOfWeek++; /* Filling in the end of the calendar body */ if ($dayOfWeek != 7) { $remainingDays = 7 - $dayOfWeek; $calendar .= "<td colspan='$remainingDays'> </td>"; } $calendar .= "</table>"; return $calendar; } if (isset($_GET['m']) && isset($_GET['y']) && isset($_GET['d'])){ $month = $_GET['m']; $year = $_GET['y']; $day = $_GET['d']; } else { $dateComponents = getdate(); $month = $dateComponents['mon']; $year = $dateComponents['year']; $day = $dateComponents['mday']; } echo build_calendar($month,$year,$day); ?> Any help would be GREATLY APPRECIATED. I'm a newbie so maybe there is something I am not aware of yet. Thanks!
-
Finding records by date using a drop down menu
sivarts replied to sivarts's topic in PHP Coding Help
Caesar - thanks for the advice. In the future I definately will use timestamps. I should have thought of that a month ago...but at this point the clients are already using the db the way it is. Plus, I have a very limited timefrmae to get the project finished (one week!!). I wouldn't have time to change all the dates in the db and rework my php scripts to work with those changes...I'll keep working on it and see what I come up with. -
Finding records by date using a drop down menu
sivarts replied to sivarts's topic in PHP Coding Help
I am storing them in SQL format (yyyy-mm-dd). I would also like to know if there is a good way to have people enter dates in a more human readable format and have them converted to SQL format. Right now, when enetering dates people have to enter them in the SQL format which is a bit of an usability issue. -
HI- I am trying to let users search for events by date. I have a drop down menu with the following: Today This Week Next Week This Month What I want to do is set up If/else statements that would take one of the above (passed as $_GET['searchDate']) and and perform a SQL query based on the variable (Today, This Week, etc.). I need to know how to structure the if/else statement and also how to code the PHP so that it knows that This Week is today plus the next 6 days and so forth. I have set up something like : $query = $_GET['searchDate']; if ($query = 'Today') { //get recordset for today } elseif ($query = 'This Week') { //get recordset for This week } and so on...It doesn't seem to work though (I have not actually set up any SQL queries yet, but I have set it to display the value of $query for testing. It only gives me the first if clause (today). I am a PHP newbie, so I know I am missing something obvious but can't seem to find the answer. Can anyone provide me with help? Is this the best way to do this or is there a better way to look up records based on the date? I would also like to provide a calendar on the page that they could click a date and it would show the records listed for that date. I have been looking around the web and I cannot find an example of this, but I know some one has done something like this somewhere. Any help would be appreciated.Thanks
-
Hi- I have a page on which a user can search through records based on a certain criteria. On the page that those results are displayed, there is also the same search option, so that they can perform the search again. However, when I am adding recordset navigation links (I'm using Dreamweaver to apply this behavior to my links) and I try and advance to the next page fo records it doesn't work. Looks like it is also passing the variable for the search form (which has not been submitted except for when arriving to this page) is included in the URL. How can I make sure this 'search variable' is only passed when the form is submitted and not when any other variables are sent?? Help would so GLADLY be appreciated.
-
How to automatically delete records by date every night??
sivarts replied to sivarts's topic in PHP Coding Help
Thanks, micah1701. I appreciate the help. -
Hi, PHP newbie here. I am building an event listing service and would like to have records removed from the database after they have passed. I am assuming I will need to run a CRON job on the server every night, but what sort of PHP script will I need to write? I also think that in the interest of safety, I would like to have the old records moved to another database first and then deleted every month. Can I set up something like this to run automatically?? Any suggestions will be greatly appreciated.