Re: [PHP-DB] radio form submission
On Thu, Jun 23, 2011 at 15:46, Chris Stinemetz chrisstinem...@gmail.com wrote: Use an if or a switch. For example: I think your suggestions are exactly what I am looking for. I am not sure exactly where to place it. Do I insert it after the query statment? During your while() loop. This line here: td class=post-content' . $posts_row['post_tptest'] . If you convert it to a function as Karl suggested, you could do something like this: td class=post-content' . getSpeed($posts_row['post_tptest']) . -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] radio form submission
On Thu, Jun 23, 2011 at 16:08, Chris Stinemetz chrisstinem...@gmail.com wrote: I must be missing something. I am just getting a blank page. Your help is greatly apprecieated. This is why you're supposed to take the advice and write it out yourself, not copy and paste the code. ;-P By copying and pasting the stuff, you broke your query. Karl suggested you use a column which doesn't exist. Instead, change the query back to what it was before, add the function (you should be able to copy and paste that part though) at the end of the file, and then use the line of code I gave you. Obviously, I can't write it out for you, but you'll get the idea. The function and query statement is: function getSpeed($val) { if($val != 'undefined') { switch ($val){ case 1: $post_tptest = 0-250kbps; break; case 2: $post_tptest = 250-300kbps; break; case 3: $post_tptest = 300-400kbps; break; case 4: $post_tptest = 400-600kbps; break; case 5: $post_tptest = 600kbps-3.8mbps; break; default: $post_tptest = Speed Undetected; // or 0-250kbps break; } } else { return(Error, no speed value set); } } } $post_speed = getSpeed($post_tptest); //fetch the posts from the database $posts_sql = SELECT posts.post_store, posts.post_content, posts.post_speed, posts.post_date, posts.post_by, users.user_id, users.user_name, users.first_name, users.last_name FROM posts LEFT JOIN users ON posts.post_by = users.user_id WHERE posts.post_store = . mysql_real_escape_string($_GET['id']) . ORDER BY posts.post_date DESC ; The call: while($posts_row = mysql_fetch_assoc($posts_result)) { echo 'tr class=topic-post td class=user-post' . $posts_row['first_name'] . ' ' . $posts_row['last_name'] . 'br/' . date('m-d-Y h:iA', strtotime($posts_row['post_date'])) . '/td td class=post-content' . getSpeed($posts_row['post_tptest']) . 'br/' . htmlentities(stripslashes($posts_row['post_content'])) . '/td /tr'; } } Thank you! -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/
Re: [PHP-DB] radio form submission
On Thu, Jun 23, 2011 at 14:18, Chris Stinemetz chrisstinem...@gmail.com wrote: So far I am good on creating the form and submitting it to mysql database and calling the submitting value from a different script. My question is: How can I make it so when a user selects radio option value 1 it will then be displayed as 0-250kbps when I call it the value in the bottom script? Use an if or a switch. For example: ?php // Using if/elseif/else if ($row['tp_test'] == '1') { echo '0-250Kbps'; } elseif ($row['tp_test'] == '2') { echo 'The second value.'; } elseif ($row['tp_test'] == '3') { echo 'The third value.'; } else { echo 'I have no clue. I give up.'; } // Using switch switch ($row['tp_test']) { case '1': echo 'First case.'; break; case '2': echo 'Second case.'; break; case '3': echo 'Third case.'; break; default: echo 'No idea whatsoever.'; break; } ? -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] Regex for telephone numbers
On Fri, Dec 31, 2010 at 19:09, Jim Lucas li...@cmsws.com wrote: Actually... Specified here [1] it says that the {1,} is the same as '+'. I think you should drop the comma. If you don't this would be valid 844-2345-123456 ^[2-9]{1,}[0-9]{2,}\-[2-9]{1,}[0-9]{2,}\-[0-9]{4,}$ should be ^[2-9]{1}[0-9]{2}\-[2-9]{1}[0-9]{2}\-[0-9]{4}$ Bah, you're absolutely correct. Force of habit with the commas. I didn't even notice the sample test cases I put into that test array didn't check for more than the number of digits per field, either. Good catch, Jim, and Happy New Year. -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] Regex for telephone numbers
On Wed, Dec 29, 2010 at 19:12, Ethan Rosenberg eth...@earthlink.net wrote: Dear List - Thank you for all your help in the past. Here is another one I would like to have a regex which would validate that a telephone number is in the format xxx-xxx-. Congrats. People in Hell would like ice water. Now we all know that everyone wants something. ;-P Really, this isn't a PHP question, but rather one of regular expressions. That said, something like this (untested) should work: ?php $numbers = array( '123-456-7890', '2-654-06547', 'sf34-asdf-', 'abc-def-ghij', '555_555_', '000-000-', '8007396325', '241-555-2091', '800-555-0129', '900-976-739', '5352-342=452', '200-200-2000', ); foreach ($numbers as $n) { echo $n.(validate_phone($n) ? ' is ' : ' is not ').'a valid US/Canadian telephone number.'.PHP_EOL; } function validate_phone($number) { if (preg_match('/^[2-9]{1,}[0-9]{2,}\-[2-9]{1,}[0-9]{2,}\-[0-9]{4,}$/',trim($number))) { return true; } return false; } ? -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] Problems w/ goto
On Fri, Dec 17, 2010 at 12:22, Robert Cummings rob...@interjinn.com wrote: I was one of the people that argued in favour of GOTO on the Internals list a few years ago. GOTO has a use, and a very good one at that. It is by far the most efficient construct when creating parsers or other similar types of logic flow. The demonized GOTO of the 80s was primarily due to jumping to arbitrary points in the code, or in the case of basic to arbitrary line numbers in the code which had little meaning for future readers. Not to mention failure to properly break, as in the OP's code example. -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] [PHP] mySQL query assistance...
On Mon, Nov 29, 2010 at 14:35, Don Wieland d...@dwdataconcepts.com wrote: Hi all, Is there a list/form to get some help on compiling mySQL queries? I am executing them via PHP, but do not want to ask for help here if it is no the appropriate forum. Thanks ;-) Yes. For MySQL queries, write to the MySQL General list at my...@lists.mysql.com. For PHP-specific database questions (for any database backend, not strictly MySQL), such as problems in connecting to the database, questions on support for database platform/version, or even query processing, you should use php...@lists.php.net. For your convenience, both have been CC'd on this email. -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] Strange Query Error...
On Sat, Nov 27, 2010 at 12:30, Don Wieland d...@dwdataconcepts.com wrote: Hi gang, I am executing a query via PHP that gives me a PHP error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND m.`Preferred_First_Name` LIKE 'Don' AND m.`Preferred_Last_Name` LIKE 'Wielan' at line 1 but when I copy the ECHO of the select query and run it in Sequel Pro Query, it returns no error. Here is the query: select m.* from Members m inner join Member_Years my on m.aucciim_id = my.member_id where now() DATE_ADD(DATE_SUB(concat(`member_year` + 1,'-07-01'), INTERVAL 1 DAY), INTERVAL 30 DAY) AND m.`Preferred_First_Name` LIKE 'Don' AND m.`Preferred_Last_Name` LIKE 'Wieland' group by m.AUCCIIM_ID order by m.preferred_last_name What is causing it to choke via PHP? This is actually better-suited to the DB list (CC'd) than the General list, but one primary question: are you using the mysql_* family, mysqli_* family, or another method of interfacing with MySQL? -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] Re: [PHP] Strange Query Error...
On Sat, Nov 27, 2010 at 13:18, Don Wieland d...@dwdataconcepts.com wrote: On Nov 27, 2010, at 10:07 AM, Bastien wrote: Try removing the backticks around the table names. If you do use them, then all values (field names and table names) need it. I tried that and still chokes... select m.* from Members m inner join Member_Years my on m.aucciim_id = my.member_id where now() DATE_ADD(DATE_SUB(concat(member_year + 1,'-07-01'), INTERVAL 1 DAY), INTERVAL 30 DAY) AND m.Preferred_First_Name LIKE 'Don%' group by m.AUCCIIM_ID order by m.preferred_last_name ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND m.Preferred_First_Name LIKE 'Don%'' at line 1 Note how you keep changing case here. For example, m.aucciim_id vs. m.AUCCIIM_ID. Also note that all of this is cAsE-sEnSiTiVe. -- /Daniel P. Brown Dedicated Servers, Cloud and Cloud Hybrid Solutions, VPS, Hosting (866-) 725-4321 http://www.parasane.net/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] moved code to a new server
Forwarded to General, since this doesn't belong on DB. On Fri, Oct 24, 2008 at 6:18 PM, Marc Fromm [EMAIL PROTECTED] wrote: We moved our website to a new linux server. The code was running on a different linux server. Thus the OS environment is the same. We are receiving this error: [Fri Oct 24 14:53:37 2008] PHP Fatal error: require() [a href='function.require'function.require/a]: Failed opening required 'this was a url to a .js file' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/html/path to .php file on line 4 I'm not a php programmer thus I am in the dark. You don't have to be, you just have to read the error message. If you copied that verbatim, then 'this was a url to a .js file' exists on line 4 of .php in /var/www/html/path, and PHP failed to open it. Make sure the file exists exactly where PHP is looking for it, and that it's accessible and readable to and by the user as which the server is running when executing `.php` in /var/www/html/path, and that the target file can be found from that directory. -- /Daniel P. Brown http://www.parasane.net/ [New Look] [EMAIL PROTECTED] || [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php