[PHP] Searching with Date Ranges
If I want to show events (records in a MySQL table) for the next 10 days (and I do), what would be the best approach to searching with this range? (The dates in my table are stored as a string in the format /MM/DD.) Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Read the book! Be patient! All success comes from acquiring knowledge and experience." -- Seth Willits --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Date Confusion
On Sunday, September 7, 2003, at 02:50 PM, Seth Willits wrote: A few things I'm trying to do: 1) Turn "MM/DD/YY" into an array like that returned from getdate(). I don't want to explode it or split it, I want to get an array just as if I used getdate() when the current day was MM/DD/YY. It just dawned on me that the timestamp parameter for getdate() is exactly what does this. So forget this one :) 2) Have a date string representing the first of the month and manipulate it to be the last day of the previous month. This, I'm still wondering about. This is the code I have: $month = $date['mon']; $year = $date['year']; if ($month == 1) { $lastofprevmonth = date('t', strtotime('12' . '/01/' . ($year-1) )); $lastofprevmonth = date('m/d/y', strtotime('12' . '/' . $lastofprevmonth . '/' . ($year-1))); } else { $lastofprevmonth = date('t', strtotime(($month-1) . '/01/' . $year)); $lastofprevmonth = date('m/d/y', strtotime(($month-1) . '/' . $lastofprevmonth . '/' . $year)); } This is a far cry from the simple trick in other languages where you just subtract one from the first of the current month and your date then reflects the last day of the previous month. Can that be done in PHP? Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "When purchasing that gift for your Special Someone guys remember, girls like cute things. If it makes you want to puke, your chick will totally love it." -- Someone else out There --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Date Confusion
I'm having difficulty with understanding how to manipulate dates. It seems that there's no date object manipulate so we just pass around a bunch of values which is kinda of annoying. A few things I'm trying to do: 1) Turn "MM/DD/YY" into an array like that returned from getdate(). I don't want to explode it or split it, I want to get an array just as if I used getdate() when the current day was MM/DD/YY. 2) Have a date string representing the first of the month and manipulate it to be the last day of the previous month. If I can figure out how I'm supposed to do those, then the rest I will understand. Thanks, Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Knowledge is limited. Imagination encircles the world." -- Albert Einstein --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PDF Fonts
What do I need to do to get fonts working for PDF creation? Running the script below, I get 2 errors. The first says "PDFlib error [2100] PDF_begin_page: Function must not be called in 'object' scope" on line 2. If I remove "test.pdf" and change it to "", then it reports "PDFlib error [2516] PDF_findfont: Metrics data for font 'Times New Roman' not found" on line 2 also. finished"; ?> Thanks, Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "No electrons were hurt in the transfer of this e-mail." -- Anon --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Block HTML Control
On Tuesday, September 2, 2003, at 02:06 AM, Viraj Kalinga Abayarathna wrote: Seth, Aaa ok. I was confused with the semi colon and colon used in the last example. This clears it all up. Thanks. Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Dreams are what reality is made of." -- Seth Willits --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Block HTML Control
On Tuesday, September 2, 2003, at 12:06 AM, Seth Willits wrote: Lots of Awesome. Thanks for the quick reply. Hmm.. Actually, how does this work with php & html? This is actually what I'm trying to do. I should have said this in the first place, sorry :) } } ?> Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Read the book! Be patient! All success comes from acquiring knowledge and experience." -- Seth Willits --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Block HTML Control
On Tuesday, September 2, 2003, at 12:03 AM, Jason Wong wrote: Lots of Awesome. Thanks for the quick reply. Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "There are 10 types of people in this world - those that understand binary and those that don't." --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Block HTML Control
I'd like to show a big chunk of HTML if a particular variable is true, and if its false I'd like to show a different big chunk of html. Right now the only way I know of doing this is: if ($var) { print ' '; } else { print ' '; } This works, but it destroys the syntax coloring of the html making it all one solid color. I'd love to know if there's a better way OTHER than include()ing different files. Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Knowledge is limited. Imagination encircles the world." -- Albert Einstein --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't Make Directories Now
print $buildingPath . ''; if (opendir($buildingPath) == false) if (!mkdir($buildingPath)) print 'false '; A print("false $buildingPath") might yield as to why it isn't creating it. I already did that and like I said, it's always the correct path. Look at the very first line of the code above which was in the original path. Thanks for the tip on is_dir. Actually -- using is_dir made it work. I wonder why Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Read the book! Be patient! All success comes from acquiring knowledge and experience." -- Seth Willits --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't Make Directories Now
On Monday, September 1, 2003, at 03:41 PM, Curt Zirzow wrote: print $buildingPath . ''; if (opendir($buildingPath) == false) if (!mkdir($buildingPath)) print 'false '; A print("false $buildingPath") might yield as to why it isn't creating it. I already did that and like I said, it's always the correct path. Look at the very first line of the code above which was in the original path. Thanks for the tip on is_dir. Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Rather fail with honor than succeed by fraud." -- Sophocles --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Can't Make Directories Now
I figured out the permissions issue to allow gd to create image files, but I also need to create folders for those images. I've come up with a routine (below) but it fails to create the directories. I've made sure that the directory that the first directory is created in has the appropriate permissions, but it doesn't work. foreach ($pathComponents as $value) { $buildingPath = $buildingPath . "/" . $value; print $buildingPath . ''; if (opendir($buildingPath) == false) if (!mkdir($buildingPath)) print 'false '; else closedir($buildingPath); } ?> The paths to the folders its supposed to create are correct ($buildingPath), but it always prints false signaling that mkdir has failed. This is the last remaining issue on getting my site finished. Well except for uploading, but I don't need that just yet. Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "It's all about the belly fire." -- David Sepe --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Can't Connect Within Function?!
On Monday, September 1, 2003, at 11:33 AM, Mike Morton wrote: You need to read up on the scope of variables within functions. Ohh, I didn't even think of that. Thanks. Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "It's okay. We can't all have three digit IQ levels." -- Seth Willits --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Display one element at a time
On Monday, September 1, 2003, at 10:32 AM, Mike Capps wrote: Nothing seems to work. I have try every thing. At least all of the obvious like pos(array) or $element = current($array) . What I am trying to do : Is to ask questions (the problem I am having, display only one at a time) get answer by using a check box move and display next question (part of the problem) At this point my alternative is to go ahead and print all the questions with check boxs. Not what I wont to do. You'd have one page and which would keep posting to itself. First create a record in the database for the answers. Pass the question number you're currently on (i.e. 1, 2, 3...) AND the record ID for the "answers" record (using hidden input fields). Each time the page loads you'd retrieve the question for that question number from the database, and store the previous question's value in the "answers" record. Your question answer checkboxes and the hidden fields should be within a POST form (or a get form, doesn't really matter) where the action is the same page. In this page you'll have to test for when the current question number is greater than the last answer of the last question and when it is, you'd include() or require() the "Thank you for answering" text OR, test when it is EQUAL (ie showing the last page) and change the form action to a different page if you want. Note that if you were to do the latter, the "different" page would also have to add the answer to the record. Hope this helps, Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "In the eyes of others, spending a lifetime chasing a dream is often seen as a lavish waste of a one-time gift, but maybe the joy isn't solely in its catching, but also in its pursuit." -- Seth Willits --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Can't Connect Within Function?!
If I try to connect to a database within a function, I get the following error. Why is this? MySQL Connect Error : Can't connect to local MySQL server through socket '/Private/tmp/mysql.sock' (2) function getUserPermissions() { if ($_SESSION['permissions'] == '') { // Connecting, selecting database $link = mysql_connect($shs_MySQLServer, $shs_MySQLUser, $shs_MySQLPassword) or die("MySQL Connect Error : " . mysql_error()); etc } } Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "When purchasing that gift for your Special Someone guys remember, girls like cute things. If it makes you want to puke, your chick will totally love it." -- Someone else out There --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Simple File Error
On Sunday, August 31, 2003, at 05:01 PM, Catalin Trifu wrote: Hi, The user root is the which starts the main apache process, the others are the actual servers spawn by the first one. So the user under which apache runs is www. This means that you need to grand write access to those directory to the user www, and or the group (www i suppose) With some help from a friend, I chmod'ed my site folder and it all works well now. Thanks, Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Information is free. Intelligence is a gift." -- Seth Willits --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Simple File Error
On Sunday, August 31, 2003, at 04:38 PM, Catalin Trifu wrote: Does the user under wich the Apache server runs (implicitly PHP) has write access to those directories ? Hmm... I don't know. Not exactly sure how Apache runs under OS X. I see a handful of httpd processes which are under the user 'www' and one other that is under 'root'. Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Rather fail with honor than succeed by fraud." -- Sophocles --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Simple File Error
Warning: imagejpeg(): Unable to open 'thumbnails/marching/years/2000/Miscellaneous/24left.jpg' for writing in /Library/WebServer/Documents/pictures/list.php on line 28 I'm looping through a directory and creating thumbnail images and in doing so, I get the error above for each image. The code I'm using to resize and create the image is below (it's an example from php.net) and the parameters are as follows: $forcedwidth = 100 $forcedheight = 100 $sourcefile = 'marching/years/2000/Miscellaneous/24left.jpg' $destfile = 'thumbnails/marching/years/2000/Miscellaneous/24left.jpg' $imgcomp = 50 Both directories exist as does the source file. Which makes me wonder, will the library create a directory if it doesn't exist? function resampimagejpg($forcedwidth, $forcedheight, $sourcefile, $destfile, $imgcomp) { $g_imgcomp=100-$imgcomp; $g_srcfile=$sourcefile; $g_dstfile=$destfile; $g_fw=$forcedwidth; $g_fh=$forcedheight; $g_is=getimagesize($g_srcfile); if (file_exists($g_srcfile)) { /// Set Image Size /// if(($g_is[0]-$g_fw)>=($g_is[1]-$g_fh)) { /// Width is Greater Than Or Equal to Height $g_iw=$g_fw; $g_ih=($g_fw/$g_is[0])*$g_is[1]; } else { /// Height is Greater than Width $g_ih=$g_fh; $g_iw=($g_ih/$g_is[1])*$g_is[0]; } // Create Thumbnail /// $img_src=imagecreatefromjpeg($g_srcfile); $img_dst=imagecreate($g_iw, $g_ih); imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih, $g_is[0], $g_is[1]); imagejpeg($img_dst, $g_dstfile, $g_imgcomp); imagedestroy($img_dst); } else return false; } Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Few are those who see with their own eyes and feel with their own hearts." -- Albert Einstein --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Error Log
This may be obvious, but I even looked in a few books and didn't see it, but where are PHP errors logged? No errors ever appear on the page yet the online documentation refers to error messages and such, so I'm assuming there must be some log somewhere. Thanks, Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Few are those who see with their own eyes and feel with their own hearts." -- Albert Einstein --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Error Log
On Sunday, August 31, 2003, at 09:38 AM, Catalin Trifu wrote: Look at the php.ini file. There you can define how and where to store the errors, also the level of errors youn want to show This may come as a really big shock, but, I have no php.ini file. I just searched my entire hard drive and it's not there. I'm running on OS X and am using the built-in Apache web server. Crazy... Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Often, by taking a chance, you either lose it or gain from it. If you have nothing to lose, why hesitate? Not pursuing the things you want in life only lets the opportunity to obtain them pass you by." -- Seth Willits --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session Timeout
From what I see, the default timeout for a session is 1440 seconds or 24 minutes. I was gone for nearly an hour, came back, and the session was still valid. Must the value set in the config file be different than 1440, or am I misunderstanding session.gc_maxlifetime? I'd like for the user to be required to log in if they've been inactive for 10 minutes, or if they closed the browser window and opened another one. Sorry for all the basic questions :) Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Not everything that can be counted counts, and not everything that counts can be counted." -- Albert Einstein --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Session Issue
On Friday, August 29, 2003, at 07:44 PM, Curt Zirzow wrote: Does the next page call session_start()? all pages that use $_SESSION, must call that first. Ohhh... ok. Thanks :) Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "One day you'll be wandering through the darkness looking for guidance, inspiration, and your purpose in life, and the next you'll turn around and realize they've been standing right next to you the whole time." -- Seth Willits --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session Issue
I'm logging in via a form, and on the form page it creates the session: session_start(); if ($_POST['username'] == $username && $_POST['password'] == $password ) { $_SESSION['loggedIn'] = true; } else $_SESSION['loggedIn'] = false; ?> And later in the same page, I include another file which has the links to the pages within the secured section of the site: From there, when I go to another page, that same line of doesn't work, as the links are not shown. Any idea on why that's happening? Did I miss a step? Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Black holes are where God divided by zero." -- Steven Wright --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Approaches to Logging In
I'm currently working on a portion of a website for my high school's band (though I'm now in college) and one of the sections contains contact information for all of the students which should only be accessible if you have are a member of band staff and have a password. In order to access the "band staff" section, you are required to enter in a username and password and from there you can visit any of the pages in the band staff section. So it's fairly straight forward, login view the pages, type of system. My question is, how should I go about determining whether the user has logged in or not? Are sessions overkill or difficult to use? Or is there another easier solution? This doesn't have to be maximum security or handle a variety of approaches to the pages, I'm just looking for a simple, "unless you're logged in, you can't see this page." Are sessions the way to go? Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "One day you'll be wandering through the darkness looking for guidance, inspiration, and your purpose in life, and the next you'll turn around and realize they've been standing right next to you the whole time." -- Seth Willits --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Form Parameters
D'oh! Okay, thanks for pointing me to those variables. Is there a list of global variables somewhere? I'm only using the online documentation and it's arranged a little awkward. After playing with $_POST, I couldn't figure out why it wasn't working, but I just realized that the names are case sensitive, so $_POST['username'] and $_POST['Username'] are completely different. Thanks, Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Dreams are what reality is made of." -- Seth Willits --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Form Parameters
This might be staring straight at me, but I can't seem to figure out how to reference form parameters in php code. For example: Thanks, Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "There are 10 types of people in this world - those that understand binary and those that don't." --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Absolute URLs with Require & Include
Is there anyway to get an absolute URL to work with Require & Include? Why doesn't it work already? I did see the tip about using $_SERVER, but this slows down page-loading considerably. Seth Willits --- President and Head Developer of Freak Software - http://www.freaksw.com Q&A Columnist for REALbasic Developer Magazine - http://www.rbdeveloper.com Webmaster for REALbasic Game Central - http://www.freaksw.com/rbgames "Standing up for what you believe in is never a waste of time." -- Seth Willits --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php