[PHP] Location header - slow redirect
I'm using the following short script to redirect users to another page on my site (php 4.3.2, Apache 2.0.47). http://"; . $_SERVER['HTTP_HOST'] . "/" . $goLang . "/"); exit; ?> I'm having a problem where it takes up to 15 seconds for the redirect page to load, but for other redirects on the site programmed in a similar way using php and the location header the page loads straight away. I'm a bit perplexed and would appreciate some suggestions. Thanks Phil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] crontab programmed with mysql ??
I'm looking for the approximate solution of mailing out (or doing anything else ) timed by cron(tab) along with use of mysql as means of identification and storing of the dates in multiuser enviroment. Initial date and interval of recurring event is to be set up by a user. May you know some open source code as an example to do that or so? Thank you, Oleg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help - I'm New
Hi, first let me introduce myself... My name is Kit, and I own the domain below and host sites from off that domain. I'm new to using PHP...and need some help. 1. I have apache for win32 1.3.26 setup on my w2k pro at home, and need to know how to enable PHP in the config. 2. I also have a PHP website, and need to know how to include "FORMS" for subscribing to newletters in a file called "header.php" <*** http://www.myispnet.net ***> Administrator My ISP Network [EMAIL PROTECTED] <*** http://www.myispcentral.net ***> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] help with PHPwebsite
I get the following error when i try to install an app called "PHPwebsite" ( http://phpwebsite.appstate.edu/ ) Warning: Cannot add header information - headers already sent by (output started at C:\apache\htdocs\php\setup\index.php:9) in C:\apache\htdocs\php\htmlheader.php on line 30 I also installed php,apache,perl,mysql etc using a program called: "PHPtriad" ( an app that installs/configures everything at once) Why am I getting that error, can anyone help? <*** http://www.myispnet.net ***> Administrator My ISP Network [EMAIL PROTECTED] <*** http://www.myispcentral.net ***> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] FW: help with PHPwebsite
I get the following error when i try to install an app called "PHPwebsite" ( http://phpwebsite.appstate.edu/ ) Warning: Cannot add header information - headers already sent by (output started at C:\apache\htdocs\php\setup\index.php:9) in C:\apache\htdocs\php\htmlheader.php on line 30 I also installed php,apache,perl,mysql etc using a program called: "PHPtriad" ( an app that installs/configures everything at once) Why am I getting that error, can anyone help? = below is the header.php file I'm having trouble with: = "4.1.0") ? $_SERVER[HTTP_USER_AGENT] : $HTTP_SERVER_VARS[HTTP_USER_AGENT]; // Both IE 5.x and Mozilla >= 0.9.8 now require header() to be postfixed by // exit, otherwise they do not execute headers send if (stristr($agent, 'msie')) { Header("Refresh: 0;url=$url"); exit; } else { Header("Location: $url"); exit; } } ?> <*** http://www.myispnet.net ***> Administrator My ISP Network [EMAIL PROTECTED] <*** http://www.myispcentral.net ***> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] T_string error
Can someone tell me what the following error means, and how to fix it...please? Parse error: parse error, unexpected T_STRING in c:\program files\apache group\apache\htdocs\phpbb\language\lang_english\lang_main.php on line 629 this is the code on that page: $lang['Avatar_filesize'] = 'The avatar image file size must be less than %d kB'; // The avatar image file size must be less than 6 kB (than 6 kB < this part of that line is on the next line down) <*** http://www.myispnet.net ***> Administrator My ISP Network [EMAIL PROTECTED] <*** http://www.myispcentral.net ***> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] EO - New FREE web development engine
Hello, I'm contacting you because we have recently released a new web development platform, EO, that I would like for you to try out for use in building dynamic sites. EO is a portable, flexible yet robust system that you can use to quickly build interactive sites, plus it has features that protect you, the web developer. The Engine behind EO has been in development since 1996 and has been used to build simple to complex systems in many industries including retail, automotive, financial, marine and more. BEST OF ALL IT'S FREE! Please visit http://www.eodeveloper.com/eo/eo.exe/eofree?01 to find out more and download your FREE copy. Thank you! Team EO http://www.eodeveloper.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] how_to_display blob picture from Interbase database
Hi php-general, How to display blob picture from Interbase database in web page. -- Keep going, Admin mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] PHP to embed font
Is there anyway to use PHP to embed font types into web pages to the person visiting the page sees what you want them to even if they dont have the same fonts on their computer. Pat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Web page authentications
I am new to PHP and am confused on HTTP authentications. I have read that section in the manual and still have questions. Where does PHP look to see if the user is valid or if the passward matches the user. How do you use PHP to set up user registration so users can input their information for authentication. Can anyone point me in the right direction to read more on this and help clear my confusion. Pat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] Date Issue
$smont = 10; $sday = 13; $syear = 2008; $timestamp = mktime(0,0,0,$smont,$sday,$syear); $thismonth = getdate($timestamp); Here is where the problem comes into play. echo $thismonth['yday']; This displays 286 when in fact its 287. Is there a problem in my ini file or what is the deal. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Php mysql update
Okay maybe i have just forgot. I am trying to update the database and do a +1 to a int field without pulling the data and adding 1 to it and sticking it back in. Someone refresh me on this please. I think it is something like. $dwsl = mysql_query("UPDATE database set Field='+1' WHERE Criteria='Criteria'"); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Php mysql update
Sorry about that it hit me right after i sent the email. Thank You so much for you reply Hello, you have to do : $dwsl = mysql_query('UPDATE database SET "Field"="Field"+1 WHERE "Criteria"=\'Criteria\'');> From: ad...@buskirkgraphics.com> To: php-general@lists.php.net> Date: Mon, 29 Dec 2008 12:05:37 -0500> Subject: [PHP] Php mysql update> > Okay maybe i have just forgot.> I am trying to update the database and do a +1 to a int field without pulling the data and adding 1 to it and sticking it back in.> > Someone refresh me on this please.> I think it is something like.> $dwsl = mysql_query("UPDATE database set Field='+1' WHERE Criteria='Criteria'");> > -- > PHP General Mailing List (http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php> _ Téléphonez gratuitement à tous vos proches avec Windows Live Messenger ! Téléchargez-le maintenant ! http://www.windowslive.fr/messenger/1.asp -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php rpm
Okay here is my question. Does anyone know of an RPM of php that is pre-compiled with all the extras like soap, mssql, freetds, etc... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] verify text in field
Try $text = "Joe of Egypt"; $sql = "SELECT title FROM book WHERE title LIKE '$text'"; $result = mysql_query($sql); If(mysql_num_rows($result) >= '1') { while ( $row = mysql_fetch_array($sql) ) { echo("" . $row["title"] . ""); } } My Ideas my not make some people happy with my design but I use it and it works very well -Original Message- From: PJ [mailto:af.gour...@videotron.ca] Sent: Thursday, February 26, 2009 5:07 PM To: php-general@lists.php.net Subject: [PHP] verify text in field Is there a shorter way of determining if a field contains text? This works but I wonder if I can K.I.S.S. it? I really only need to know if there is or is not a field containing the text specified. I don't need to see it. Error performing query: " . mysql_error() . ""); exit(); } // Display the text while ( $row = mysql_fetch_array($result) ) { echo("" . $row["title"] . ""); } if ($row["title"] == "") echo ("Empty!") ?> -- Phil Jourdan --- p...@ptahhotep.com http://www.ptahhotep.com http://www.chiccantine.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] Time difference desired load
Suggestion on faster solutions for extremely large database. $ledip['started'] = '2009-04-01 13:40:34'; Example time in DB $ledip['touchedlast'] = '2009-04-01 13:41:28'; Example time in DB date('i:s', strtotime($ledip['touchedlast']) - strtotime($ledip['started'])); // Not a desired solution because of its inability to go past the minute correctly I AM AWARE. or concat( truncate( hour( timediff($ledip['touchedlast'],$ledip['started']) ) /24, 0 ) , " days ", hour( timediff($ledip['touchedlast'],$ledip['started']) ) %24, " hours ", minute( timediff($ledip['touchedlast'],$ledip['started'] ) ) , " minutes ", second( timediff($ledip['touchedlast'],$ledip['started'] ) ) , " seconds" ) as timeleft The results of concat truncate, allows me the flexibility or exacting time differences out past the minute. I am worried that the vastness of the database may cause me a server load or query timeframes that are undesirable as it grows even bigger. Suggestions? * PLEASE Do not reply to this email with your 9 million page thought of how to, or some custom function that you think is all that, I do not care. I am asking for load desired results NOT your take on my code… -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php/mysql Query Question.
Before most of you go on a rampage of how to please read below... As most of you already know when using MySQL from the shell you can write your queries in html format in an out file. Example: shell>mysql -uyourmom -plovesme --html This now will return all results in an html format from all queries. Now I could “tee” this to a file and save the results returned if I so choose to save the result of the display . Let’s say I want to be lazy and write a php MySQL query to do the same so that any result I queried for would return the html results in a table without actually writing the table tags in the results. Is there a mysql_connect or select_db or mysql_query tag option to do that since mysql can display it from the shell? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php/mysql Query Question.
I tend to do this robert, while looking at your example i thought to myself since i am trying to mimick a shell command why not run one. Result: $ddvery"; ?> Not are the results safe but the unlimited possibilites are amazing. Thanks so much for the kick starter ad...@buskirkgraphics.com wrote: > Would you mind giving me an example of this that i can stick right into a blank php file and run. > > I get what you are saying but i cant seem to make that even echo out the data. php 5.2 mysql 5.1.3 Apache 2.2 Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- 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] Formatting an ECHO statement.
I ask as you look at the comments and replies to your post, you think long term. Today you want the italic option, tomorrow you want to change the display to something else. Now you have to go back and change ever place you set the italic symbols to make your change. BUT if you use styles you can not only change the display to the desired look in one location but you can have flexibility. Example: Let's say the comments are coming from a database and you want to display the comment differently based on the contents of the comment. In my example I have 3 different classes in the style. Now as I foreach over the fake data array example, I simply pick the style to use based on each matching criteria. While the static examples #wever_comment{font-style:italic} #good_comment{font-style:italic; color: green;} #bad_comment{font-weight:bold; color: red;} $variable_from_database = array('good','bad','whatever'); Foreach($variable as $key) { Echo 'Other Comments:'; If(preg_match("/bad/i",'$key')){Echo '$key';} If(preg_match("/good/i",'$key')){Echo '$key';} If(preg_match("/whatever/i",'$key')){Echo '$key';} Echo ''; } In the long term the flexibility allows you to make faster changes with a higher degree, of what I like to call "smarter code". Yes the filters are static, and I would not use static filters personally. It is meant as an explanation, not a how to. -Original Message- From: Shreyas Agasthya [mailto:shreya...@gmail.com] Sent: Monday, October 18, 2010 6:10 AM To: PHP General List Subject: [PHP] Formatting an ECHO statement. Team, A bit of silly one but like my book says, there are no dumb questions, I am asking it here. If I have : $other="Whatever"; and I do: echo 'Other Comments:' .$other. ' works perfectly well and prints the value. What if I want to, now, italicize the value of $other with the above syntax? How do I achieve it? I know we can do it this way : echo " I am $other"; but I want to learn how to do it with the above syntax like I mentioned earlier. Regards, Shreyas Agasthya -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Fiscal Years and Quarters
Don If you are looking for current quarter you can do this. $tm = date('Y-m-d H:i:s'); $Current_Fiscal_Quarter = ceil(date("m", $tm)/3); This will return the quarter you are currently in. Exmaple 1, 2, 3,or 4 I have a great quarterly dates function posted on php.net http://www.php.net/manual/en/function.date.php#100390 -Original Message- From: Don Wieland [mailto:d...@pointmade.net] Sent: Tuesday, October 19, 2010 7:12 PM To: php-general@lists.php.net Subject: [PHP] Fiscal Years and Quarters Hello, I have a preference field called "Fiscal_Year_Start_Month" which has the Month Names as options. Based on this value, I need to calculate the following date in UNIX: Current_1st_Quarter_Start_Date Current_1st_Quarter_End_Date Current_2nd_Quarter_Start_Date Current_2nd_Quarter_End_Date Current_3rd_Quarter_Start_Date Current_3rd_Quarter_End_Date Current_4th_Quarter_Start_Date Current_4th_Quarter_End_Date Last_1st_Quarter_Start_Date Last_1st_Quarter_End_Date Last_2nd_Quarter_Start_Date Last_2nd_Quarter_End_Date Last_3rd_Quarter_Start_Date Last_3rd_Quarter_End_Date Last_4th_Quarter_Start_Date Last_4th_Quarter_End_Date Next_1st_Quarter_Start_Date Next_1st_Quarter_End_Date Next_2nd_Quarter_Start_Date Next_2nd_Quarter_End_Date Next_3rd_Quarter_Start_Date Next_3rd_Quarter_End_Date Next_4th_Quarter_Start_Date Next_4th_Quarter_End_Date Then based on TODAY'S date Current_Fiscal_Quarter - result will be 1, 2, 3,or 4 Don -- 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] Fiscal Years and Quarters
Is there any way to get rid of, whatever wet behind the ears person whom has this spam return for every post. mytr...@mail.ua I get 3 and 4 of these for every reply, I am sure anyone who is posting to the list gets the same emails. -Original Message- From: Don Wieland [mailto:d...@pointmade.net] Sent: Tuesday, October 19, 2010 7:12 PM To: php-general@lists.php.net Subject: [PHP] Fiscal Years and Quarters Hello, I have a preference field called "Fiscal_Year_Start_Month" which has the Month Names as options. Based on this value, I need to calculate the following date in UNIX: Current_1st_Quarter_Start_Date Current_1st_Quarter_End_Date Current_2nd_Quarter_Start_Date Current_2nd_Quarter_End_Date Current_3rd_Quarter_Start_Date Current_3rd_Quarter_End_Date Current_4th_Quarter_Start_Date Current_4th_Quarter_End_Date Last_1st_Quarter_Start_Date Last_1st_Quarter_End_Date Last_2nd_Quarter_Start_Date Last_2nd_Quarter_End_Date Last_3rd_Quarter_Start_Date Last_3rd_Quarter_End_Date Last_4th_Quarter_Start_Date Last_4th_Quarter_End_Date Next_1st_Quarter_Start_Date Next_1st_Quarter_End_Date Next_2nd_Quarter_Start_Date Next_2nd_Quarter_End_Date Next_3rd_Quarter_Start_Date Next_3rd_Quarter_End_Date Next_4th_Quarter_Start_Date Next_4th_Quarter_End_Date Then based on TODAY'S date Current_Fiscal_Quarter - result will be 1, 2, 3,or 4 Don -- 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] Weird Behavior
Hm I guess the little person inside, just hates the long way of doing something. My suggestion $CD = 1287583899; $q1s = 1283313600; $q1e = 1291093200; $q2s = 1291179600; $q2e = 1298869200; $q3s = 1298955600; $q3e = 1306814400; $q4s = 1306900800; $q4e = 1314763200; for($a=1; $a<=4; $a++) { $sSQ = "q".$a."s"; $eSQ = "q".$a."e"; if(($CD >= $$sSQ) && ($CD <= $$eSQ)){ $qCUR = "$a";} } echo $qCUR; The result is 1 Richard L. Buskirk -Original Message- From: Don Wieland [mailto:d...@dwdataconcepts.com] Sent: Wednesday, October 20, 2010 10:35 AM To: php-general@lists.php.net Subject: [PHP] Weird Behavior Little help please ;) $CD = 1287583899 $q1s = 1283313600 $q1e = 1291093200 $q2s = 1291179600 $q2e = 1298869200 $q3s = 1298955600 $q3e = 1306814400 $q4s = 1306900800 $q4e = 1314763200 Why does the following not return the value "1" in the $qCur var // Current Quarter if($CD >= $q1s && $CD <= $q1e) $qCur = 1; if($CD >= $q2s && $CD <= $q2e) $qCur = 2; if($CD >= $q3s && $CD <= $q3e) $qCur = 3; if($CD >= $q4s && $CD <= $q4e) $qCur = 4; it returns "4" Don Wieland -- 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] questions about if statements regarding a checkbox
If check it will submit the value of 'on' So If($_POST['test'] == "on') { Do this }else{ Do this } Richard L. Buskirk -Original Message- From: Ben Brentlinger [mailto:b...@benbrent.com] Sent: Saturday, October 30, 2010 10:05 PM To: php-general@lists.php.net Subject: [PHP] questions about if statements regarding a checkbox hello, I'd like to know the proper code to use in a php script that processes a form with a checkbox in order to send one email if the checkbox has been checked and another email if the checkbox hasn't. I tried if($check == true) and I tried putting the word "true" in double quotes, and both of them caused the "unexpected variable" syntax error. The only problem is, all I could think to use was that line of code I just used, I'm not sure what the proper syntax is for checkbox when using the if statement to send one email when the checkbox is checked and a different email when it's not checked. I'm wanting to send an email to the site admin with the information given by the person who filled out the form that contains the checkbox. Thanks, Ben -- 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] questions about if statements regarding a checkbox
I tested your code and besides adding a form to the beginning it works. If you want to see the results of the posted for try. print_r($_POST); you can see every position of the array passed and validate they are passing as intended. Try this. //if reallife is not set (Checked it will not pass) // I am pretty sure I read where someone had responded with the isset if(isset($_POST['reallife'])) { print_r($_POST); } Richard L. Buskirk -Original Message- From: Ben Brentlinger [mailto:b...@benbrent.com] Sent: Sunday, October 31, 2010 8:26 AM To: php-general@lists.php.net Subject: Re: [PHP] questions about if statements regarding a checkbox Here's the code I'm using with the exception of the php tags and the redirect script that redirects to another page once the form is submitted. This is just a test script I'm working on in order to teach myself php. The php portion will be posted first, than the html form related to the php. I've got the code inside tags similar to the "code" tag which only serves to serarate the php code from the html form. [php_code] $name = $_POST['firstname'] . ' ' . $_POST['lastname']; $email = $_POST['email']; if($_POST['reallife'] == "on") { $to = 'b...@benbrent.com'; $subject ='test email one'; $msg = "$name has filled out the test form. \n" . "this is just a test message"; mail ($to, $subject, $msg, 'From:' . $email); } else { $to = 'b...@benbrent.com'; $subject ='test email two'; $msg = "$name has filled out the test form." ; mail ($to, $subject, $msg, 'From:' . $email); } if($_POST['reallife'] == "on") { $to = '$email'; $subject = "Thank you email number one"; $msg = "hello $name, \n" . "thank you for filling out the form. \n" . "This is the first of two test emails \n" . "The second would have been sent \n" . "if you had left the checkbox unchecked \n"; mail ($to, $subject, $msg, 'From:' . $...@benbrent.com); } header ("location:thankyoupage") [/php_code] [html_code] Contact Form Email: First Name: Last Name: I know you in real life [/html_code] This actual code that is on the portion of my hosting account which I use as my test server. In my opinion, it's much cheaper to pay for a hosting account to use as a test server to teach myself php than it is to pay some collage professor to teach it to you only to be slapped in the face by having him assume you're learning php to be a freelance coder working for a company that does freelance work. The truth is, I only have an interest in learning php to use in my own business and when I get good enough, I may do some freelancing on the side on sites like Scriptlance, but my main focus will be my own business and for anyone to have the audacity that I plan on working for someone else my whole life pisses me off, so that's why I'd much rather teach myself than to take a college class on php. Thanks, Ben -- 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] questions about if statements regarding a checkbox
I placed an example of your code on my site. I simply pasted exactly what you had, minus the actual mailing portion. If you check the box you will see the array, if you do not check the box no array. http://www.richardbuskirk.com/blunk.php Forgive my prior post, I had not woke up yet. So the wording is missing things though, yet not put to email mid sentence. Code from site. Contact Form Email: First Name: Last Name: I know you in real life Richard L. Buskirk -Original Message- From: ad...@buskirkgraphics.com [mailto:ad...@buskirkgraphics.com] Sent: Sunday, October 31, 2010 10:37 AM To: 'Ben Brentlinger'; php-general@lists.php.net Subject: RE: [PHP] questions about if statements regarding a checkbox I tested your code and besides adding a form to the beginning it works. If you want to see the results of the posted for try. print_r($_POST); you can see every position of the array passed and validate they are passing as intended. Try this. //if reallife is not set (Checked it will not pass) // I am pretty sure I read where someone had responded with the isset if(isset($_POST['reallife'])) { print_r($_POST); } Richard L. Buskirk -Original Message- From: Ben Brentlinger [mailto:b...@benbrent.com] Sent: Sunday, October 31, 2010 8:26 AM To: php-general@lists.php.net Subject: Re: [PHP] questions about if statements regarding a checkbox Here's the code I'm using with the exception of the php tags and the redirect script that redirects to another page once the form is submitted. This is just a test script I'm working on in order to teach myself php. The php portion will be posted first, than the html form related to the php. I've got the code inside tags similar to the "code" tag which only serves to serarate the php code from the html form. [php_code] $name = $_POST['firstname'] . ' ' . $_POST['lastname']; $email = $_POST['email']; if($_POST['reallife'] == "on") { $to = 'b...@benbrent.com'; $subject ='test email one'; $msg = "$name has filled out the test form. \n" . "this is just a test message"; mail ($to, $subject, $msg, 'From:' . $email); } else { $to = 'b...@benbrent.com'; $subject ='test email two'; $msg = "$name has filled out the test form." ; mail ($to, $subject, $msg, 'From:' . $email); } if($_POST['reallife'] == "on") { $to = '$email'; $subject = "Thank you email number one"; $msg = "hello $name, \n" . "thank you for filling out the form. \n" . "This is the first of two test emails \n" . "The second would have been sent \n" . "if you had left the checkbox unchecked \n"; mail ($to, $subject, $msg, 'From:' . $...@benbrent.com); } header ("location:thankyoupage") [/php_code] [html_code] Contact Form Email: First Name: Last Name: I know you in real life [/html_code] This actual code that is on the portion of my hosting account which I use as my test server. In my opinion, it's much cheaper to pay for a hosting account to use as a test server to teach myself php than it is to pay some collage professor to teach it to you only to be slapped in the face by having him assume you're learning php to be a freelance coder working for a company that does freelance work. The truth is, I only have an interest in learning php to use in my own business and when I get good enough, I may do some freelancing on the side on sites like Scriptlance, but my main focus will be my own business and for anyone to have the audacity that I plan on working for someone else my whole life pisses me off, so that's why I'd much rather teach myself than to take a college class on php. Thanks, Ben -- 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with "shell_exec"
It seems most probably a permission problem. If I were you I would check the permissions on the bin directory and the files in it. PHP will probably run under the uid of the webserver, which, on most systems is either "apache" or "nobody" depending on the configuration. Richard L. Buskirk -Original Message- From: Boyan Penev [mailto:boyan...@googlemail.com] Sent: Sunday, October 31, 2010 11:16 AM To: php-general@lists.php.net Subject: [PHP] Problem with "shell_exec" Hello, i have installed php 5.2.14 on an embedded system. I have run a couple of test scripts and everything works fine, but i can't get "shell_exec" to work. When i invoke "shell_exec", the script doesn't get interpreted, instead i get prompted to download the whole .php file. I have tried both /bin/php and /bin/php-cgi- same problem. When i try to execute it per command line instead of web server, with both php and php-cgi i get "Segmentation fault" and nothing happens. I use busybox http as a web server, if it's relevant. Does anybody have an idea what the problem might be? Any help would be appreciated. Best regards, Boyan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with "shell_exec"
After going over this a thousand times in my head and on sever. Here are a few reasons why a shell_exec will not function. First I tested the PHP CLI Can I see my version of php. $output = shell_exec('php -v'); Echo $output; If I am not getting the information about the php version. Is shell_exec for php and http on? In your php.ini file there will be a section called disable_functions. If you are sure that shell_exec is not in the list. If neither of these are an issue for you, It has to be a permissions issue. I do not claim to be an expert in the shell_exec area of php, I cannot duplicate your error. Richard L. Buskirk -Original Message- From: Boyan Penev [mailto:boyan...@googlemail.com] Sent: Sunday, October 31, 2010 12:26 PM To: ad...@buskirkgraphics.com Cc: php-general@lists.php.net Subject: Re: [PHP] Problem with "shell_exec" Hello Richard, thank you for the prompt reply. I just tried to follow your suggestion, but i couldn't solve my problem: 1. I have started the server with user "nobody". All the binaries i was trying to execute(e.g. /bin/ls) were "chown"-ed to the user "nobody" Problem presisted. Than i "chown" -ed /var/www to the user "nobody". Than the php and php-cgi interpreters as well- same thing. I tried the same with users "adm" and even "root" 2. I than gave the executables all the permissions possible("777"- i know it is dangerous, but i am just testing)- still nothing. I copied the binaries from /bin to /var/www and tried to execute them with all kinds of permissions and "chown"'s- didn't work 3. Than i moved to the command line interpreter: i tried to execute it in /var/www and in the home folder. The permissions were also adjusted. I executed it with root privileges- i always get "Segmentation fault". One more thing- if i omit the arguments in shell_exec( "$output = shell_exec();) i get "Missing parameters" but no "Segmentation fault" Boyan On Sun, Oct 31, 2010 at 4:34 PM, wrote: > It seems most probably a permission problem. If I were you I would > check the permissions on the bin directory and the files in it. PHP > will probably run under the uid of the webserver, which, on most > systems is either "apache" or "nobody" depending on the configuration. > > Richard L. Buskirk > > > -Original Message- > From: Boyan Penev [mailto:boyan...@googlemail.com] > Sent: Sunday, October 31, 2010 11:16 AM > To: php-general@lists.php.net > Subject: [PHP] Problem with "shell_exec" > > Hello, > > i have installed php 5.2.14 on an embedded system. I have run a couple of > test scripts and everything works fine, > but i can't get "shell_exec" to work. When i invoke "shell_exec", the > script doesn't get interpreted, instead > i get prompted to download the whole .php file. I have tried both /bin/php > and /bin/php-cgi- same problem. > When i try to execute it per command line instead of web server, with both > php and php-cgi i get "Segmentation fault" > and nothing happens. I use busybox http as a web server, if it's relevant. > Does anybody have an idea what the problem > might be? Any help would be appreciated. > > Best regards, > > Boyan > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] updating sub-request parameters
So let me get this straight. Your script.php has all the passed variable positions of $_GET? Once it has passed you want to change the value? You can change the value of a $_GET very easy. If(isset($_GET['param1'])) { $_GET['param1'] == "no Chew"; } By changing the global value or using filters on the global values of $_GET. I have created a similar script only to mess with the $_GET variables. If(isset($_GET['param1'])) { $_GET['param1'] = mysql_real_escape_string($_GET['param1']); // you can create $_GET variables like so. $_GET['moo_cow'] = mysql_real_escape_string($_GET['param1']); } I hope I have answered your question. Richard L. Buskirk -Original Message- From: Daniela Floroiu [mailto:dani.flor...@googlemail.com] Sent: Monday, November 01, 2010 10:21 AM To: php-general@lists.php.net Subject: [PHP] updating sub-request parameters hi, I need to make an apache sub-request like: virtual('.../script.php?param1=val1¶m2=val2...'); where the parameters are different from the parameters of the original request. I tried to set param1 and param2 in $_GET, $_REQUEST, $_SERVER['QUERY_STRING'] but without success: what script.php receives are nothing less and nothing more than the original parameters with the original values. any ideea how one could touch the parameters being passed to a sub-request? cheers, --df -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to code in PHP an onchange event in a ?
OnChange is Javascript. I might suggest you get yourself familiar with JQuery. JQuery makes your life a lot easier when there is a need for client browser interaction with site scripting. Richard L. Buskirk From: Tomás Corrales Lemoine [mailto:to...@hog.ecasa.avianet.cu] Sent: Thursday, November 04, 2010 4:23 PM To: php-general@lists.php.net Subject: [PHP] How to code in PHP an onchange event in a ? Hi, List, I have this two files (index.php and include.php). They both work fine, but I want to substitute the code for de onchange event in the tag. Can I use PHP to code this event? How? Thanks. index.php: '; include_once 'include.php'; $mysql_link = tcl_MySQL_ConnectToServer('localhost', 'user', 'password'); tcl_MySQL_OpenDataBase($mysql_link, 'production'); $query = 'SELECT DISTINCT recipe.product_id, product.description FROM recipe, product WHERE recipe.product_id = product.product_id ORDER BY product.description'; $result = tcl_MySQL_DataQuery($mysql_link, $query); tcl_FillComboBox($result, 'Product', 'product_id', 'description', 'alert(\'Alert Message\')'); tcl_MySQL_CloseConnection($mysql_link); echo ''; ?> include.php: User '.strtoupper($user).' connected to MySQL server.'; return $link; } function tcl_MySQL_DataQuery($link, $query) { return mysql_query($query, $link); } function tcl_MySQL_OpenDataBase($link, $database) { mysql_select_db($database, $link); } function tcl_FillComboBox($result, $label, $col1, $col2, $onchange) { echo ''.$label.''; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo ''.$line[$col2]; } echo ''; } ?> -- Aeropuerto Internacional Frank País García de Holguín.
RE: [PHP] Updating a GET variable
No, Try this. ?&lang=en'>Flip Dear god, why would you butcher php like that? I, like many prefer short code or at least concat the string. Flip Richard L. Buskirk -Original Message- From: Marc Guay [mailto:marc.g...@gmail.com] Sent: Tuesday, November 09, 2010 3:48 PM To: a...@ashleysheridan.co.uk Cc: php-general Subject: Re: [PHP] Updating a GET variable > What's wrong with just putting the url parameters in the link that you know > you need, one by one? I have a footer that I include on every page and would like it to adapt to whatever situation it finds itself in. Is your suggestion, to do the following for the existing example: echo "Flip< /a>"; > Also, don't just output the values sent to the server, as that's an attack waiting to happen. Are you referring to echoing the SCRIPT_NAME and QUERY STRING values into the href attribute? -- 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] PHP loop to issue sql insert
Example: $simple = "select count(*) as count, searchkeywords from searchtable group by searchkeywords order by count desc"; $stuff = mysql_query($simple); If(mysql_num_rows($stuff) >= 1) { While($toarray = mysql_fetch_assoc($stuff)) { $doit = mysql_query("INSERT INTO mytable (count, color) values ('$toarray[count]', '$toarray[searchkeywords]')"); Echo mysql_error(); } } I am not sure why, don't care. Here is a very simple pull from this table insert into this table with the looped data. Richard L. Buskirk -Original Message- From: Simon J Welsh [mailto:si...@welsh.co.nz] Sent: Sunday, November 14, 2010 8:16 PM To: Rick Dwyer Cc: php-general@lists.php.net Subject: Re: [PHP] PHP loop to issue sql insert On 15/11/2010, at 12:47 PM, Rick Dwyer wrote: > Hello List. > > I have a sql command that counts, groups and sorts data from a table. I need to insert the results of that sql command into different table. > > My sql SELECT looks like this: > > select count(*) as count, searchkeywords from searchtable group by searchkeywords order by count desc; > > and returns records like this: > > 578 green > 254 blue > 253 red > 253 yellow > 118 orange > etc. > > My PHP looks like this so far: > > $sql = "select count(*) as count, searchkeywords from searchtable group by searchkeywords order by count desc"; > $result = @mysql_query($sql,$connection) or die("Couldn't execute checkcat query"); > $num = mysql_num_rows($result); > echo $num; > > > The echo is of course returning the total number of records not data as listed above. > > I know a WHILE statement is to be used here, but can't get it to work. > > How do I loop through the above found data, inserting each value as like this: > > insert into mytable (count, color) values ("578", "green"); > insert into mytable (count, color) values ("254", "blue"); > ...etc > > > > Thanks, > > > --Rick Personally I'll get MySQL to do it for me using: insert into mytable (count, color) select count(*) as count, searchkeywords from searchtable group by searchkeywords order by count desc (see http://dev.mysql.com/doc/refman/5.1/en/insert-select.html for more information on INSERT ... SELECT) Otherwise, you'll want to use mysql_fetch_assoc($result). Examples and information can be found at http://php.net/mysql_fetch_assoc --- Simon Welsh Admin of http://simon.geek.nz/ Who said Microsoft never created a bug-free program? The blue screen never, ever crashes! http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e -- 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] smary assign var
Taking what I understand from C, I think you are looking for this equivalent in php. $product = array('reduction'=>'4','price_without_reduction'=>'22','price '=>'18') $yuzde = $product['reduction']*100; $yuzde = round($yuzde / $product['price_without_reduction']); Echo $yuzde; This is no reason to truncate or escape html since the strings do not contain them. I might suggest you read http://www.php.net/manual/en/function.round.php for a better understand the precision options with round. Richard L. Buskirk -Original Message- From: Tontonq Tontonq [mailto:root...@gmail.com] Sent: Thursday, November 18, 2010 6:59 PM To: PHP General Mailing List Subject: [PHP] smary assign var hi guys i have 2x sub value [reduction] => 4 [price_without_reduction] => 22 [price] => 18 and i want to calculate how much i did reduction percent {assign var='yuzde' value=$product.reduction*100} {assign var='yuzde' value=$yuzde/$product.price_without_reduction} -{$yuzde|truncate:3:''|escape:'htmlall':'UTF-8'}% when i escape only 3 chars i see some products returns like "-18.%" when i escape only 2 chars i get e result like "-5.%" so is there a way to round that value to int not float? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] MySQL Query Help
Since we are just tossing out development environments. We moved to Aptana in conjunction with TortoiseSVN for a team environment development timelines dropped. Personally I do not feel any gui editor makes you a better programmer, maybe you understand the fundamentals a little less. Not that anything so far has been an answer to your question. Developing mysql statements that not only require minimum resources but that are highly effective. Take a lot of trial and error. I feel there is no better tool in my mind to test query concepts than NaviCat. Not only is the product very user friendly but as a senior developer it gives me more insight into the impact the query has on my servers. Always think longevity of the product you are producing. Imagine one day you have 650,000 products how will the query impact the service you have written. I feel as a certified MySQL DBA you should understand that what works today may NOT be the best choice in query statements for the future. Always analyze your query statements for query length and system resources requirements. Depending on the structure of your database/tables/fields your query may be achieved many different ways. I might suggest you try an extended select statement. "SELECT product from sometable WHERE product='$array1' AND product=(SELECT product_name from sometable where other matching critera)"; By extending or what some may call concating the statement the return is more effective. Richard L. Buskirk -Original Message- From: Ben Miller [mailto:biprel...@gmail.com] Sent: Saturday, November 20, 2010 3:54 PM To: 'php-general' Subject: [PHP] MySQL Query Help Hi, I'm building a website for a client in which I need to compare their products, side-by-side, but only include criteria for which all selected products have a value for that criteria. In my database (MySQL), I have a tables named "products","criteria" and "criteria_values" If I have something like $selected_product = array("1"=>"Product 1","2"=>"Product 2"...) // All products selected for comparison by the user I need to get only rows from "criteria" where there is a row in "criteria_values" matching "criteria.criteria_id" for each $selected_product - in other words, if any of the $selected_product does not have a row in "criteria_values" that matches "criteria.criteria_id", that criteria would not be returned. I hope that makes sense. I've played around with a few join queries, but none have given the desired results. Best I've been able to come up with so far is to query "criteria" for each DISTINCT(criteria_id) and then run through each $selected_product to make sure each has a criteria_value with a matching criteria_id, eliminating any criteria where the number of criteria_values < count($selected_product), but this seems pretty inefficient. Thanks in advance for any help. Ben Miller -- 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] curl and variable parameters in hyperlink
Depending on how the website is setup you can curl or soap parameters. http://www.php.net/manual/en/book.curl.php http://www.php.net/manual/en/book.soap.php Richard L. Buskirk -Original Message- From: Bob Keightley [mailto:bob.keight...@virgin.net] Sent: Tuesday, November 23, 2010 9:12 PM To: php-general@lists.php.net Subject: [PHP] curl and variable parameters in hyperlink First use of Curl so probably a very simple problem - I have a script which loads a third party web page into my site. That page contains links which have variable parameters i.e. www.blahblah.asp?param1=xxx¶m2=yyy. Any clues as to what I need to do to pass these parameters in a curl script appreciated. -- 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] how can one run python script in php
Try CURL http://www.php.net/manual/en/book.curl.php Richard L. Buskirk -Original Message- From: Moses [mailto:jam...@gmail.com] Sent: Wednesday, December 08, 2010 5:51 PM To: php-general@lists.php.net Subject: [PHP] how can one run python script in php Hi Everyone, I am trying to run a python script in php using exec or system command, but there is no answer. musa -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Regex for telephone numbers
I suggest you try javascript. Richard L. Buskirk -Original Message- From: Ethan Rosenberg [mailto:eth...@earthlink.net] Sent: Wednesday, December 29, 2010 7:12 PM To: php-db-lists.php.net; php-general@lists.php.net Subject: [PHP] Regex for telephone numbers 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-. Thanks. Ethan MySQL 5.1 PHP 5 Linux [Debian (sid)] -- 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] Regex for telephone numbers
Also remove your stupid Email filter. If you need a email filter, you should not be on this list or learn to setup rules one. Richard L. Buskirk -Original Message- From: Ethan Rosenberg [mailto:eth...@earthlink.net] Sent: Wednesday, December 29, 2010 7:12 PM To: php-db-lists.php.net; php-general@lists.php.net Subject: [PHP] Regex for telephone numbers 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-. Thanks. Ethan MySQL 5.1 PHP 5 Linux [Debian (sid)] -- 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] Newbie Question
Add this to your .htaccess file and HTML files will be handled like PHP files allowing you put PHP in HTML files. AddType application/x-httpd-php .html Richard L. Buskirk -Original Message- From: Adolfo Olivera [mailto:olivera.ado...@gmail.com] Sent: Saturday, January 01, 2011 8:38 PM To: Joshua Kehn Cc: robl...@aapt.net.au; php-general@lists.php.net Subject: Re: [PHP] Newbie Question Sorry, here is the code. The .php extension is a requirement? Can't it b embedded on a .html file? http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml";> Untitled Document On Sat, Jan 1, 2011 at 9:55 PM, Joshua Kehn wrote: > On Jan 1, 2011, at 7:50 PM, David Robley wrote: > > > > And normally would need to be saved as a .php file so the contents will > be > > handled by php. > > > > > > Cheers > > -- > > David Robley > > > > A fool and his money are my two favourite people. > > Today is Boomtime, the 2nd day of Chaos in the YOLD 3177. > > Save the code as hello.php. Copy it to your root web directory (should be > the base directory or something called public_html / www when you FTP in) > and access it from youdomain.com/hello.php > > Regards, > > -Josh > > Joshua Kehn | josh.k...@gmail.com > http://joshuakehn.com > > -- Adolfo Olivera 15-3429-9743 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Newbie Question
The question was "The .php extension is a requirement?" The answer is no. While me and Ash may completely disagree on the php parser, the simple answer is there are many ways around running a non .php extension file in php. mod_rewrite rules in .htaccess files are interpreted for each request and CAN slow down things if your traffic is high. Having said that, mod_rewrite in httpd.conf is faster because it is compiled at server restart and it is native to the server. As a beginner, I completely agree with ash on bad practice rule of thumb. You will simply rewrite the html file later on wishing you had never did the hack to make it function. Richard L. Buskirk -Original Message- From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Sunday, January 02, 2011 12:16 PM To: ad...@buskirkgraphics.com Cc: 'Adolfo Olivera'; 'Joshua Kehn'; robl...@aapt.net.au; php-general@lists.php.net Subject: RE: [PHP] Newbie Question On Sun, 2011-01-02 at 11:48 -0500, ad...@buskirkgraphics.com wrote: > Add this to your .htaccess file and HTML files will be handled like PHP > files allowing you put PHP in HTML files. > > AddType application/x-httpd-php .html > > > Richard L. Buskirk > > -Original Message- > From: Adolfo Olivera [mailto:olivera.ado...@gmail.com] > Sent: Saturday, January 01, 2011 8:38 PM > To: Joshua Kehn > Cc: robl...@aapt.net.au; php-general@lists.php.net > Subject: Re: [PHP] Newbie Question > > Sorry, here is the code. The .php extension is a requirement? Can't it b > embedded on a .html file? > > http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml";> content="text/html; charset=utf-8" /> Untitled Document >$hello; ?> > On Sat, Jan 1, 2011 at 9:55 PM, Joshua Kehn wrote: > > > On Jan 1, 2011, at 7:50 PM, David Robley wrote: > > > > > > And normally would need to be saved as a .php file so the contents will > > be > > > handled by php. > > > > > > > > > Cheers > > > -- > > > David Robley > > > > > > A fool and his money are my two favourite people. > > > Today is Boomtime, the 2nd day of Chaos in the YOLD 3177. > > > > Save the code as hello.php. Copy it to your root web directory (should be > > the base directory or something called public_html / www when you FTP in) > > and access it from youdomain.com/hello.php > > > > Regards, > > > > -Josh > > > > Joshua Kehn | josh.k...@gmail.com > > http://joshuakehn.com > > > > > > > -- > Adolfo Olivera > 15-3429-9743 > > It's really best not to think about embedding PHP in an HTML file, as that isn't really how it works and it just encourages bad practices. HTML is embedded inside PHP files, not the other way around. The PHP parser interprets all the PHP code and creates the necessary output, and passes that output along with any HTML to the web server to then deliver to the client (browser). If you embedded PHP inside HTML files, the web server would have to call up the PHP parser every time you broke in and out of PHP tags, which wouldn't do at all! I wouldn't recommend having .html parsed as PHP though, as it will slow down your website/application unnecessarily for any .html files that contain no PHP code, as PHP still has to parse the file for any code, even if there is none. Leave .html files for static pages that you produce with a PHP app for example, or use MOD_REWRITE to reference PHP scripts when certain .html files are requested by the browser, as this can be a whole lot more specific and selective and won't introduce problems later on. Thanks, Ash http://www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sorting Help
-Original Message- From: Floyd Resler [mailto:fres...@adex-intl.com] Sent: Wednesday, April 11, 2012 11:26 AM To: PHP Subject: [PHP] Sorting Help I need to sort the following array: { [Smith, Bob]=>array(137.5,125.5), [Jones, Robert]=>array(132.7,128.2) } The array needs to be sorted by the first number (i.e. 137.5) and then the second in descending order. I looked at array_multisort but couldn't figure out how to make work for my needs. Thanks! Floyd Do me a favor and copy a print_r of your array because this I can't figure out what you're are doing with that. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Sorting Help
-Original Message- From: Floyd Resler [mailto:fres...@adex-intl.com] Sent: Wednesday, April 11, 2012 11:26 AM To: PHP Subject: [PHP] Sorting Help I need to sort the following array: { [Smith, Bob]=>array(137.5,125.5), [Jones, Robert]=>array(132.7,128.2) } The array needs to be sorted by the first number (i.e. 137.5) and then the second in descending order. I looked at array_multisort but couldn't figure out how to make work for my needs. Thanks! Floyd Here is what I did to your array $test = array("Smith, Bob"=>array(137.5,125.5),"Jones Robert"=>array(132.7,128.2)); asort($test); print_r(''); print_r($test); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Blocking URL hacking attemps
-Original Message- From: sono...@fannullone.us [mailto:sono...@fannullone.us] Sent: Sunday, April 22, 2012 12:55 PM To: PHP General Subject: [PHP] Blocking URL hacking attemps I'm using a script called BlackHole that uses PHP and a "hidden" directory to catch bad bots and block them by their IP address from the site [http://perishablepress.com/blackhole-bad-bots/]. It's working very well, but I'd like to expand on the idea. When looking at our access logs, I see someone "adding code" to our URL's in hopes to, apparently, hack into our site. If our URL is like this: http://www.example.com/pages/bolts.php they are adding to it like this: http://www.example.com/pages/bolts.php/wp-content/themes/functions/thumb.php .cache/external_e19f4bb51bc2262e07d23b79b916c12c.php or http://www.example.com/pages/bolts.php/cart.php or http://www.example.com/pages/bolts.php/wp-content/themes/functions/thumb.php timthumb.php or http://www.example.com/pages/bolts.php/bratislava/stare-mesto Is there a way that I can trap the "extra" info in the URL's and pass it to the BlackHole script to ban these attempts as well? I'm thinking I'll need to compare the entered URL with $_SERVER["PHP_SELF"] and if there's extra info, like another "*.php", after the page name, then ban the IP. I realize that's a rather simplistic explanation and there may be a better way to accomplish this. If anyone has any examples they can share, I'd really appreciate. Thanks, Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Marc, First I would suggest you look at htaccess or web.config depending on your flavor of OS. Examine the URL patterns and rewrite the URL appending to the string. This will allow you a little more control. I completely disagree on the blocking IP concept and this can lead to network latency and other issues, redirecting traffic is more efficient. I think the scare factor of products like black hole are really just that. Bots are not always a bad thing, when your server becomes more popular people are interested in content so controlling the bots is key. IP addresses can be spoofed and if you have an auto block this could be your undoing in the long run. Rick.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Insert group by
$sql='select count(*) as count, searchkeywords from searchkeywords group by searchkeywords having searchkeywords LIKE searchkeywords order by count desc' Ir this does not work for you explore the HAVING CLAUSE -Original Message- From: Rick Dwyer [mailto:rpdw...@earthlink.net] Sent: Thursday, April 26, 2012 8:23 PM To: PHP-General Subject: [PHP] Insert group by Hello all. This is more of a MySQL question, but I'm hoping it can be answered here. On one of my pages, I issue a SQL command to group data as such: $sql='select count(*) as count, searchkeywords from searchkeywords group by searchkeywords order by count desc' Works well... but I would like it to groups plurals with singular words as well. So "hats" are grouped with "hat". Since I'm doing a "group by" column name, I don't know that this can be done. Any help is appreciated. Thanks, --Rick -- 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] Array_diff problems
-Original Message- From: Rick Dwyer [mailto:rpdw...@earthlink.net] Sent: Friday, April 27, 2012 3:37 PM To: PHP-General Subject: [PHP] Array_diff problems Hello all. I have two arrays and when compared against each other via array_diff, I do not get any output: $myarray1 = Array ( [0] => Array ( [id] => 1 [Funding_Type] => Federal [Amount] => 10 [Frequency_Description] => Total [Other_Funding] => ) [1] => Array ( [id] => 2 [Funding_Type] => Trust [Amount] => 20 [Frequency_Description] => Per Year [Other_Funding] => ) [2] => Array ( [id] => 3 [Funding_Type] => Other Funding [Amount] => 30 [Frequency_Description] => Other [Other_Funding] => some )) $myarray2 = Array ( [0] => Array ( [id] => 1 [Funding_Type] => Federal [Amount] => 10 [Frequency_Description] => Total [Other_Funding] => ) [1] => Array ( [id] => 2 [Funding_Type] => Trust [Amount] => 20 [Frequency_Description] => Per Year [Other_Funding] => ) [2] => Array ( [id] => 3 [Funding_Type] => Other Funding [Amount] => 50 [Frequency_Description] => Other [Other_Funding] => none )) $arraydifferences = (array_diff($myarray1,$myarray2)); I need $arraydifferences to record the differences between the two. Any help is appreciated. Thanks, --Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I suggest you read Multidimensional array_diff for Nested Arrays and your format is not correct on the array that you gave an example of. http://www.php.net/manual/en/function.array-diff.php#98680 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] code deployment through php
-Original Message- From: Stuart Dallas [mailto:stu...@3ft9.com] Sent: Tuesday, May 01, 2012 8:19 AM To: rene7705 Cc: Camilo Sperberg; php-general Subject: Re: [PHP] code deployment through php On 1 May 2012, at 10:19, rene7705 wrote: > On Tue, May 1, 2012 at 11:11 AM, Camilo Sperberg wrote: > >> If I understood the problem correctly, you want to keep a single copy >> of your code on every machine you work, including the final server. >> >> > Well, I want to work on 1 copy of my common code on my windows > machine, then sync those changes to all my sites (hosted on the win > dev box) to see if it messes up the other sites, then FTP those > changes to my hosting account, and run the sync script there as well. > > >> Have you read about SVN ? You can set up a cronjob to execute it >> automatically if you want, there are clients for Windows, Zend >> Studio, etc etc. >> > > I've read about some source control systems, I've tried them out, but > I'd rather go for this simpler approach tbh. > I already do regular backups that are timestamped, it's enough for me > right now I think. If you really think rolling your own deployment system is simpler than using source control then I don't think you've understood all of the advantages of source control. I know it can look complicated, but it's really not, and it will make it far easier to keep track of what you're doing and what changes are deployed where than the system you described. I strongly recommend you reconsider. -Stuart -- Stuart Dallas 3ft9 Ltd http://3ft9.com/ Stuart, If I may add to your post Version control for different environments (Development and Production) is SO key with SVN. SVN has logging and other key features. Many, and when I say many that is an understatement, Many companies enforce SVN for their protection. Ever had a script not fully transfer, and only partial code remains? With SVN you can roll it back and Whala! You have the original source back. For one of my roles as Project Manager, I love Tortoise SVN. I have changed the scripting a bit to send me emails with descriptions of changes as they happen with attached files. This way I can actually filter my emails to find the exact person who made the bad change, what they had, and what they did instead of searching the logs. Since my developers can only push to the Development Servers I can fix issues before they become a Production Issue. No more, Developers having access to the server directly. They make their changes and commit their changes up, I review and can schedule changes to be committed to Production Servers. To setup a new Developer I simply check out the SVN library for them and they are up to speed day one. The setup is very easy, Yes the controls are a tiny bit confusing at FIRST. But if you want success, then SVN is a SMART decision for any project. Richard Buskirk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] I need a good access and error log..
-Original Message- From: rene7705 [mailto:rene7...@gmail.com] Sent: Monday, May 07, 2012 3:00 AM To: php-general Subject: [PHP] I need a good access and error log.. Hi. I've been using Google Analytics, and I'm sure I'm using the analytics code correctly, but when I checked my dev server's apache access logs (dozens of hits per day) against what Google Analytics reports (zip, zero, nada), I realized I needed something different. BTW, I'm not the only one to report this problem (https://www.google.nl/search?aq=f&sourceid=chrome&ie=UTF-8&q=google+analyti cs+lower+number) I thought of rolling something of my own, a PHP-MySQL based access+error log, add a viewer for it (http://dygraphs.com/ perhaps), and spend the next month perfecting it.. But before I start coding, I thought it would be better to ask you all what you use to see who's visiting your sites and when. Oh, I need something that will work on shared hosting (php+mysql). Thanks for your input. (and purists; I couldn't think of a better place to post this, as this is a large community of web developers who use the same language as I do. I may even end up writing an opensourced php logging facility for you) -- I have seen and dealt with this for a few companies. I have setup PHP scripting, JavaScript, Perl scripting you name it I have tried it. I have NEVER came up with the same number Google Analytics comes up with. Sporadic behavior from Analytics not tied to a unique browser, OS or time. Almost like random addition values are just added to the total for no reason. I like Google, but the numbers are not real! When I can track each and every visit, site navigation and the numbers do not match. I asked Google for click by click information IP, Time and any other information they could give me. I never got that list to this day. Probably because it would allow me to argue traffic that simply didnt happen! Suggestions when logging traffic, Avoid JavaScript that relies on the client side to tell you information. Bad Idea! Use php, perl or any server side language. When logging information remember that apache/.NET process web request and generally the best place to log. It you log at the process you do not need to have scripting in each landing page. Log light information, never request overwhelming amounts of information for each request you may cause horrid loading results. PHP example (Just a simple example, there are many ways to do it) Index.php I HIGHLY recommend you have a full understand of httaccess or web.config before you attempt logging from them. Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Best practice question regarding set_include_path()
-Original Message- From: Al [mailto:n...@ridersite.org] Sent: Thursday, May 10, 2012 11:44 AM To: php-general@lists.php.net Subject: [PHP] Best practice question regarding set_include_path() For my applications, I've been using includes and other file addressing by using the doc root as the base dir. e.g. require_once $_SERVER['DOCUMENT_ROOT'] . '/miniRegDB/includes/miniRegDBconfig.php'; Recently, I ran into a problem with a new installation on a shared host where the doc root was assigned in an unusual manner. I rather not require setting a custom base dir [instead of $_SERVER['DOCUMENT_ROOT']'] for my applications. So, I was wondering if it would be good practice to use the set_include_path() and add the base dir for my applications. I've used this for dealing with Pear function files on shared servers and had no problems. Need some guidance regarding this subject. Thanks -- I use define to set the application path define('BASE_PATH','C:\\inetpub\\vhosts\\yourwebsite.com\\httpdocs\\'); Example: require_once (BASE_PATH. '/miniRegDB/includes/miniRegDBconfig.php'); works great for JQuery paths $(document).ready(function() { $('#dareport').html(''); }); To me it is much better than set_include_path() but works in the same premise -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Time out issue
I am running Windows 2008 R2, IIS 7 I am running into an issue where no matter what I set the script time out to be the server is Giving me a 500 error after like 60 seconds when the process exceeds the configured activity timeout. Here is the example script I fully understand this may not be a PHP error but if anyone has ran into this issue with a windows server and can explain in detail how I can adjust the timeout, I would be very grateful. Everything I have read online points to a fcgiext.ini file that does not exist on my server. Anyone know how to help ?
RE: [PHP] Time out issue
-Original Message- From: Matijn Woudt [mailto:tijn...@gmail.com] Sent: Saturday, May 12, 2012 3:54 PM To: admin Cc: php-general@lists.php.net Subject: Re: [PHP] Time out issue On Sat, May 12, 2012 at 9:42 PM, admin wrote: > I am running Windows 2008 R2, IIS 7 > > I am running into an issue where no matter what I set the script time > out to be the server is > > Giving me a 500 error after like 60 seconds when the process exceeds > the configured activity timeout. > > > > Here is the example script > > > set_time_limit(120); > > sleep(100); > > Echo "PASSED THE TIME OUT"; > > ?> > > > > I fully understand this may not be a PHP error but if anyone has ran > into this issue with a windows server and > > can explain in detail how I can adjust the timeout, I would be very > grateful. > > Everything I have read online points to a fcgiext.ini file that does > not exist on my server. > > > > Anyone know how to help ? > Didn't use windows server in about 10 years (Go linux ;)), but did you try this? http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/44ebc761-ac76-4b44-8894-551c9315af6c.mspx - Matijn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I had to get Microsoft on the phone to resolve this issue with IIS and FAST-CGI seems you can adjust the Request Timeout and Activity Timeout within the IIS manager and for some reason no documentation leads you to this point. Sorry to bother issue resolved. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP]How to handle E_ERROR,E_PARSE with a user defined function
-Original Message- From: Yuchen Wang [mailto:phob...@gmail.com] Sent: Tuesday, May 22, 2012 10:19 PM To: php-general Maillist Subject: [PHP]How to handle E_ERROR,E_PARSE with a user defined function Hi all, How to handle E_ERROR,E_PARSE with a user defined function ? -- *Yuchen Wang* I suggest you try http://www.php.net/set_error_handler -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] w.r.t. mail() function
-Original Message- From: Ashwani Kesharwani [mailto:ashwani.kesharw...@gmail.com] Sent: Wednesday, May 23, 2012 12:13 AM To: php-general@lists.php.net Subject: [PHP] w.r.t. mail() function Hi , I have a query w.r.t. mail() function in php. I have hosted my site and i have created an email account as well. when i am sending mail to different recipient from my php script using above function it is getting delivered to respective recipients as expected. However if I want to see those mail in the sent folder of my email account , i can not see those mails there. How can I achieve this. Any suggestions. Regards Ashwani - You can change the settings of sendmail http://www.devshed.com/c/a/Administration/Getting-Started-with-Sendmail/12/ OR You can log text or database each email. $query = "INSERT INTO mail_log (`subject`,`to`,`from`,`message`,`mail_date`) values ('".mysql_real_escape_string( $subject )."', '".mysql_real_escape_string( $to )."', '".mysql_real_escape_string( $from )."', '".mysql_real_escape_string( $message )."', '".date("Y-m-d H:i:s")."') "; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] What is The best way/tool for debuging PHP?
-Original Message- From: LEOPARD Corporation [mailto:leopardonline@gmail.com] Sent: Saturday, May 26, 2012 12:02 PM To: php-general@lists.php.net Subject: Re: [PHP] What is The best way/tool for debuging PHP? Thanks for your reply. Dev-PHP is an IDE, and I don't need such tool because I'm using Eclipse, and I'm very comfortable with. what I really want to know is: what is the best "pure" debugging tool which its function is to debug PHP scripts and applications only. Thanks in advance! On Sat, May 26, 2012 at 6:03 PM, saeed ahmed wrote: > Dev-php > from > http://devphp.sourceforge.net/ > > 2012/5/26, LEOPARD Corporation : > > Hello, > > > > I'm new to this list, and this is the first time ever I send a > > message to you. > > > > I'm learning PHP since a couple of months, and I really wanna be a > > good > PHP > > programer, and I know that I should work hard for that. > > > > Now, I just wanted to know what is the best way or tool for debuging PHP. > > > > I have googled for this many many times, and found a lot of these > > stuff, but I didn't figure out which one is really the best. > > > > in fact, I don't care whether it's an easy way or hard way, all what > > I > want > > is to know what is the best and preferred way or tool. > > > > Wish you all the best! > > > Yes many IDE's are used when debugging php because they can simulate the environment needed for php. Not to promote them but VSPHP is an amazing product, as a standalone or integrated into Visual Studio 2010. I have enjoyed using this product for the last couple years. I am a HUGE Visual Studio advocate, when VSPHP came along I exclusively use VS and notepad to develop applications in. Is this the BEST product? No clue!! BUT: I can develop and Debug in different versions of PHP. I can integrate with any database, and I will (Toot the horn about) the ability to use global variables instant insert. Saves me time, headaches and I can search an entire project for every instance of variable and no need to open each page. I like the color markup and the debug options of stepping trough a segment of code for a real time analysis. To me it is the BEST tool on the market. I am a .NET PHP developer who switched over from 15+ years of Linux/Unix systems. Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Function size
-Original Message- From: Paul M Foster [mailto:pa...@quillandmouse.com] Sent: Wednesday, May 30, 2012 10:54 AM To: php-general@lists.php.net Subject: Re: [PHP] Re: Function size On Wed, May 30, 2012 at 04:31:12PM +0200, Sebastian Krebs wrote: [snip] > > If the functions were named properly you don't have to follow every > execution path to the deepest deep. Or do you reading PHPs C-source, > just because a wild "substr()" appeared? When you see a method "loadFromFile()" > and the IDE tells you, that it expects a $filename as parameter, why > should you jump there just to make sure, that the method loads > something from a file by the filename given as first parameter? Here's why, and I've seen this happen a *lot*. The function may be properly named, but have side effects. Or the guy who named the function *thought* it was properly named, but was wrong. For example, he may have named the function "loadFromFile()", and the function does in fact do that. What the name doesn't tell you is that it then erases the file from which it pulled. Oops! No, you're correct, the function is *not* properly named in that case. But the guy who wrote it thought it was. And before I look at the internals of the function, I don't know whether it's properly named or not. Worse, the side effects may not show up until later, and then with disasterous results. Imagine assuming everything's okay, patching your code into the system, and finding out that it's been hacking up the customer's filesystem for the last three weeks. All because you didn't check to see what that other function was *actually* doing. Rule: NEVER assume you know what a function is doing by looking at its name. ALWAYS satisfy yourself that you know what a function is doing by *looking* at what it's doing. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- That is WHY you put Function Definitions / Relations Rick. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] help with preg_match
-Original Message- From: Chris Purves [mailto:ch...@northfolk.ca] Sent: Sunday, June 03, 2012 8:26 PM To: php-general General Subject: [PHP] help with preg_match Hello, I am trying to use preg_match to match something from an html file. Within the html file is some text that looks like: Something, something end I know that the text ends 'end', but I don't know what the Something, something is. I am using preg_match as follows: preg_match('/[^>]*end/',$curl_response,$matches); I want to match 'end' and everything before it that is not '>'. The problem appears to be with the '>'. I have tried escaping (\>), but it didn't make a difference. The php script hangs when it tries to run this function. -- Chris Purves "There's a time to think, and a time to act. And this, gentlemen, is no time to think." - Sheriff Bud B. Boomer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- You could try this preg_match_all('/(]*>*)(.*)(]*>)/is',$curl_response,$matc hes); print_r($matches); Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Variable representation
-Original Message- From: Ron Piggott [mailto:ron.pigg...@actsministries.org] Sent: Thursday, June 21, 2012 3:47 AM To: php-general@lists.php.net Subject: [PHP] Variable representation I am trying to represent the variable: $row['Bible_knowledge_phrase_solver_game_question_topics_1'] Where the # 1 is replaced by a variable --- $i The following code executes without an error, but “Hello world” doesn’t show on the screen. What needs to change? Ron Ron Piggott www.TheVerseOfTheDay.info You can do this echo $row['Bible_knowledge_phrase_solver_game_question_topics_'.$i]; I would not suggest a variable name that long. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] slicing and dicing strings
Read http://php.net/manual/en/function.substr.php -Original Message- From: Kirk Bailey [mailto:kbai...@howlermonkey.net] Sent: Wednesday, June 27, 2012 6:15 PM To: php-general@lists.php.net Subject: [PHP] slicing and dicing strings ok, it slices and dices, but how? in python, to print all but the last char in string FOO, we say print FOO[:-1] But this seems to bark like a basset hound in php. Whyfore? Now tihs tyro is seeking sage words to help me understand this. RTFM is not sage words; if you don't want to help me please don't waste the bandwidth. Would anyone care to help me understand this without dedicating 4 precious and in over demand/under supply hours to RTFM? -- end Very Truly yours, - Kirk Bailey, Largo Florida kniht +-+ | BOX | +-+ think -- 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] slicing and dicing strings
-Original Message- From: Geoff Shang [mailto:ge...@quitelikely.com] Sent: Thursday, June 28, 2012 5:12 AM To: php-general@lists.php.net Subject: Re: [PHP] slicing and dicing strings On Wed, 27 Jun 2012, tamouse mailing lists wrote: > RTFM with no hint of where to look is a problem. But the dictum of > "Read here in the manual" will surely be the best thing. You will then > know where to look for future questions. Personally, I've got better things to do with my time than spend it committing the syntax and semantics of every single PHP function to memory. I nearly always have the php.net front page with its function search open in a browser whenever I'm writing something more than a few lines. The function search seriously rocks. Even if I can't remember which string function I want, I can search for *any* string function and I'll get the list of all of them, along with a quick summary to help me find the one I want. Geoff. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- Geoff, The function you are looking for is SUBSTR(); I understand you have the manual open and you think you can find the answer pretty quickly. Please understand that knowing a little, to advanced features of all functions will help you significantly. It will cut down on research time and you have a better understanding of what function will better fit the situation at hand. While some people will never fully remember all syntax of every function it never hurt anyone in attempting to understand a majority of PHP functionality. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Entry point of an MVC framework
-Original Message- From: Timmy Sjöstedt [mailto:m...@iostream.se] Sent: Thursday, July 12, 2012 6:01 PM To: php-general@lists.php.net Subject: Re: [PHP] Entry point of an MVC framework On 07/12/2012 11:44 PM, Daevid Vincent wrote: >> -Original Message- >> From: Simon Dániel [mailto:simondan...@gmail.com] >> Sent: Thursday, July 12, 2012 1:21 PM >> Subject: [PHP] Entry point of an MVC framework >> >> I have started to develop a simple MVC framework. > > Yeah! Just what PHP needs, another MVC framework > > NOT. > > Why are you re-inventing the wheel? > > Personally I *hate* frameworks with a passion, but if you're going to > use one, then why not just build with one that is already out there > and well supported. http://www.phpframeworks.com/ to start with. > > I would say this is a perfectly sane idea if one wants to learn how things actually work. Most frameworks, however, are very bloated because they have to support and implement many things, as they are general purpose frameworks used by everybody and their dogs. If you only want what you need, and you know how to do it, rolling your own system is no problem. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php - Timmy, Thank GOD someone said it. 99.999% of every MVC framework you can download is crammed to the hilt with BLOAT. I also agree that knowing/understanding a MVC framework is vital and sometimes the only way to learn is to recreate the madness you see in front of you. I like many people have created my OWN MVC framework customized to my madness and NO BLOAT!! I do suggest if you're starting out in MVC frameworks. You have a better understand of .htaccess and or web.conf for better control and flexibility. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] What do you call the end-user?
-Original Message- From: Tedd Sperling [mailto:t...@sperling.com] Sent: Thursday, July 19, 2012 1:27 PM To: php-general@lists.php.net General Subject: [PHP] What do you call the end-user? Hi gang: I can't wait for tomorrow -- so here's my off-topic post today. First question: What do you call the people who ultimately use your code? I call them the "end-user", but others have stated other terms, such as "customer" or "user". Second question: Are you concerned with their ("whomever") experience in using your code? This question transcends your code working correctly, accurately, and securely -- no need to comment on those aspects. But rather more specifically do you consider how easily your "whomever" can use your work efforts? As you may have guessed - I just attended a UX conference and they provide an interesting perspective on UX. I was wondering how php developers typically address the subject. Cheers, tedd t...@sperling.com http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php I call them the GUI between the Chair and the Key board (behind the scenes)! To their face/documented I call them the "End-user" I do however break this down into "tier level access users" depending on access desires. >From straw dog to functioning portal the (easy, flow, and navigation) is always designed for the most novice of users is HIGH priority. This area gets a little hairy with different levels of knowledge are concerns. Some want a point to point (Walk Trough scenario) and others want more complex features as options. Reports, in my mind the most complex portion of any development because of the mash of conceptual ideas of what the end product should look like. These areas are rarely novice compliant, because of the sheer complexity of filtering options desired. I stick to a "Canned Report" approach when dealing with novice end-users. My goal in life has been to develop the ultimate portal that thinks for you and less dependent on your interactions. I am close to finishing a learning module that learns from your interactions and navigates according to your past history. But that is for another time -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] What do you call the end-user?
-Original Message- From: Paul M Foster [mailto:pa...@quillandmouse.com] Sent: Thursday, July 19, 2012 6:31 PM To: php-general@lists.php.net Subject: Re: [PHP] What do you call the end-user? On Thu, Jul 19, 2012 at 01:26:50PM -0400, Tedd Sperling wrote: > Hi gang: > > I can't wait for tomorrow -- so here's my off-topic post today. > > First question: > > What do you call the people who ultimately use your code? > > I call them the "end-user", but others have stated other terms, such > as "customer" or "user". "User", because I'm writing the code for *my* customer. The person actually exposed to my code may or may not be a customer of anyone. They may simply be an internet surfer at my customer's site. > > Second question: > > Are you concerned with their ("whomever") experience in using your > code? > > This question transcends your code working correctly, accurately, and > securely -- no need to comment on those aspects. But rather more > specifically do you consider how easily your "whomever" can use your > work efforts? > > As you may have guessed - I just attended a UX conference and they > provide an interesting perspective on UX. I was wondering how php > developers typically address the subject. I'm interested in user experience to a limited extent. My interest stops when a user wants the code to wipe their nose for them. "Can we make the website automatically update our accounting system and then write a check for the cost of goods to the vendor? Sure. How much money do you have?" (Their accounting system is some inscrutable pile of Windows COM objects, like SAP, behind a firewall. And they don't even know which vendor to write the check to. I guess mental telepathy is a part of the PHP libraries not installed on my development system.) Or "when someone sends the form on the website for an appointment request, can you make a reminder pop up on all the desktops in the office? No, I can't. Here's an idea: assign someone to check the email for appointment requests throughout the day, and contact the customer to confirm, based on you actually *looking* at your appointment calendar." Sheesh. Apparently, computers (not mine) are capable of performing magic tricks. I think my screens should be fairly self-explanatory, if possible. But I'm averse to making them idiot-proof. If you're an idiot, get someone else to operate your computer for you. You shouldn't be using one. But there may be times when a computer screen or set of screens will absolutely require some training, rather than someone completely unfamiliar with the workings of the office just sitting down and being able to guess how to operate the system. You didn't learn to drive by just sitting in a car and guessing how it is done. Don't expect a web-based application to be operable simply by guessing, necessarily. By the way, I'm quite happy to write documentation for systems. Unfortunately, more than half the people who read anything can't actually *apply* what they read to whatever system they're working with. Supposedly they can read. But somehow they still need someone to explain it to them, no matter how good the docs are. Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php --- LOL Paul, You are so very spot on, I have a current customer who would like the website to just load when he logs in. I wish I had not agreed to writing him a startup script to load the interface for him because NOW he wants it to auto login for him. They use a random key generator as a portion on their login authentication. So let's see: The system sends you a report every hour on the hour. You no longer have to navigate to the interface. It auto logs into the system for you. I pander to these kind of people like there is no tomorrow when they are the ones who sign the check, because anything outside of scope cost BIG TIME. :) I have gone so far to create training aids that are system mimics to explain to them what they are doing wrong and what the next step is. I use to write SCO compliant learning systems and let me tell you there is NO such thing as idiot proof. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] get_browser error
Anyone using Get_browser() notice that IE 9 is reporting as IE 7? I am aware of compatibility mode in IE 9 but that should not change the version information sent will it?
RE: [PHP] Crash course
-Original Message- From: Lester Caine [mailto:les...@lsces.co.uk] Sent: Monday, August 20, 2012 6:52 AM To: php-general@lists.php.net Subject: [PHP] Crash course OK - MySQL is not an area I've had to bother with, but I'm trying to sort out a tranche of websites that 1&1 messed up the DNS on last week and we have take over support for. All the databases have backed up and been restored ... although after Firebird's backup and restore system having to dump the database as raw SQL ... that took a LONG time :( Anyway I've installed the mysqli driver and that seems to be working and I've run 'test connection' in mysql workbench with what I think are the same settings in the joomla without a problem, but the website just gives "Database connection error (2): Could not connect to MySQL." I can browse the data in workbench, and changing user admin enables and disables that, but nothing seems to sort the php connection. Can anybody think of something that I have missed in this or point me to a suitable 'newbie' guide to debugging mysql connections so I can get all these sites back on line again ... If it was Firebird I'd just have mirrored of one of my other machines and been working as the security stuff is managed in the database, by mysql seems to have layers of security that I'm missing somewhere ;) -- Lester Caine - G8HFL - Contact - http://lsces.co.uk/wiki/?page=contact L.S.Caine Electronic Services - http://lsces.co.uk EnquirySolve - http://enquirysolve.com/ Model Engineers Digital Workshop - http://medw.co.uk Rainbow Digital Media - http://rainbowdigitalmedia.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- First of all, I HIGHLY doubt that 1and1 AKA Cisco messed up the DNS. I would be very careful blaming them and publically announcing it. Secondly if you tested mysql connection with Workbench then the error you describe is configuration error in Joomla, common sense would dictate so. http://www.inmotionhosting.com/support/edu/joomla-25/database/troubleshootin g-database-errors This list is for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dynamic Content thoughts
Hello everyone, In my quest to build bigger and better dynamic content, I am putting forth a concept to see what you all think. Many times I come across customers who want drop down menus dynamically built from database tables. Old way Example: Echo '--Please Select--'; $query = "SELECT * FROM personnel ORDER BY last_name"; $result = mysql_query($query); If(mysql_num_rows($result) >= 1) { While($row = mysql_fetch_assoc($result)) { Echo "".$row['first_name']." ".$row['last_name'].""; } } Echo ''; * I am purposing a Method for this that has some flexibility. Initialize Object: $yourobject = new yourclass(); Call method: // The call design is just so you have a better understanding of my concept $dropdown = $yourobject-> dropmenu('personnell','ID',array(0 => 'first_name', 1 => 'last_name'), 'last_name'); Function dropmenu($table,$fieldforvalue,$fieldstodisplay,$fieldorder) // Yes you could add some WHERE filters as well { $arraytoreturn = array(); If(strlen($table) >= 3){ if(is_array($fieldstodisplay)){ $count = 0; foreach($fieldstodisplay as $key=>$values){ if(strlen($values) >=3){ If($count == 0){ $fields = $values; }else{ $fields . = ",".$values; } $count++; } } }else{ If(strlen(($fieldstodisplay) >= 1){ $fields = $fieldstodisplay; $fieldstodisplay = array(0 =>$fieldstodisplay); }else{ Return $arraytoreturn; // Return nothing because no field was selected. } } }else{ Return $arraytoreturn; // Return nothing because no table was selected. } If(strlen($fieldorder) >= 3) { $orderfilter = " ORDER BY ".$fieldorder." "; }else{ $orderfilter = ""; } $query = "SELECT ".$fields." FROM ".$table." ".$orderfilter." "; $result = mysql_query($query); If(mysql_num_rows($result) >= 1) { $arraytoreturn[] = "--Please Select--"; While($row = mysql_fetch_assoc($result)) { $display_fields = ""; Foreach($fieldstodisplay as $key=>$values){ $display_fields .= $row[$values]." "; } If(strlen($fieldforvalue >= 3){ $arraytoreturn[] = "".$display_fields .""; }else{ $arraytoreturn[] = "".$display_fields .""; } } Return $arraytoreturn; }else{ Return $arraytoreturn; // Nothing to return. } } Now I can call the drop downs driven by database tables dynamically and It saves me a TON of time. Echo ''; Foreach($dropdown as $key=>$values){ Echo $values; } Echo ''; Richard L. Buskirk "Some of the world's greatest feats were accomplished by people not smart enough to know they were impossible"
RE: [PHP] Dynamic Content thoughts
-Original Message- From: Matijn Woudt [mailto:tijn...@gmail.com] Sent: Thursday, August 23, 2012 4:39 PM To: admin Cc: php-general@lists.php.net Subject: Re: [PHP] Dynamic Content thoughts On Thu, Aug 23, 2012 at 9:51 PM, admin wrote: > Hello everyone, > > In my quest to build bigger and better dynamic > content, I am putting forth a concept to see what you all think. > > Many times I come across customers who want drop down menus > dynamically built from database tables. > > > > Old way Example: > > > * > > > > I am purposing a Method for this that has some flexibility. > > > > Initialize Object: $yourobject = new yourclass(); > > Call method: // The call design is just so you have a better > understanding of my concept > > $dropdown = $yourobject-> dropmenu('personnell','ID',array(0 => > 'first_name', 1 => 'last_name'), 'last_name'); > > > > Function dropmenu($table,$fieldforvalue,$fieldstodisplay,$fieldorder) > // <> > > > > Now I can call the drop downs driven by database tables dynamically > and It saves me a TON of time. > > Echo ''; > > Foreach($dropdown as $key=>$values){ > > Echo $values; > > } > > Echo ''; > > Hi Richard, First of all, I don't really see the problem with the first code, as it's not that many LOC. OTOH comparing it to the enormous amount of lines needed for your function it seems a bit overkill. If you combine $query = .. and mysql_query($query), to a single line (which I prefer), then you only have 4 lines of code in your first example. ( I only count lines that do something, not the brackets etc). Your function has about 40. If you still want this function, I would change a few things. 1) Do all the echo stuff inside your function, or, only return the data and print the html stuff outside of your function. You're now mixing both which seems wrong. 2) Use SQL as input, and if you wish to make it easy for yourself, write a seperate function that writes SQL queries for you (or just use a lib for it, there are probably plenty). 3) Use mysqli, mysql is deprecated. 4) Use mysqli_real_escape_string to sanitize your input before using it on the database. Hope this helps you, - Matijn -- Thank you Matijn, For coding style, I think we can agree on the fact each person has a different style and reasoning's for their own style. My style on SQL statements was passed down to me from some very successful developers who felt the reason for creating a SQL statement in such a manor was to assist in informatics and Debugging. While you're not getting the point in the Method being in the class and called when needed. It cuts coding size and time down by extremes when you have multiple drop downs that may or may not repeat on different views. Matijn was very correct on the combination of HTML and PHP in a Method and I do agree, many feel this is a giant no no. Many could simply pass the array to the view and create the drop down from there. The wonderful part of the method is that it has the flexibility to meet many coding styles and a vast range of abilities. I do however feel the Mysql_real_escape_string to be un-necessary for the developer, being the end-user(GUI between the keyboard and Chair) will not be passing these fields to the Database. But escape away if you feel safer doing this with-in your own version of the method. As for the MYSQL VS MYSQLI in MOST benchmarks, I find the MYSQL extension to be slightly faster. Yes MYSQLI functions are more Object-oriented in some designs I feel MYSQL out performs MYSQLI in large database setups for a personal preference. Again you may change the Design of the method to meets your needs MYSQL or MYSQLI doesn’t really take away from the concept. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP to XLS Security Alert issue
I am exporting to a XLS file and the file does export, but when I open the file Microsoft is giving a Excel Security Notice. I am sure there is something in the header that is missing or causing this problem. header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Disposition: attachment;filename=list.xls"); header("Content-Transfer-Encoding: binary "); I use pack() to write the labels, Numbers, data. If that could be the culprit. echo pack("s", 0x203, 14, $Row, $Col, 0x0); echo pack("d", $Value); I am running 5.2 on PHP and opening the document with 2010 Office on Windows.
RE: [PHP] PHP to XLS Security Alert issue
-Original Message- From: Matijn Woudt [mailto:tijn...@gmail.com] Sent: Tuesday, August 28, 2012 3:55 PM To: admin Cc: php-general@lists.php.net Subject: Re: [PHP] PHP to XLS Security Alert issue > I believe that's normal, and that it does that with any document downloaded > from the web. > I'm not sure if there's a workaround, but you should not ask that here but on > a Microsoft Office forum/list, or just ask the question to Microsoft > themselves. > > - Matijn > > -- > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: > http://www.php.net/unsub.php Matijn, I understand YOU believe this is normal. I am sorry you feel that way because the construction of the document is exactly where the problem was resolved, and that is in PHP. So asking in the PHP-List was the exact the place to post a question of document construction using PHP. Yes understanding the document verification methods of Microsoft helps but it is up to the DEVELOPER to put the correct headers and content strings to make the document valid and that is what I was asked. Q: I am exporting to a XLS file and the file does export, but when I open the file Microsoft is giving a Excel Security Notice. I am sure there is something in the header that is missing or causing this problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] another Array question
Hello everyone, I have a very long array. I want to pull all the data from the array from a certain position to a certain position. $myarray = array('0'=>'me', '1'=>'you','2'=>'her','3'=>'him','4'=>'them', '5'=>'us'); Yes I know the array above it small it's an example, mine has over 150 positions. $foundyou = array_search('you', $myarray); $foundthem = array_search('them', $myarray); Now I want to take all the array positions from $foundyou to $foundthem and put their values into a variable; For the life of me I can't remember how I did it. I DO NOT want to foreach over the array positions that would be counterproductive. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] another Array question
Length was my problem the whole time. Thank you very much. Resolved -Original Message- From: Jim Lucas [mailto:li...@cmsws.com] Sent: Tuesday, September 11, 2012 1:02 AM To: admin Cc: php-general@lists.php.net Subject: Re: [PHP] another Array question On 9/10/2012 9:41 PM, admin wrote: > Hello everyone, > > I have a very long array. I want to pull all the data from the array > from a certain position to a certain position. > $myarray = array('0'=>'me', > '1'=>'you','2'=>'her','3'=>'him','4'=>'them', > '5'=>'us'); > Yes I know the array above it small it's an example, mine has over 150 > positions. > > $foundyou = array_search('you', $myarray); $foundthem = > array_search('them', $myarray); > > Now I want to take all the array positions from $foundyou to > $foundthem and put their values into a variable; For the life of me I > can't remember how I did it. > > I DO NOT want to foreach over the array positions that would be > counterproductive. > Well, depends on exactly what you mean by "and put their values into a variable". Do you mean concatenate all the values into one single "flat" variable. Or do you mean to make a subset array of the values between your two points you found? First, check out array_slice. Second, look at join 'me', '1'=>'you', '2'=>'her', '3'=>'him', '4'=>'them', '5'=>'us', ); $s_pos = array_search('you', $myarray); $f_pos = array_search('them', $myarray); # Calculate the length, it is needed by array_slice() $length = ($f_pos - $s_pos); $subset_array = array_slice($myarray, $s_pos, $length); print_r($subset_array); $all_values = join(', ', $subset_array); echo $all_values; ?> Obviously, you need to add in some error checking. But that should get you started. -- Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP Threading on Windows
It has been suggested: That because php does not support PCNTL threading on Windows that multiple services of php are an alternative. I am interested in this theory, if anyone is currently working on a project that (forks) processes off to another instance or service of PHP on windows please let me know. In some of my latest development I have some rather large processes that consume the single instance of PHP, threading these off would be ideal. Example: $tmpsrv=win32_query =win32_create_service(array( 'params' => __FILE__." install", 'service' => 'Name_of_the_service', 'display' => 'Name of service to be displayed in the service list' )); Any windows php developers have ideas, comments on this suggestion? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Images can execute php script?
Today I seen a hack into php that has rocked me to my foundation. I seen a picture uploaded onto a server using php and when php displayed the image, phpinfo() was executed and displayed. Does this problem exist in PHP 5.2.17 +? How do you stop it? Sorry, I have never known of this before today. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Images can execute php script?
> Jpgs can hold other data rather than image data > One thing to try is to run strip_tags($image) to remove any php code > http://stackoverflow.com/questions/3499173/my-php-site-was-hacked-by-codes-u ploaded-as-image > http://josephkeeler.com/2009/04/php-upload-security-the-1x1-jpeg-hack/ > > Bastien I understand the principle behind include('pages/' . $_GET['page'] . '.php'); http://www.mysite.com/index.php?page=../upload/image.jpg?cmd=somecode%00 Which I find ridiculous if anyone did that. I am not sure how he was calling the image to be sure. I watched him upload the image and then Do what looked like a normal echo UPLOADED_IMAGES.$_FILE["name"]; You seen phpinfo() called but it was not in the script rather in the image. He opened the test.jpg in a text editor and sure enough there was in the code of the jpeg. This bothers me because I am not sure what all he did. He was proving PHP is not a safe language in front of a rather large group or people in the meeting. I could only look on in disbelief that it just happened in front of me. Everything inside of me wants to say he was doing something outside of what I consider normal circumstances. My question is this: If someone uploads a image through a form or whatever and they have embedded a code in can that code inside the image be executed by viewing the file? $image = 'uploaded.jpg'; Echo ""; Read this: http://php.webtutor.pl/en/2011/05/13/php-code-injection-a-simple-virus-writt en-in-php-and-carried-in-a-jpeg-image/ That was written a couple months ago. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Joining a team, where no wiki or docs are available
> -Original Message- > Hi, > > i'm going to join a mid-size company with a few PHP-driven projects written > in procedural PHP, million years old. > > At the moment, they don't have a wiki or any documentation about their > projects. For me, the first challenge in probation period is to understand > how their code works. > * > Considering that there is no wiki or docs, How can I see the Big Picture?* > i'm sure this is a common problem for programmers everywhere. > > What approach do you use in a similar situation? > Is there a systematic approach for this? > Is there reverse-engineering technique to understand the design of code? > > Please share your experience and thoughts. > > -Thanks in advance, > Behzad Behzad, I would start by mapping their databases structure. Get an understanding of the data behind the application. Normally this gives you a better insight into their thought process, providing they use one. Now for each page I would map out any functions, statements or includes to a diagram and documenting explanations for everything. Because their concept of what the application does may not be the actual functionality. This will allow you to see pitfalls, bad coding, and areas of improvement. This will also allow you do explain to them what the application really does. Think documentum -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Problem with PHP in Moodle LMS
> Has anyone ever heard of a problem with the Moodle LMS when trying to edit an activity (quiz, resource) in which there is a timeout after only a few seconds and a message saying something to the effect of > that the system is sorry but there was a time out, please retry. When I look in the URL I see the following after my domain name: > > .../course/modeit.php > > Is this purely a Moodle thing, or something someone can help me with. (I've already searched the Moodle site for information about this error, but can't see anything related to version 2.2.3, which I am > using.) Any help would be appreciated. I thought I might want to up the timout figure in the php5.ini file in the root directory of my shared Linux hosting with Godaddy, but I don't think that's really the > problem. > Regards, > > Gary Gary, Yes Moodle has a configuration issue. I would switch it to Debug mode and check the error logs it will tell you exactly what is going wrong. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Differences
> Hi everyone, I have been playing around with some code the list helped me with a while back and I'm not grasping the concept between return and echo and the PHP manual doesn't answer this, unless I'm missing something. There is an > example at the very bottom of PHP's return manual, but it's confusing. > > So now I'm left wondering why return will only give me the first result in an array, but echo will give me all the results of the array. Using stuart's example he had sent me a while back I've messed around with it and modified it > to better understand it: > > function filename($prefix) >{ > $matches = glob('images/property_pics/'.$prefix.'*'); > foreach($matches as $filename){ > return $filename; > } >} > >echo completeImageFilename($row['MLS_No']); > >With the above code I only get the first image of each picture name, but when I change return to echo, it groups and displays all the pics that have the same picture name. >-- >David M. The first loop and return is all you will get. Put the information into an array and return the array once the array is built. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Differences
function filename($prefix) { $array_to_return = array(); $matches = glob('images/property_pics/'.$prefix.'*'); foreach($matches as $filename){ $array_to_return[] = $filename; } return $array_to_return; } If this better explains it. The first return will stop the process you need to put the information into an array and then return the array outside of the foreach loop. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Table help needed
> -Original Message- > From: Chris Payne [mailto:oxygene...@gmail.com] > Sent: Friday, October 19, 2012 7:01 PM > To: > Subject: [PHP] Table help needed > > Hi everyone, > > So i'm stuck, and I admit it. I have to (QUICKLY) display information > from a database, easy. But the formatting they want is in a HTML > table, 3 columns at a time and unlimited rows - how can I display 3 > columns across at a time? Please help, it's a last minute thing !!! > > Chris $query = "SELECT * TABLE"; $result = mysql_query($query); If(mysql_num_rows($result) >= 1) { Echo ""; While($row = mysql_fetch_assoc($result)) { Echo "".$row[field1]."".$row[field2]."".$row[field3]."< /TD> } Echo ""; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Table help needed
> -Original Message- > From: tamouse mailing lists [mailto:tamouse.li...@gmail.com] > Sent: Saturday, October 20, 2012 1:53 AM > To: admin > Cc: Chris Payne; php-general@lists.php.net > Subject: Re: [PHP] Table help needed > > On Fri, Oct 19, 2012 at 6:09 PM, admin > wrote: > >> -Original Message- > >> From: Chris Payne [mailto:oxygene...@gmail.com] > >> Sent: Friday, October 19, 2012 7:01 PM > >> To: > >> Subject: [PHP] Table help needed > >> > >> Hi everyone, > >> > >> So i'm stuck, and I admit it. I have to (QUICKLY) display > >> information from a database, easy. But the formatting they want is > >> in a HTML table, 3 columns at a time and unlimited rows - how can I > >> display 3 columns across at a time? Please help, it's a last minute > thing !!! > >> > >> Chris > > > > > > $query = "SELECT * TABLE"; > > $result = mysql_query($query); > > If(mysql_num_rows($result) >= 1) > > { > > Echo ""; > > While($row = mysql_fetch_assoc($result)) > > { > > Echo > > > "".$row[field1]."".$row[field2]."".$row[fiel > > d3]."< > > /TD> > > } > > Echo ""; > > } > > Surprised no one else has jumped on the "Don't use mysql anymore" thing > here. > > Quick and dirty PDO implementation: https://gist.github.com/3922192 Chris, Let me first apologize for a couple syntax errors I had in the real quick explanation. I answered your question in relationship to your knowledge of the subject based on the question it's self. I want to apologize for the comments that followed my reply, seems some people can't make constructive comments if their life depended on it. While the more complex version in PDO is the preferred method to obtain objects from mysql. This does require you to have the basic fundamentals of object oriented programming skills, which I am guessing at this point you do not have based on how the question was phrased. There are many people in the list who will gladly point you in the direction to learning aids and tutorials to get you started. Good Luck :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PDO mysql Connection issue
> On Wednesday, November 28, 2012 at 4:50 PM, ad...@buskirkgraphics.com wrote: >> I am having a PDO mysql connection issue I cant explain. >> >> On server server1.mydomain.com (http://server1.mydomain.com) >> I have a test script >> > $pdo = new PDO('mysql:host=171.16.23.44;dbname=test', 'user','password'); >> ?> >> 171.16.23.44 is by an A record called server2.mydoamin.com >> (http://server2.mydoamin.com) they are 2 different >> servers. >> This script returns an error: >> ERROR: Access denied for user 'user'@'server1.mydomain.com >> (http://server1.mydomain.com)' (using password: >> YES) >> >> I find this ODD because that is not the server i am connecting TO but FROM. >> Why would the PDO connection be referring back to its own localhost instead >> of >> the intended domain. >> I have tried this by fully qualified domain name, same thing. >> I have ensured the route does exist on the connecting server. >> I have ensured there is no local reference to the domain name/IP back to its >> self. >> >> I log into 171.16.23.44 and there is NO record of the failed attempt. >> I validate the user has remote access rights. >> I validate there is not a firewall rule blocking the host/port/you name it. >> I telnet from the server to the destination via port 3306 it connects. >> >> BTW (171.16.23.44) IS FAKE I AM USING THE IP AS AN EXAMPLE HERE. >> >> Any clue as to WHY the host parameter is not setting or is it setting and >> something else is wrong? > > > Have you tried running FLUSH HOSTS on the MySQL server? > > Also, i would try to disable DNS within MYSQL by starting with > --skip-name-resolve > (http://dev.mysql.com/doc/refman/5.0/en/server-options.html#option_mysqld_skip-name-resolve); > > -- > Mike Mackintosh > PHP 5.3 ZCE > I have tried the options listed same results. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PDO question
> -Original Message- > From: Jim Lucas [mailto:li...@cmsws.com] > Sent: Wednesday, November 28, 2012 9:23 PM > To: ad...@buskirkgraphics.com > Cc: php-general@lists.php.net > Subject: Re: [PHP] PDO question > > On 11/28/2012 12:58 PM, ad...@buskirkgraphics.com wrote: > > > > Guys, > > I am not quiet sure what is happening but every time i try to connect > > to a remote host it refers back to localhost. > > > > $pdo = new PDO('mysql:host=171.16.23.44;dbname=test', > > 'user','password'); > > > > ERROR: Access denied for user 'user'@'localhost' (using password: > YES) > > in /var/www/html/text.php > > > > Any clue as to WHY it keeps referring back to localhost when i > clearly > > set the host parameter to another server. > > I checked the /etc/hosts records to see if there was a referral for > > that domain back to it's self there is NOT. > > > > There is a warning on the following page that talks about a possible > issue with connections. Might give it a look. > > http://www.php.net/manual/en/ref.pdo-mysql.connection.php > > -- > Jim Lucas > > http://www.cmsws.com/ > http://www.cmsws.com/examples/ Thank you issue resolved for some reason it was passing the credentials with the fully qualified domain name and NOT the IP and the permission failed to match. Not sure why it is suddenly passing the fully qualified domain name now but as long and this works I really don’t care thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Can't connect to MySQL via PHP
> -Original Message- > From: Rick Dwyer [mailto:rpdw...@earthlink.net] > Sent: Saturday, January 12, 2013 8:26 AM > To: php-general@lists.php.net > Subject: [PHP] Can't connect to MySQL via PHP > > Hello all. > > I used the code below successfully to connect to a MySQL db on one > hosting provider. I've moved the code to a new hosting provider with > new values and it returns: > > Access denied for user 'user'@'db.hostprovider.net' (using password: > YES) > > Even though I can copy and paste these three values (host, user and > pass) and paste into Navicat to make a connection. So the credentials > are correct, but they are not authenticating when used in PHP. I've > tried making host "localhost" and "127.0.0.1". both with the same > result. > > Can someone tell me what I am doing wrong here? > > Appreciate it. > > Thanks, > --Rick > > > > $db_name = "mydb"; > $vc_host= "db.hostprovider.net"; > $vc_user= "user"; > $vc_pass= "pass"; > > $connection = @mysql_connect($vc_host, $vc_user, $vc_pass); $db = > mysql_select_db($db_name, $connection); > > echo mysql_error(); > > > > > -- > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: > http://www.php.net/unsub.php Try this for me --- $db = mysql_connect($vc_host, $vc_user, $vc_pass); mysql_select_db($db_name, $db); if (!$db) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($db); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Can't connect to MySQL via PHP
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Saturday, January 12, 2013 10:03 AM To: admin Cc: 'Rick Dwyer'; php-general@lists.php.net Subject: RE: [PHP] Can't connect to MySQL via PHP On Sat, 2013-01-12 at 12:56 -0800, admin wrote: > -Original Message- > From: Rick Dwyer [mailto:rpdw...@earthlink.net] > Sent: Saturday, January 12, 2013 8:26 AM > To: php-general@lists.php.net > Subject: [PHP] Can't connect to MySQL via PHP > > Hello all. > > I used the code below successfully to connect to a MySQL db on one > hosting provider. I've moved the code to a new hosting provider with > new values and it returns: > > Access denied for user 'user'@'db.hostprovider.net' (using password: > YES) > > Even though I can copy and paste these three values (host, user and > pass) and paste into Navicat to make a connection. So the credentials > are correct, but they are not authenticating when used in PHP. I've > tried making host "localhost" and "127.0.0.1". both with the same > result. > > Can someone tell me what I am doing wrong here? > > Appreciate it. > > Thanks, > --Rick > > > > $db_name = "mydb"; > $vc_host= "db.hostprovider.net"; > $vc_user= "user"; > $vc_pass= "pass"; > > $connection = @mysql_connect($vc_host, $vc_user, $vc_pass); $db = > mysql_select_db($db_name, $connection); > > echo mysql_error(); > > > > > -- > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: > http://www.php.net/unsub.php Try this for me --- $db = mysql_connect($vc_host, $vc_user, $vc_pass); mysql_select_db($db_name, $db); if (!$db) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_close($db); Please at least use mysqli_* functions. Every time someone recommends we use mysql_* functions, a kitten kills a programmer. Thanks, Ash http://www.ashleysheridan.co.uk Ash, The question was asked about mysql functions. As much as the php list would like to force people from using mysql, I guess you should not have invented it, if you don't want people to still use it. Shoots a small fluffy kitten with big blue eyes... Waste a cap save a gui
RE: [PHP] Can't connect to MySQL via PHP
> -Original Message- > From: tamouse mailing lists [mailto:tamouse.li...@gmail.com] > Sent: Saturday, January 12, 2013 7:55 PM > To: admin > Cc: a...@ashleysheridan.co.uk; Rick Dwyer; php-general@lists.php.net > Subject: Re: [PHP] Can't connect to MySQL via PHP > > On Sat, Jan 12, 2013 at 4:49 PM, admin > wrote: > > As much as the php list would like to force people from using mysql, > I guess you should not have invented it, if you don't want people to > still use it. > > It's not this php list. It's the php developers. mysql* functions are > set to be removed in a release coming soon. > > Time marches on. mysql* functions were written first, then the mysqli* > functions were written. mysql* is old, out of date, and not begin > supported. > > Should not have written it? Maybe? But maybe no libraries should have > been written, nothing should move forward, better ways should not have > been found. > > Maybe you want to do your computing using pebbles, too. So let me understand how this works. Someone ask for help, no matter what version they are using or function that is currently in place. We slam them. Call them an idiot. Not that they ask a question about a function in the CURRENT version. Yes the documentation does fully express the function is depreciated, but let's deal with the now. So let's NOT answer the question? (Hello, welcome to MICROSOFT) I am very glad 90% of other languages that have list don't have the same approach. They would gladly give you the answer, but then go on to express how they may suggest this (with example) because it is (safer, easier, ect...). Every time I see someone give a simple answer in an approach to help them learn, in comes the marching band of ignorance and they are toting the banner of epic fail. This is a list to help people understand php and grow the community and knowledge base of its inner workings. If you want to answer at question please at least use SOMETHING that is conducive to educating them. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Can't connect to MySQL via PHP
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] Sent: Sunday, January 13, 2013 8:52 AM To: admin Cc: 'tamouse mailing lists'; 'Rick Dwyer'; php-general@lists.php.net Subject: RE: [PHP] Can't connect to MySQL via PHP On Sun, 2013-01-13 at 11:37 -0800, admin wrote: > -Original Message- > From: tamouse mailing lists [mailto:tamouse.li...@gmail.com] > Sent: Saturday, January 12, 2013 7:55 PM > To: admin > Cc: a...@ashleysheridan.co.uk; Rick Dwyer; php-general@lists.php.net > Subject: Re: [PHP] Can't connect to MySQL via PHP > > On Sat, Jan 12, 2013 at 4:49 PM, admin > wrote: > > As much as the php list would like to force people from using mysql, > I guess you should not have invented it, if you don't want people to > still use it. > > It's not this php list. It's the php developers. mysql* functions are > set to be removed in a release coming soon. > > Time marches on. mysql* functions were written first, then the mysqli* > functions were written. mysql* is old, out of date, and not begin > supported. > > Should not have written it? Maybe? But maybe no libraries should have > been written, nothing should move forward, better ways should not have > been found. > > Maybe you want to do your computing using pebbles, too. So let me understand how this works. Someone ask for help, no matter what version they are using or function that is currently in place. We slam them. Call them an idiot. Not that they ask a question about a function in the CURRENT version. Yes the documentation does fully express the function is depreciated, but let's deal with the now. So let's NOT answer the question? (Hello, welcome to MICROSOFT) I am very glad 90% of other languages that have list don't have the same approach. They would gladly give you the answer, but then go on to express how they may suggest this (with example) because it is (safer, easier, ect...). Every time I see someone give a simple answer in an approach to help them learn, in comes the marching band of ignorance and they are toting the banner of epic fail. This is a list to help people understand php and grow the community and knowledge base of its inner workings. If you want to answer at question please at least use SOMETHING that is conducive to educating them. At no point was I slamming someone for using the old functions, in-fact I was trying to make a joke of that and point out that the msqli functions would be better, unless you really do believe that kittens will kill programmers... The thing is most of us expect the person asking the question here to have done at least a little bit of research into the problem, even if that only extends to "I'll Google some of these keywords in the error". That should at least have produced the same advice about those old deprecated functions, but I wanted to reiterate it a bit just to be sure. It can't hurt to know something like that. The fact is, what you considered a simple answer was bad advice, and would have just taught more people that those old functions are fine, when in-fact they are not. I think it's very important to make people aware of security concerns, especially if they're a beginner with the language. Thanks, Ash http://www.ashleysheridan.co.uk Ash, I am not trying to single you out and i hope that is not how you have taken this conversation. While i agree with you on the security of mysql and BTW (Kittens are monsters). The question clearly showed they have NO experience in db connectors. I felt to over complicate the problem by pushing them into another function was not the best approach. Yes they should understand the security risk and i take the reasonability for not fully explaining the ramifications for using such a function. If you knew my staff you would know I am the last person to think old ways is any approach i will accept. I will end the conversation with an apology to person asking the question, because i should have went into more detail and to anyone this conversation has mislead into thinking i think that function is anything BUT outmode.
RE: [PHP] Can't connect to MySQL via PHP
> -Original Message- > From: Jim Giner [mailto:jim.gi...@albanyhandball.com] > Sent: Sunday, January 13, 2013 9:13 AM > To: php-general@lists.php.net > Subject: Re: [PHP] Can't connect to MySQL via PHP > > Regardless of the choice of interface to mysql, regardless of the > completely harmless but educational tips from Ash, and very > deliberately ignoring the un-helpful and extraneous comments of others, > I'm wondering how the OP is doing with getting his mysql access > working. > Haven't heard from him lately. > > Rick? > > -- > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: > http://www.php.net/unsub.php Jim, I understand it was a credentials issue and all is working fine now. I hope they did take the advice from ash and change the function for security reasons. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP programming a members only access site
> -Original Message- > From: Stephen [mailto:stephe...@rogers.com] > Sent: Sunday, January 13, 2013 9:06 AM > To: php-general@lists.php.net > Subject: [PHP] PHP programming a members only access site > > Can anyone point me to good tutorials/documentation on the subject? > > I want to add this functionality to one of my sites. > > I know there are existing solutions for this, but the ones I have found > are complex, turnkey and don't really facilitate learning. > > I consider myself strong in php programming and using MySQL. > > But I have never used sessions or cookies, and want to learn and do it > properly. > > And I am interested in the security of logins and credentials. Things > like detecting sharing of credentials and the appropriate action to > take. Also what logs to keep and how to audit them. > > And, of course, having sample code for functions like creating a new > account, sending the confirmation email, handling the response. Dealing > with forgotten passwords. I don't want to re-invent the wheel, but I > don't want to have to dissect the code for, say, phpBB to see how it is > done there, either. > > Thanks in advance for suggestions! > > -- > Stephen > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php Stephen, Chris Shiflett wrote an amazing book on this subject "Essential PHP Security" he examines specific attacks and the techniques used to protect against them. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HTML errors
If you are going to use double quotes escape out. >> echo "".$replace.""; On Jan 12, 2011, at 2:30 PM, tedd wrote: > At 10:35 PM -0500 1/11/11, David McGlone wrote: >> Hi Everyone, I'm having a problem validating some links I have in a foreach. >> Here is my code: >> > "http://www.w3.org/TR/html4/loose.dtd";> >> >> my PHP code: >> $categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us', >> 'testimonials'); >> foreach($categorys as $category){ >> $replace = str_replace("_", " ", $category); >> echo "$replace"; >> } >> >> Validator Error: >> an attribute value must be a literal unless it contains only name characters >> >> Šome>homeservices> hŠ >> >> I have tried various combinatons and different doctypes. I'm beginning to >> wonder if this code is allowed at all. >> >> >> -- >> Blessings >> David M. > > David: > > First of all, the type (strict or transitional) of DOCTYPE doesn't matter -- > it only matters IF you are going to use deprecated HTML elements > (transitional) or not (strict). > > Second, your (i.e., list) should start with a "type of list" tag, such > for ordered list -- there are several different types (i.e., ol, ul, > dir, menu, dl dt dd). > > Third, you might try this: > > echo("$replace"); > > The Validator might be objecting to the way you use ' instead of ". > > HTH's > > Cheers, > > 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
Re: [PHP] Rewriting string
Try this. After you create the array If(in_array($_GET['page'],$categorys)){ }else{ } Sent from my iPhone On Jan 13, 2011, at 5:09 AM, David McGlone wrote: > Hi everyone, > > I think the subject is right, or somewhere close. Anyway I am trying to > perform a little trickery here with links. In the following code you can see > where I am trying to replace the link on the current page so it's not a link > when on that page. I think I got the general idea of what I need to do as you > can see in the code I just don't know how to accomplish it, if it's possible. > > > $categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us', > 'testimonials'); > foreach($categorys as $category){ > $deadlink = $_GET['page']; > > if ($deadlink == 'page') { > > $replace = str_replace("_", " ", $category); > echo "$deadlink"; > > } else { > > $replace = str_replace("_", " ", $category); > echo "$replace"; > > } > -- > Blessings > David M. > > -- > 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] Re: Rewriting string
> $categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us', > 'testimonials'); If(in_array($_GET['page'], $categories)) { echo ''.str_replace("_"," ",$_GET['page']).''; }else{ echo ''.str_replace("_"," ",$_GET['page']).''; } I normally never write someones code for them but you are just not getting it. The above code works use it. > $deadlink = $_GET['page']; <-- useless > > > On Jan 13, 2011, at 12:45 PM, Nathan Rixham wrote: > David McGlone wrote: >> Hi everyone, >> I think the subject is right, or somewhere close. Anyway I am trying to >> perform a little trickery here with links. In the following code you can see >> where I am trying to replace the link on the current page so it's not a link >> when on that page. I think I got the general idea of what I need to do as >> you can see in the code I just don't know how to accomplish it, if it's >> possible. >> $categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us', >> 'testimonials'); >> foreach($categorys as $category){ >> $deadlink = $_GET['page']; >> if ($deadlink == 'page') { > > for a short answer, all you need to do is change the above line to: > > if($deadlink == $category) > > and as a slightly colourful variant: > > $categorys = array('home', 'services', 'gallery', 'about_us', 'contact_us', > 'testimonials'); > foreach($categorys as $category){ > $temp = str_replace("_", " ", $category); > $_GET['page'] != $category && $temp = ''.$replace.''; > echo "{$temp}" . PHP_EOL; > } > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >
RE: [PHP] Submitting data to MySQL database using HTML/PHP form
I see an errors in the syntax. $insert = "INSERT INTO user_info (login, password) VALUES ('".mysql_real_escape_string($login)."',"'.mysql_real_escape_string($passwor d)."')"; Issues resolved. $insert = "INSERT INTO user_info (login, password) VALUES ('".mysql_real_escape_string($login)."','".mysql_real_escape_string($passwor d)."')"; Here is the issue ,"'.mysql_real_escape_string($password)."' Your escaping incorrectly. It should be ,'".mysql_real_escape_string($password)."' The double quote is in the wrong place. -Original Message- From: Nazish [mailto:naz...@gmail.com] Sent: Sunday, February 20, 2011 3:54 PM To: php-general@lists.php.net Subject: Re: [PHP] Submitting data to MySQL database using HTML/PHP form Update: I added "echo" statements after mysql_connect and mysql_select_db to check where the code was broken. These statements show up on the login.php page after submitting the form, which means the MySQL connection works. So, the problem seems to lie with the *$insert *query... ideas? On Sun, Feb 20, 2011 at 3:04 PM, Nazish wrote: > Thanks everyone! However, when I click the "submit" button, the url simply > moves to http://localhost/login.php (from home.php) and it is a blank page > (apart from asking whether it should remember the password for future use). > The values still do not move to the database. > > I included most of your suggestions > > a) added mysql _error() > b) different names for the variables > c) removed double quotes > d) changed ?> (silly error!) > e) modified the $insert query > > The code now looks like this: > > > > // Connect to server and select database. > $host = "localhost"; > $user = "root"; > $mysql_pass = "abc"; > $db = "directory"; > > mysql_connect($host, $user, $mysql_pass) or die(mysql_error()); > > mysql_select_db($db) or die(mysql_error()); > > // username and password sent to mysql database > > > $login = $_POST['login']; > $password = $_POST['password']; > > $insert = "INSERT INTO user_info >(login, password) > VALUES > > ('".mysql_real_escape_string($login)."',"'.mysql_real_escape_string($passwor d)."')"; > > > mysql_query($insert) > or die ("Unable to add user to the database:".mysql_error()); > > ?> > > > I could insert the values using the command line, and it was updated in > MySQL, but it doesn't work through the form... it just goes to a blank page > on login.php. I'd appreciate any insights on why that's happening. > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] problem with if and exact match
Try If(preg_match("/Jackson/i", $name)) {echo 'match'; }else{ echo 'fail'; } Richard Buskirk Sent from my iPhone On Mar 15, 2011, at 1:02 AM, "Jack" wrote: > I want to be able to match if a string is contained within the string I am > evaluating. > > > > I know that if ( $name == "xxjacksonxx"); based on the below would be true. > > But I want to be able to say if "jackson" is contained within $name that > it's a match. > > > > I tried the below without success.. > > Not getting the operand properly.. > > > > > > > $name = "xxjacksonxx"; > > > > if ( preg_match($name, "jackson")) { > > print "true"; > > > > } else { > > > > print "false"; > > } > > > > ?> > > > > Thanks! > > Jack > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Can I modify a MySQL object?
Depends on where you want to manipulate. In mysql you can $query = 'select first_name as FNAME from tablename'; In this result you changed the column name from first_name to FNAME for the result only. In this example we can change the data returned in a particular field by using an if statement. $query = 'select IF(first_name='John','Big Bad John',first_name) FROM tablename; If the first_name field contains john we convert the name else just return the name in the row. Is that what you wanted? Richard L. Buskirk Senior Software Engineer/Systems Administrator You can't grow your business with systems that are on life support... -Original Message- From: Brian Dunning [mailto:br...@briandunning.com] Sent: Wednesday, March 23, 2011 8:07 PM To: PHP-General List Subject: [PHP] Can I modify a MySQL object? Let's say I do a query: $result = mysql_query("select * from tablename"); Is there some way I can manually update the contents of certain columns/records in $result? I don't want to actually update MySQL, just the results that I'm holding in memory for this script. Can I do it without converting it to a regular array? -- 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] is there a static constructor?
Why not just create a no named function in the top of the class. This this way it loads on include. Richard Buskirk Sent from my iPhone On Mar 31, 2011, at 12:56 AM, "D. Dante Lorenso" wrote: > All, > > I want to build a config file class that gets called statically. Is there > such a thing as a static constructor? Example: > > class Daz_Config { > public static function load() { >... > } > public static function get($key) { >self :: load(); >... > } > } > > Daz_Config :: get('myvalue'); > > I want to call the load function when the class is used for the first time. > If no code ever calls "Daz_Config :: get(...)" then I never want to invoke > load() but if it does get called, I only want to call load() once before the > class is used further. > > Anyone know how to do this with calling load() at the top of all the other > functions and writing a load() function that exits early if already loaded? > > -- Dante > > -- > 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] JavaScript Injection ???
Javascript:alert("Hello World"); The browsers have had many updates since last I seen this work. PHP Server side. JavaScript Client/Browser Side. Richard L. Buskirk You can't grow your business with systems that are on life support... -Original Message- From: tedd [mailto:t...@sperling.com] Sent: Monday, April 18, 2011 1:06 PM To: php-general@lists.php.net Subject: [PHP] JavaScript Injection ??? Hi gang: Quite some time ago I had a demo that showed Javascript injection. It was where a user could type in: alert("Evil Code"); and a JavaScript alert would be shown. But now my demo no longer works. So, what happened? Was there a php update that prohibited that sort of behavior or did hosts start setting something to OFF, or what? If you know, please explain. Thanks, 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
RE: [PHP] JavaScript Injection ???
Yes Alert works fine on my browsers but the hack to change the alert on someone else's website has been fixed from browser updates. Richard L. Buskirk You can't grow your business with systems that are on life support... -Original Message- From: Jim Giner [mailto:jim.gi...@albanyhandball.com] Sent: Monday, April 18, 2011 2:03 PM To: php-general@lists.php.net Subject: Re: [PHP] JavaScript Injection ??? wrote in message news:005501cbfdeb$457839c0$d068ad40$@com... > Javascript:alert("Hello World"); > The browsers have had many updates since last I seen this work. > ?? You're saying that "alert" doesn't work on your browse? Gee - it works on mine. -- 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] PHP delete confirmation
This can be done in the delete.php file OR use javascript onClick to confirm the intent. Delete.php Personally I would use the javascript page navigation is senseless if they miss click. Javascript: Small and simple javascript. onclick="return confirm('Are you sure you want to delete?')" Richard L. Buskirk -Original Message- From: Chris Stinemetz [mailto:chrisstinem...@gmail.com] Sent: Friday, April 29, 2011 12:33 AM To: php-general@lists.php.net Subject: [PHP] PHP delete confirmation I have been trying to figure out how to add delete confirmation for the bellow snippet of code. I would prefer not to use javascript. Can anyone offer any advise on how to right the delete confirmation in PHP? Thank you in advance. P.S. I apologize for the indention. For some reason gmail messes it up. "; echo '' . $row['Name'] . ''; echo '' . $row['Date'] . ''; echo '' . $row['StoreInfo'] . ''; echo '' . $row['Address'] . ''; echo '' . $row['Type'] . ''; echo '' . $row['EngTech'] . ''; echo '' . $row['StoreManager'] . ''; echo '' . $row['BBtime'] . ''; echo '' . $row['BBup'] . ''; echo '' . $row['BBdown'] . ''; echo '' . $row['SiteSect'] . ''; echo '' . $row['VoiceCall'] . ''; echo '' . $row['Comments'] . ''; echo 'Edit'; echo 'Delete'; echo ""; } // close table> echo ""; ?> -- 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] php to store data
Do your provider offer MySQL or MSSQL? Richard L. Buskirk -Original Message- From: sir wally lewis [mailto:rgilland1...@gmail.com] Sent: Monday, May 02, 2011 3:56 AM To: php-general@lists.php.net Subject: [PHP] php to store data I am a complete novice at php. My internet service provider gives me webspace and PHP script execution for free. I would like a simple example of a website that stores data on the server, in simple text files. Is this possible? Kind Regards, Robert -- 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] php to store data
Sorry just seen posting and thought it was new. Most hosting sites offer MySQL with PHP Richard L. Buskirk -Original Message- From: sir wally lewis [mailto:rgilland1...@gmail.com] Sent: Monday, May 02, 2011 3:56 AM To: php-general@lists.php.net Subject: [PHP] php to store data I am a complete novice at php. My internet service provider gives me webspace and PHP script execution for free. I would like a simple example of a website that stores data on the server, in simple text files. Is this possible? Kind Regards, Robert -- 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] Using SQLite without hosting support
Paul, I could be wrong on this but unless you have a dedicated server, you do not have the recompilation rights if the hosting company is worth anything. Richard L. Buskirk -Original Message- From: Paul M Foster [mailto:pa...@quillandmouse.com] Sent: Tuesday, May 03, 2011 12:36 PM To: php-general@lists.php.net Subject: [PHP] Using SQLite without hosting support Assume you have a hosting account with PHP5 support, but no SQLite support. Yes, supposedly SQLite support is standard for PHP5, but there's no law that keeps someone from compiling PHP5 without SQLite support. So assuming that's the case, given that SQLite is a pretty simple product, is it possible to run PHP5 and use SQLite, even if support for it is not built in? The dl() function has some restrictions on it which might prohibit its use, so is there some way to use SQLite in this situation without resorting to using the dl() function? Paul -- Paul M. Foster http://noferblatz.com http://quillandmouse.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
RE: [PHP] Customize link
If your options are dynamically created you could check the value passed against each option are mark the match with "SELECTED"; Example Static: Echo "5".PHP_EOL; Example Dynamic for($a=1, $a <= 15; $a++) { Echo " ".$a."".PHP_EOL; } Just a though Richard L. Buskirk -Original Message- From: Michael Simiyu [mailto:simiyu.mich...@gmail.com] Sent: Thursday, May 05, 2011 6:10 PM To: php-general@lists.php.net Subject: [PHP] Customize link Hello, Here is the scenario I have a form with the folloing fields i. Title ii. Category (This is a drop down with a list of categories which have id's - am using wordpress ) iii. upload file field now what i want to do is to be able to customize a link like http://www.mysite.com/addfile&cat_id=5 so that when i access the link it has one of the categories in the drop down selected..reason is i dont want users to see the different types of categories So i guess my question is how to configure a meu item in a drop down to be automatically selected in a link... Thanks -- 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] accessing data from an array within an array.
I would suggest you print out the array to get a better understanding of the structure first. Print_r(''); Print_r($array); Print_r(''); You can foreach over the $array['row'] Foreach($array['row'] as $key=>$values) { Echo $values.PHP_EOL; } Richard L. Buskirk -Original Message- From: Adam Preece [mailto:a...@blueyonder.co.uk] Sent: Saturday, May 07, 2011 11:37 AM To: php-general@lists.php.net Subject: [PHP] accessing data from an array within an array. hello all. im trying to make a function that fetches all rows in the database and stores each row (Array) within an array. so the code is as follows: public function fetch_all($table_name,$order = "DESC"){ $array['row'] = array(); strtoupper($order); $query = "SELECT * FROM `{$table_name}` ORDER BY id {$order}"; $result = $this->gen_query($query); while($row = $this->fetch_assoc($result)){ $array['row'][] = $row; } if($this->sql_error_check($result)){ return $array; } } this returns (ill just paste 1 row for the sake of the email length: Array ( [row] => Array ( [0] => Array ( [id] => 9 [name] => TESTER [title] => TESTER [heading] => TESTER [text] => TESTER [gallery_id] => 0 [meta_desc] => TESTER [meta_keywords] => TESTER [meta_author] => TESTER [page_id] => 0 [date_time] => 2011-05-07 06:49:39 [image] => [user_access_id] => 1 ) How do i access each array within the array and throw out the data for each one. im pretty confused on this one. any help would be appreciated. Adam -- 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