[PHP] Code check
Hi all, I wrote a php script that creates options for select boxes. What this script does is selects tomorrows date. However I have tested the code when the day is the last day of the month and the script blows up. Instead of displaying June it displays January and repeats the months 12 times I think. I didn't count I just noiced thart that the months of the year were repeated multiple times. I think my problem is with the mktime function. I don't think it likes $i+1 too well. I also want to be sure that this code takes care of all date contitions like leap year, end of the year and any other condition that would give a wrong date. So here is my code: select name=month ?php foreach(range(1,12) as $i) { if (date('t') == date('j')) { echo option value=$i+1 selected=\true\ . date('F', mktime(12,0,0,$i+1,1)) . /option\n; } if (date('n') == $i) { echo option value=$i selected=\true\ . date('F', mktime(12,0,0,$i,1)) . /option\n; } else { echo option value=$i . date('F', mktime(12,0,0,$i,1)) . /option\n; } } ? /select br / br / select name=day ?php foreach (range (1,31) as $i) { if (date('j')+1 == $i) { echo option value=$i selected=\true\ . date('j', mktime(12,0,0,0,$i,date('Y'))) . /option\n; } else { echo option value=$i . date('j', mktime(12,0,0,0,$i,date('Y'))) . /option\n; } } ? /select br / br / select name=year ?php if (date('n') == 12 date('j') == 31 ) { echo option value= . date('Y')+1 . selected=\true\ . date('Y')+1 . /option\n; } else { echo option value= . date('Y') . selected=\true\ . date('Y') . /option\n; } ? /select Any help will be appreciated Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] selecting current month from a database
Hi all, I know this might be trivial problem but I can't seem to figure it out. Here is my problem I have a drop down menu where I have the months of year as menu items. I want to be able to have the current month be the selected month. I have tried using the date function as the way to set the current month as the selected value but it seems that every value entered in the select box is set to selected. Here is my code maybe someone can help me out $month_query = mysql_query(SELECT m_id, months FROM Month); while ($r = mysql_fetch_array($month_query)) { $v = $r[m_id]; $out = $r[months]; echo(option selected= . date(F) . value=$v$out/option\n); } Just incase you want to know m_id = 1..12 months = January..December How do I set only the current month to selected ? Thanks, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating a Photo Album
I'm not looking for someome to do it for me. I would like to learn how to do this my self. I have written code in Java and C/C++ before. From the function list in the PHP manual some of the functions look like the C/C++ functions. Thanks, Paul On 4/8/06, tedd [EMAIL PROTECTED] wrote: Paul: To continue top-posting, It's pretty simple, just store the images in a folder, place the url's to the images in MySQL, create a web page that can show an image and pulls the first one from the dB with a reference such that when someone clicks the picture, it increments and pulls the next image url from the dB and displays it. Are you into programming or are you looking for someone to do it for you? tedd At 5:05 PM -0700 4/7/06, Paul Goepfert wrote: updating by user click for now. I might change that in the future to update by interval. Paul On 4/7/06, tedd [EMAIL PROTECTED] wrote: At 12:13 AM -0700 4/7/06, Paul Goepfert wrote: Hi all, I am postilng pictures up on a website. So far I have a picture per page. This will get not be very efficient as time goes on. Is there anyway that I can have one page with only the image updating? Can this be done in PHP. If it can would someone explain it to me. The only thing I k.now how to do well in PHP is mysql queries and data validatlion. Thanks, Paul Paul: Updating how? By a time interval, by a user click, or what? tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Creating a Photo Album
Hi all, I am postilng pictures up on a website. So far I have a picture per page. This will get not be very efficient as time goes on. Is there anyway that I can have one page with only the image updating? Can this be done in PHP. If it can would someone explain it to me. The only thing I k.now how to do well in PHP is mysql queries and data validatlion. Thanks, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Book Recommendation
Hi all, Can anyone tell me a good php book to buy. I already have Web Database Applications with PHP MySQL by O'Reilly. Thanks, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating a Photo Album
updating by user click for now. I might change that in the future to update by interval. Paul On 4/7/06, tedd [EMAIL PROTECTED] wrote: At 12:13 AM -0700 4/7/06, Paul Goepfert wrote: Hi all, I am postilng pictures up on a website. So far I have a picture per page. This will get not be very efficient as time goes on. Is there anyway that I can have one page with only the image updating? Can this be done in PHP. If it can would someone explain it to me. The only thing I k.now how to do well in PHP is mysql queries and data validatlion. Thanks, Paul Paul: Updating how? By a time interval, by a user click, or what? tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mysql_fecth_array() and function call as parameter
I included the or die function on the end of my query statement. When I tested this on my web page I got the following error Query2 Failed: You have an error in your SQL syntax near '(curdate())' at line 1 When this code executed: $query2 = mysql_query(SELECT dayNum FROM Days WHERE dayNum = day(curdate())) ; I can't see where the error is. Can anyone see the error? The table name is correct because I have another drop down box that gets all dates in the table and outputs it with no error. I also tested the above SQL statement on a local copy of mysql (version 5.0.18-nt) and it worked with out any errors. And this code works on a different web server. Mysql client version 3.23.49. However it does not work on mysql client version 3.23.54. Also both php versions are the same. Thanks Paul On 4/3/06, Jon Drukman [EMAIL PROTECTED] wrote: Paul Goepfert wrote: function determineDay () { $return = ; $query1 = mysql_query(SELECT months FROM Month WHERE m_id = month(curdate())); $query2 = mysql_query(SELECT dayNum FROM Days WHERE dayNum = day(curdate())); $query3 = mysql_query(SELECT year FROM Year WHERE year = year(curdate())); always Always ALWAYS check the error return!!! $query1 = mysql_query(SELECT months FROM Month WHERE m_id = month(curdate())) or die(query1 failed: . mysql_error()); do this religiously on every single mysql_query. in fact, write a wrapper function to do it for you - that's what i do. If anyone can find my error please let me know. I have looked at this for about an hour and I can't figure it out. you probably could have saved an hour by checking the error code. -jsd- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Not sure if this is a php problem or a mysql problem
Hi all, I have developed a php functilon that is to return the date +1 from a Mysql database. My sql statement is as follows SELECT dayNum FROM Days Where dayNum = day(curdate())+1; The function works great on the intended webserver but when placed on a different mysql server (The one I have using to develop the webpage) the return variable with the intended SQL statement is not being set. I Think it has something to do with thlis day(curdate()) portion of my sql statement. When I had month in place of day I was able to ge a output. I don't have a problem with year(curdate()) or month(curdate()). Even though the functilon works on the final destination webserver I would like to know why it won't work on my testing server. Thanks Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_fecth_array() and function call as parameter
I have done the following to my code hoping that the fix would work $query1 = mysql_query(SELECT months FROM Month WHERE m_id = month(curdate())); //echo $query1 . br /; $query1_data = mysql_fetch_assoc($query1); echo $query1_data . br /; returns Array (The word that is) switch ($query1_data) { I also outputted $query2 = mysql_query(SELECT dayNum FROM Days WHERE dayNum = day(curdate())); echo $query2 . br /; and I got an empty string This is the code that I use when I call the function $month = $this-determineMonth(); //echo $month . br /; $Month_query = mysql_query($month); //echo mysql_error() . br /; while ($x = mysql_fetch_assoc($Month_query)) { $form .=option value={$x[m_id]}{$x[months]}/option\n; } And according to my apache error log I have [Mon Mar 27 11:34:42 2006] [error] [client 192.168.0.2] PHP Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\\Program Files\\Apache Group\\Apache2\\htdocs\\validation.php on line 130 [Mon Mar 27 11:34:42 2006] [error] [client 192.168.0.2] PHP Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\\Program Files\\Apache Group\\Apache2\\htdocs\\validation.php on line 342 By the way I tested the SQL statements in MYSQL and they returned the values I was looking for. What am I missing? At the time of this email I was unable to check the php docs at php.net. Thanks, Paul On 3/26/06, Chris [EMAIL PROTECTED] wrote: Paul Goepfert wrote: I placed the echo statements in my code and I found out that my query was empty. I also went a step further and tested if I was getting the correct outputs from the queries that initially do at the beginning of the method. Instead of getting an output like March I got an output that says Resource id#9. I don't get it. I tested the sql statement in MySQL that I have on my computer. It worked, Why wouldn't it give the same output through mysql_query()? Ahh, didn't notice that. $query1 = mysql_query(SELECT months FROM Month WHERE m_id = month(curdate())); $query2 = mysql_query(SELECT dayNum FROM Days WHERE dayNum = day(curdate())); $query3 = mysql_query(SELECT year FROM Year WHERE year = year(curdate())); These return result resources (kinda like '$fp = fopen' doesn't return the file - it returns a handle only), not the results. You need to do: $query1_data = mysql_fetch_assoc($query1, 0, 0); then switch($query1_data) { } see http://www.php.net/mysql_query and http://www.php.net/mysql_fetch_assoc for more info. On 3/26/06, Chris [EMAIL PROTECTED] wrote: Paul Goepfert wrote: Hi all, I have wriiten a function that determines whether tomorrows date is the first of the month or not then returns a SQL string based on whether its the first of the month or not. According to my apache error logs I get an error that says: [Sun Mar 26 21:43:14 2006] [error] [client 192.168.0.2] PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\\Program Files\\Apache Group\\Apache2\\htdocs\\validation.php on line 331 I understand that this is a warning but I believe that it has something to do with the fact that no output is being displayed. All other mysql database outputs work fine. This is the code that sets the query in the mysql_query parameter $Month_query = mysql_query($this-determineMonth()); Add this after your month_query call: echo mysql_error() . br/; It will tell you what's wrong with the query. I'd probably also print out the query: $qry = $this-determineMonth(); echo $qry . br/; and run it manually (if something does get returned). -- Postgresql php tutorials http://www.designmagick.com/ -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_fecth_array() and function call as parameter
I finally got the function to work. However I have a problem with another function. It is almost exactly like the origional function but in this function I am determining the days instead of the month. I made the same changes to the days function as I did to the month function. However no value is being set to be returned. I can't find my error. My function is below: function determineDay () { $return = ; $query1 = mysql_query(SELECT months FROM Month WHERE m_id = month(curdate())); $query2 = mysql_query(SELECT dayNum FROM Days WHERE dayNum = day(curdate())); $query3 = mysql_query(SELECT year FROM Year WHERE year = year(curdate())); $query1_data = mysql_fetch_assoc($query1); $query2_data = mysql_fetch_assoc($query2); $query3_data = mysql_fetch_assoc($query3); switch ($query1_data[months]) { case January: case March: case May: case July: case August: case October: case December: if ($query2_data[dayNum] == 31) $return .= SELECT dayNum FROM Days; else $return .= SELECT dayNum FROM Days WHERE dayNum = day(curdate()) +1; break; case February: if ($query2_data[dayNum] == 28 || $query2_data[dayNum] == 29) { if ($query2_data[dayNum] == 28) $return .= SELECT dayNum FROM Days WHERE dayNum = 28; else $return .= SELECT dayNum FROM Days WHERE dayNum = 29; } else { if (($query3_data[year] % 4 == 0) ($query3_data[year] % 100 != 0 || $query3_data[year] % 400 == 0)) $return .= SELECT dayNum FROM Days WHERE dayNum = day(curdate()) +1 AND dayNum =28; else $return .= SELECT dayNum FROM Days WHERE dayNum = day(curdate()) +1 AND dayNum =29; } break; case April: case June: case September: case November: if ($query2_data[dayNum] == 30) $return .= SELECT dayNum FROM Days WHERE dayNum = 30; else $return .= SELECT dayNum FROM Days WHERE dayNum = day(curdate())+1 AND dayNum = 30; break; } return $return; } Here is the code for where I output the contents of the query $day = $this-determineDay(); $Day_query = mysql_query($day); while ($a = mysql_fetch_assoc($Day_query)) { $form .= option value={$a[dayNum]}{$a[dayNum]}/option\n; } $form .= /select\n; If anyone can find my error please let me know. I have looked at this for about an hour and I can't figure it out. Thanks, Paul On 3/27/06, Brady Mitchell [EMAIL PROTECTED] wrote: I have done the following to my code hoping that the fix would work $query1 = mysql_query(SELECT months FROM Month WHERE m_id = month(curdate())); //echo $query1 . br /; $query1_data = mysql_fetch_assoc($query1); echo $query1_data . br /; returns Array (The word that is) Use: print_r($query1_data) or var_dump($query1_data) to see everything in the array. If you want to use echo, you'd have to echo each index of the array one at a time with something like: echo $query1_data[0]; http://php.net/echo http://php.net/print_r http://php.net/var_dump switch ($query1_data) { You can't switch on an entire array. Switch is used to check the value of a variable (which could be an index of the array, but not the entire array). Something like this should work: switch($query1_data[months]) { } http://php.net/switch In your original posting you have lines like the following in your switch statement: if($query2 == 31) As someone mentioned, mysql_query returns a resource ID, you then have to use mysql_fetch_assoc (or one of the other mysql_fetch_* functions) to get an array that you can use as you are trying to do. So after doing: $query2_data
Re: [PHP] mysql_fecth_array() and function call as parameter
according to my SQL the month name ois going to be returned not the month number. m_id is the number equivlent to the month. months is the full name of the month. In my month method I did not change the case values to the month number and the function returns correctly. All I had to do was add the column name to $query1_data[] or $query2_data[] But in this method it didn't work. I can't figure it out. I've even checked my column name to be sure I spelled it right. It was. On 3/27/06, Brady Mitchell [EMAIL PROTECTED] wrote: -Original Message- I finally got the function to work. However I have a problem with another function. It is almost exactly like the origional function but in this function I am determining the days instead of the month. I made the same changes to the days function as I did to the month function. However no value is being set to be returned. I can't find my error. My function is below: snip switch ($query1_data[months]) { case January: case March: case May: case July: case August: case October: case December: Once again, in your switch statement you are checking for the full name of the month, but your query will be returning the month number. Since you don't have a default case on your switch statement, $return is never being set, so $day = $this-determineDay(); is not setting $month to anything, which is why you are getting error messages. http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html Brady -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql_fecth_array() and function call as parameter
Hi all, I have wriiten a function that determines whether tomorrows date is the first of the month or not then returns a SQL string based on whether its the first of the month or not. According to my apache error logs I get an error that says: [Sun Mar 26 21:43:14 2006] [error] [client 192.168.0.2] PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\\Program Files\\Apache Group\\Apache2\\htdocs\\validation.php on line 331 I understand that this is a warning but I believe that it has something to do with the fact that no output is being displayed. All other mysql database outputs work fine. This is the code that sets the query in the mysql_query parameter $Month_query = mysql_query($this-determineMonth()); this is the code for determineMonth () function determineMonth() { $return = ; $query1 = mysql_query(SELECT months FROM Month WHERE m_id = month(curdate())); $query2 = mysql_query(SELECT dayNum FROM Days WHERE dayNum = day(curdate())); $query3 = mysql_query(SELECT year FROM Year WHERE year = year(curdate())); switch ($query1) { case January: case March: case May: case July: case August: case October: case December: if($query2 == 31) $return = SELECT m_id, months FROM Month WHERE m_id = month(curdate())+1; else $return = SELECT m_id, months FROM Month WHERE m_id = month(curdate()); break; case February: if ($query2 == 28 || $query2 == 29) $return = SELECT m_id, months FROM Month WHERE m_id = month(curdate())+1; else $return = SELECT m_id, months FROM Month WHERE m_id = month(curdate()); break; case April: case June: case September: case November: if ($query2 == 30) $return = SELECT m_id, months FROM Month WHERE m_id = month(curdate())+1; else $return = SELECT m_id, months FROM Month WHERE m_id = month(curdate()); break; } return $return; } I hope I included everything. If not let me know and I'll post it Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_fecth_array() and function call as parameter
I placed the echo statements in my code and I found out that my query was empty. I also went a step further and tested if I was getting the correct outputs from the queries that initially do at the beginning of the method. Instead of getting an output like March I got an output that says Resource id#9. I don't get it. I tested the sql statement in MySQL that I have on my computer. It worked, Why wouldn't it give the same output through mysql_query()? Paul On 3/26/06, Chris [EMAIL PROTECTED] wrote: Paul Goepfert wrote: Hi all, I have wriiten a function that determines whether tomorrows date is the first of the month or not then returns a SQL string based on whether its the first of the month or not. According to my apache error logs I get an error that says: [Sun Mar 26 21:43:14 2006] [error] [client 192.168.0.2] PHP Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\\Program Files\\Apache Group\\Apache2\\htdocs\\validation.php on line 331 I understand that this is a warning but I believe that it has something to do with the fact that no output is being displayed. All other mysql database outputs work fine. This is the code that sets the query in the mysql_query parameter $Month_query = mysql_query($this-determineMonth()); Add this after your month_query call: echo mysql_error() . br/; It will tell you what's wrong with the query. I'd probably also print out the query: $qry = $this-determineMonth(); echo $qry . br/; and run it manually (if something does get returned). -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mail function problems
Hi all, Has anyone had this problem before? I have a web server that resides on a windows platform (According to phpinfo()). I used the php mail function to send out a test message to make sure that the mail function would work when needed. I sent out the test message and I didn't get an email sent to me. This is what I did, I created the following variables: $to = [EMAIL PROTECTED]; $subject =Test; $message =This is a test $headers = From: Paul . [EMAIL PROTECTED]\r\n; $headers .= X-Sender: [EMAIL PROTECTED]\r\n; $headers .=X-Mailer: PHP\r\n; $headers .=Return-Path: [EMAIL PROTECTED]\r\n; I put them in the mail function as parameters mail($to,$subject,$message,$headers). Ok now this is what is found in phpinfo(): sendmail_from no value no value sendmail_path no value no value SMTP no value no value smtp_port25 25 Do these values need to be set? if so, how do that on a remote server? I don't think I have access to the httpd config file or php.ini file. Thanks Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] regular expressions and Phone validation
Hi all, I have one small problem I don't understand the preg_replace() method. I understand the gist of what it does but I still don't fully know what it does. I have read the entry in the php manual about this and I am still confused about it. I've never been any good with regular expressions. Here is the function in use: function checkPhone ($Phone) { global $errmsg; if (!empty($Phone)) { $Phone = ereg_replace([^0-9], '', $Phone); if ((strlen($Phone)) = 14) return preg_replace(/[^0-9]*([0-9]{3})[^0-9]*([0-9]{3})[^0-9]*([0-9]{4}).*/, (\\1) \\2-\\3,$Phone); } } I think my problem is mostly what is returned when preg_replace executes? Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Creating forms dynamically
Hi all, I have been working on a page where I have a form. I currently have the form in an else block with no access to it if I need to redisplay the form incase of errors. To be more specific I want to redisplay the page with the errors displayed. I would like to have the form coded once. It would save on file size. In my form I have a table that holds the text inputs. I do have MySQL code for dropdown menus. If anyone has any ideas on how to create the form when the error messages are displayed without having to code it a second time please let me know. Oh by the way this is how my page is setup now Class validation { -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Creating forms dynamically
Class validation { //functions } if(isset($submit)) { //calls to validation code } else { //display webpage } On 3/14/06, Paul Goepfert [EMAIL PROTECTED] wrote: Hi all, I have been working on a page where I have a form. I currently have the form in an else block with no access to it if I need to redisplay the form incase of errors. To be more specific I want to redisplay the page with the errors displayed. I would like to have the form coded once. It would save on file size. In my form I have a table that holds the text inputs. I do have MySQL code for dropdown menus. If anyone has any ideas on how to create the form when the error messages are displayed without having to code it a second time please let me know. Oh by the way this is how my page is setup now Class validation { -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Phone number validation
Hi all, I am trying to validate phone numbers in a web form that I have created. I am using a regular expression to validate the phone number. It seems when I enter the phone number in the following ways I get errors (123) 456 7890 123 456 7890 (123) 456 - 7890 123 456-7890 I am using the ereg method in php to test the regular expression. Here is the Regular Expression that I am using to test against potential phone numbers $validPhone = ^([0-9]{3}[ ]*)?[0-9]{3}[ ]*[0-9]{4}$; By the way The phone numbers are in US format. If anyone can help me with this I would really appreciate it. Thanks, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Phone number validation
On 3/12/06, Curt Zirzow [EMAIL PROTECTED] wrote: On Sun, Mar 12, 2006 at 12:09:42PM -0700, Paul Goepfert wrote: Hi all, I am trying to validate phone numbers in a web form that I have created. I am using a regular expression to validate the phone number. It seems when I enter the phone number in the following ways I get errors (123) 456 7890 123 456 7890 (123) 456 - 7890 123 456-7890 Dont forget: 123.456.780 1-123-456-7890 ... $validPhone = ^([0-9]{3}[ ]*)?[0-9]{3}[ ]*[0-9]{4}$; By the way The phone numbers are in US format. With US phone numbers I always use this approach to avoid what format people use to enter the phone: - Remove any non digit $check_phone = preg_replace('/[^0-9]/', '', $phone); I just want to be sure about something. Is there a second quotation mark missing? I only count one and I added a space between the quotes. Paul - If $check_phone strlen 10.. invalid - if $check_phone strlen == 11 first char == '1'.. remove it - if $check_phone strlen == 10, seems ok - possible area code check with prefix check (if have db to support that) I would even go as far as storing the phone striped of any formating and only format it when you display it. The other option would to make three seperate input fields in the form and join them together in your script: (input name=phone[area]) input name=phone[code]-input name=phone[num] Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Phone number validation
I didn't realize that those were single quotes. I printed out the email message and it looked like one set of double quotes for the second parameter rather the two single quotes. Is it possible for anyone to tell me what php method is used to grab the first charater of a string? And onece I have it what method removes the characted or number? I know this seems trivial but I am still new to php and I don't have a good understanding of the language yet. The more I do the better I'll get. Thanks Paul On 3/12/06, Curt Zirzow [EMAIL PROTECTED] wrote: On Sun, Mar 12, 2006 at 01:48:28PM -0700, Paul Goepfert wrote: On 3/12/06, Curt Zirzow [EMAIL PROTECTED] wrote: With US phone numbers I always use this approach to avoid what format people use to enter the phone: - Remove any non digit $check_phone = preg_replace('/[^0-9]/', '', $phone); I just want to be sure about something. Is there a second quotation mark missing? I only count one and I added a space between the quotes. I'm not sure what you're seeing but the line reads like this: http://pastebin.com/598522 Curt. -- cat .signature: No such file or directory -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP/CSS/Javascript question
Hi all, Is it possible to modify a table using JavaScript to control CSS visabilty when the entire table is developed dynamically using PHP? Thanks, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] output Today's date
Hi all, ls there anyway I can set the date to the timezone of the clients timezone? For example, if a person opens the web page at 3/6 12:01 EST and another person opens the same page at 3/5 10:01 MST I would like the date to be the above days on the client computers. I know everyone knows this but the way I described this the two people accessed the webpage at the same time but I want the correct date for the client computer to be outputted. Thank you, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Displaying Form Errors
Hello all, I am building a web page and I don't know how to display the errors that the user may enter. OK this is how I have my web page setup: I first do a isset check on $submit. And I am not sure about this. I believe that this variable is set when i click on the submit button. I don't have a $submit variable assigned to anything in my web page. What I would like is to have $submit assigned to the submit button. How do I do that? In the if block I do my validation of the web form. In the else block I have the contents of the page. I have posted this question before and I got some good pointers on how I should go about doing my validation but I have not yet figured out how to display the errors on the page. Could someone help me with that. I am doing the validation on the same page as the web page. I don't forward to a new page to do the validation. Thanks Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How do I output error messages
Hi all, I have a web page that I am doing valildation on. I have figured out how to at least get the page to load the page content. What I can't seem to figure out is how to output the error messages to the screen. The validation is being performed on the same page as the form that is being validated. The way the page is setup: if (isset($submit)) { //vaildation code } else { //webpage } Thanks for the help, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How do I output error messages
$submit is soppose to be set when the user submits the web form for validation. I am not sure but is there soppose to be a $submit = input type=submit name=submit value=submit statement? Paul On 2/21/06, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] if (isset($submit)) { //vaildation code } else { //webpage } [/snip] What is $submit? Is it set ever? The problem probably lies in the fact that $submit, whatever it is, never gets set. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] attaching MySQL 5.0.18 to PHP 4.4.2
I forgot to mention that that php and mysql are installed on a windows machine which means I didn't have to run the configure script that would associate mysql with php. How do I do this on a windows machine? Paul On 2/17/06, Kim Christensen [EMAIL PROTECTED] wrote: On 2/17/06, Paul Goepfert [EMAIL PROTECTED] wrote: Hi all, I know the subject doesn't seem too clear so here is what I am talking aboukt. I recently installed php on my windows machine. The PHP compiler works great. However upon looking through the phpinfo () document I noticed that the MySQL client version was 3.23.49. I assume that is the built in version of MySQL. I also have installed MySQL 5.0.18 on my system. I have my database in the 5.0.18 version of MySQL . How do I asssociate the MySQL 5.0.18 version with php? http://php.net/manual/en/ref.mysqli.php This isn't really the answer to your question per se, but will probably solve things along the way. -- Kim Christensen [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] attaching MySQL 5.0.18 to PHP 4.4.2
Hi all, I know the subject doesn't seem too clear so here is what I am talking aboukt. I recently installed php on my windows machine. The PHP compiler works great. However upon looking through the phpinfo () document I noticed that the MySQL client version was 3.23.49. I assume that is the built in version of MySQL. I also have installed MySQL 5.0.18 on my system. I have my database in the 5.0.18 version of MySQL . How do I asssociate the MySQL 5.0.18 version with php? Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] installing php 4.4.2 on windows system
Hello all, I have been developing a php website. I have been ftping my php web pages to a webserver and that works hkowever I don't have an error log on the webserver. So I downloaded apache 2.0.55. I am doing a manual installation and I am at the point where it tells me where to place the php.ini file. The instructions tell me to put the file in a number of places. The directions told me that if I were using apache to use the PHPIniDir directive. My question is where do I put the php.ini file? Where do I put this Directive? In the Httpd.conf? Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Class/functions question
Does anyone know where I can find the error log? I am using php on a webserver and the only log I found was a connection log in the logs dir on my webserver. Paul On 2/14/06, Jochem Maas [EMAIL PROTECTED] wrote: Paul Goepfert wrote: I was able to get part of my page to load when I created the Validation class and put a call to the validation class within my table. When I did that the page loaded up until the php code to call the method and then it does not load the rest of the page.Can anyone help me with this? By the way I am calling $_POST[name] as it sounds like your class does not exist (or some function or class it relies on). the parameter to be passed into the function so my php code looks like: ?php $a = new Validation; $a-checkEmpty($_POST[name]); ? 1. check your error log for an error messge. 2. determine if the class exists at the time that the above code is run e.g. with class_exists('Validation'). 3. determine if $a is actually a Validation object (i.e. the creation of a new object succeeded) Paul On 2/12/06, Chris Shiflett [EMAIL PROTECTED] wrote: Paul Goepfert wrote: I know how to call functlions, I just just don't know how to do it in PHP. Based on the rest of your question, I think you mean methods, not functlions. :-) If you're struggling with syntax, you should take one step at a time. Try this: ?php class myClass { function myMethod() { echo 'pmyMethod()/p'; } } $myObject = new myClass; $myObject-myMethod(); ? That should help you with any syntax problems, but I suspect your problem has more to do with logic than with syntax. if (isset($submit)) { class Validation { /* ... */ } } else { /* ... */ $v = new Validation; $v-checkEmpty($_POST[name]); If the form is submitted, define the class, else use the class. That doesn't sound right... Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Class/functions question
I was able to get part of my page to load when I created the Validation class and put a call to the validation class within my table. When I did that the page loaded up until the php code to call the method and then it does not load the rest of the page.Can anyone help me with this? By the way I am calling $_POST[name] as the parameter to be passed into the function so my php code looks like: ?php $a = new Validation; $a-checkEmpty($_POST[name]); ? Paul On 2/12/06, Chris Shiflett [EMAIL PROTECTED] wrote: Paul Goepfert wrote: I know how to call functlions, I just just don't know how to do it in PHP. Based on the rest of your question, I think you mean methods, not functlions. :-) If you're struggling with syntax, you should take one step at a time. Try this: ?php class myClass { function myMethod() { echo 'pmyMethod()/p'; } } $myObject = new myClass; $myObject-myMethod(); ? That should help you with any syntax problems, but I suspect your problem has more to do with logic than with syntax. if (isset($submit)) { class Validation { /* ... */ } } else { /* ... */ $v = new Validation; $v-checkEmpty($_POST[name]); If the form is submitted, define the class, else use the class. That doesn't sound right... Hope that helps. Chris -- Chris Shiflett Brain Bulb, The PHP Consultancy http://brainbulb.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Class/functions question
Hi all, I building a website with PHP. I am going to be using functions to deal with vaildation. I am putting all the methods in a class called Validation. My problem is I do not know how to call the function. Well I shouldn't say that. I know how to call functlions, I just just don't know how to do it in PHP. Let me put it this way. When I write programs in C++/Java I know that I have to do the following steps, create an object reference to the class use the object reference to access the methods. I am almost certain that it is the same thing in PHP. So this is what I did in my web page. ?php if (isset($submit)) { //validation code class Validation { function checkEmpty ($var) { if (empty($var)) { echo YEAH It works!!; } } } else {? . tr td align=leftFirst Name/td td align=left span class=color*/spaninput type=text name=name size=20 ?php $v = new Validation; $v-checkEmpty($_POST[name]); ? /td /tr .. ... = rest of php/html code the else block holds the entire html code for the page Do I have the logic right? Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] vaidation and mail function question
I am beginnging to do vaidation on my web form and I know of a few functions to do this with. For example the empty fuction and the is_ functions. Ok to give you a picture of what I am vaildating its just your basic form, Name, Address, Email. I am obviously going to check for empty fields. However I do want better error checking other then testing for emptty fields. Can anyone help me with that? After this form is finished vaildating I am going to be sending an email of the contents of the form to an email account. I have seen in other messages on this board about the mail function. I'm not sure about this but I think I read that in order for the mail function to work the webserver needs sendmail to make the mail function work. Is this true? I have looked at the phpinfo page on the targeted webserver and the sendmail value is missing. I assume that is ok because the webserver is on a windows system rather then a unix system. I just want to be sure about this. Thanks Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can't output sql query with php code.
Thanks everyone for your help. I should have seen the semi-colon at the end of the while loop. I must have looked at the code 20 times and I can't believe I missed it. Paul On 2/6/06, Brady Mitchell [EMAIL PROTECTED] wrote: ?php echo 'select name=month \n'; $month_query = mysql_query(SELECT m_id, months FROM Month); while ($r = mysql_fetch_array($month_query)); Remove the semi-colon at the end of the above line and it works like a charm. { $v = $r[m_id]; $out = $r[months]; echo option value=$v$out/option\n; } echo '/select\n'; ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Is this the most effient to do with php an mysql?
Hi all, I have a table of years going from 1985 - 2008. These years represent the purchase year. I have created a SQL statement that selects the years that are available for purchase years. For example 2006 -1985. Here is the SQL statement I created to produce that output. SELECT y_id, year FROM Year WHERE year = extract(year from now()) ORDER BY year desc; Is there a more efficient way to do this using more PHP and less mysql? Thanks Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Is this the most effient to do with php an mysql?
I am using this table to find out what year the person purchased their equipment On 2/6/06, Peter Lauri [EMAIL PROTECTED] wrote: I do not know if it is more efficient, but you can do this: $year = date(Y); $Query = sprintf(SELECT y_id, year FROM Year WHERE year = %s ORDER BY year DESC;, $year); $Result = mysql_query($Query); May I ask you what you are using this table for? /Peter -Original Message- From: Paul Goepfert [mailto:[EMAIL PROTECTED] Sent: Tuesday, February 07, 2006 7:55 AM To: php-general@lists.php.net Subject: [PHP] Is this the most effient to do with php an mysql? Hi all, I have a table of years going from 1985 - 2008. These years represent the purchase year. I have created a SQL statement that selects the years that are available for purchase years. For example 2006 -1985. Here is the SQL statement I created to produce that output. SELECT y_id, year FROM Year WHERE year = extract(year from now()) ORDER BY year desc; Is there a more efficient way to do this using more PHP and less mysql? Thanks Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] can't output sql query with php code.
Hi all, I have a mysql database setup to use with my php web page. I have been able to access the database and get values into my drop down menus. However when I tried to output the contents into two two diferent variables the code does not work. To be more specific I will show you the code both the one that works and the one that doesn't Doesn't work - ?php $month_query = mysql_query(SELECT m_id, months FROM Month); while ($row = mysql_fetch_array($month_query)) { $val = $row[m_id]; $out = $row[months]; echo option value=$val$out/option; } ? - Code that works - ?php echo ' select name=equipment size=1 id=equip onChange=addRow()'; $Equip_query = mysql_query(SELECT equip FROM Equipment ORDER BY equip ASC); while ($r = mysql_fetch_array($Equip_query)) { $val = $r[equip]; echo option value=$val$val/option\n; } echo /select/td; ? Also I should tell you that the code that works comes after the code that doesn't work in my web page. Oh for the values that are outputted in the code that doesn't work are val is numeric and out is a string. I know my sql query works because I tested it in mysql. Thanks for the help Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] can't output sql query with php code.
This is the full code for the code that doesn't work. ?php echo 'select name=month \n'; $month_query = mysql_query(SELECT m_id, months FROM Month); while ($r = mysql_fetch_array($month_query)); { $v = $r[m_id]; $out = $r[months]; echo option value=$v$out/option\n; } echo '/select\n'; ? On 2/6/06, Brady Mitchell [EMAIL PROTECTED] wrote: Doesn't work - ?php $month_query = mysql_query(SELECT m_id, months FROM Month); while ($row = mysql_fetch_array($month_query)) { $val = $row[m_id]; $out = $row[months]; echo option value=$val$out/option; } ? You're missing the select tags. while ($r = mysql_fetch_array($Equip_query)) { $val = $r[equip]; echo option value=$val$val/option\n; } On a seperate note, if all you are doing with the $val variable is using it to echo, it's not needed. Put brackets { } around the var to echo ie: {$r[equip]} - makes it easier to read later when you come back to tweak your code. Brady -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Database question and PHP
I have a MS Acess Database that goes along with my web page. I want to transfer the data to a MySQL database since there are php functions for the MySQL database. I do not have a MySQL database running on the system that I am developing the web page. However there is a MySQL database on the webserver that the web site is to reside. Is the databases that reside on webservers easy to maintain? Is using that database a good option or is there another database option I should use? I am converting this website from Cold Fusion to PHP. In the Cold Fusion version there was a option in the CFSELECT Tag to add a query from a database to populate the options for the select tag. Is there a way to do this in php? I am not talking about the query string but the call to get the select tag to populate the options. Thanks, Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] questions regarding PHP and Forms
Thanks for the help everyone. I have decided to use javascript to deal with my second problem. I understand that this is not a JavaScript fourm but I am having some trouble getting my JS function to work correctly. Here is my JS code. function getEquipment () { var mylist = document.getElementById(equip); if (mylist.options[mylist.selectedIndex].value==other) { document.writeln(tr); document.writeln( td align=leftOther/td); document.writeln( tdinput type=text name=other size=20/td); document.writeln(/tr); } } This is my code for where the function is called select name=equipment size=1 id=equip onChange=getEquipment() option value=treadmillTreadmil/option option value=exercise bikeExercise Bike/option option value=otherOther/option option value=rowing machine selectedRowing Machine/option /select My problem is when the page loads in a web browser the Option Other is selected every time. From what you can see from my code Rowing machine is the one that I want to be shown when the page loads. Anyway can anyonne tell me why my code is not executing correctly. I am not too familiar with java script. What I am trying to accomplish is if Other is selected then add a new table row below the drop down menu with the content that I have in the function. If no one can help with this would someone please direct me to a Java Script Forum. Thanks Paul On 1/27/06, Weber Sites LTD [EMAIL PROTECTED] wrote: Check out this list of code examples to help with #1 http://www.weberdev.com/AdvancedSearch.php?searchtype=titlesearch=validatio n Sincerely berber Visit the Weber Sites Today, To see where PHP might take you tomorrow. PHP code examples : http://www.weberdev.com Free Uptime Monitor : http://uptime.weberdev.com PHP content for your site : http://content.weber-sites.com -Original Message- From: Paul Goepfert [mailto:[EMAIL PROTECTED] Sent: Friday, January 27, 2006 9:28 PM To: php-general@lists.php.net Subject: [PHP] questions regarding PHP and Forms Hi all, I am writing my first website in php. I have a few questions. 1) I need to do vaildation on form values that I have entered into a form. Is there a way I can write the vaildation code on the same page as the form in php? 2) I have a drop down menu on one of my form fields. What I want to do is if a certain item is seelected I want to have a new textbox appear below the drop down menu. Is there a way to do this in php? Thanks Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] questions regarding PHP and Forms
Hi all, I am writing my first website in php. I have a few questions. 1) I need to do vaildation on form values that I have entered into a form. Is there a way I can write the vaildation code on the same page as the form in php? 2) I have a drop down menu on one of my form fields. What I want to do is if a certain item is seelected I want to have a new textbox appear below the drop down menu. Is there a way to do this in php? Thanks Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] need information on sending email using php
Hi all, I am new to php. I am going to be setting up a page that has a form on it. When the user clicks on submit an email should be sent with the contents of the form. My question is How do I do that? the webserver that I will be placing this page on has php ver 4.4.0 on it. Any help would be appreciated Paul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php