php-general Digest 11 May 2008 18:54:07 -0000 Issue 5453
php-general Digest 11 May 2008 18:54:07 - Issue 5453 Topics (messages 274125 through 274154): Re: Division [maybe a bug] 274125 by: Chris W 274152 by: jo opp Re: PHP-MYSQL Error: Can't connect to MySQL socket. Can someone helpme out please? 274126 by: Rahul 274127 by: Nathan Nobbe 274128 by: Rahul 274129 by: Nathan Nobbe 274131 by: Rahul 274132 by: Nathan Nobbe 274133 by: Rahul 274134 by: Nathan Nobbe 274136 by: Rahul 274137 by: Nathan Nobbe 274139 by: Rahul 274140 by: Rahul 274142 by: Nathan Nobbe 274143 by: Rahul 274145 by: Nathan Nobbe 274150 by: Shawn McKenzie 274151 by: Shawn McKenzie Safe mode story 274130 by: admin 274153 by: Wolf Can I make EasyPHP on Windows allow remote connections? 274135 by: Rahul 274138 by: Nathan Nobbe 274141 by: Rahul 274144 by: Nathan Nobbe 274146 by: Rahul Re: Month with leading zeros 274147 by: Casey 274148 by: Jim Lucas 274149 by: Jim Lucas Help with a foreach statement 274154 by: Ron Piggott Administrivia: To subscribe to the digest, e-mail: [EMAIL PROTECTED] To unsubscribe from the digest, e-mail: [EMAIL PROTECTED] To post to the list, e-mail: [EMAIL PROTECTED] -- ---BeginMessage--- jo opp wrote: Hello! $var1= 2155243640%31104000; $var2= 2147309244%31104000; echo $var1 // Return -24651656 echo $var2 // Return 1133244 $var2 return the correct result, but $var1 is wrong (the correct result is 9067640) Probably because the maximum signed 32 bit integer value is 2,147,483,648 if you are dealing with numbers that large, consider using some arbitrary precision math functions that can work with as large of numbers as you need. http://us3.php.net/manual/en/refs.mathcrypto.math.php -- Chris W KE5GIX Protect your digital freedom and privacy, eliminate DRM, learn more at http://www.defectivebydesign.org/what_is_drm; Ham Radio Repeater Database. http://hrrdb.com ---End Message--- ---BeginMessage--- 2008/5/11 Chris W [EMAIL PROTECTED]: jo opp wrote: Hello! $var1= 2155243640%31104000; $var2= 2147309244%31104000; echo $var1 // Return -24651656 echo $var2 // Return 1133244 $var2 return the correct result, but $var1 is wrong (the correct result is 9067640) Probably because the maximum signed 32 bit integer value is 2,147,483,648 OK, but with bigger numbers works fine again. Right now I made a function to deal with this issue: function remainder($dividend,$divisor){ $remainder= $dividend-(floor($dividend/$divisor)*$divisor); return $remainder; } What do you think about it? if you are dealing with numbers that large, consider using some arbitrary precision math functions that can work with as large of numbers as you need. http://us3.php.net/manual/en/refs.mathcrypto.math.php -- Chris W KE5GIX Protect your digital freedom and privacy, eliminate DRM, learn more at http://www.defectivebydesign.org/what_is_drm; Ham Radio Repeater Database. http://hrrdb.com ---End Message--- ---BeginMessage--- By the way it installed MySQL 6 and PHP 5.0.4 and from the console this command does not work: mysql -u root -p but only this works: mysql -h hostname -u root -p I tried doing the same while connecting to the database via php but it does not work. Rahul wrote: I am using Fedora Core 4. As I was unable to use PHP or MySQL together, I uninstalled both of them and installed again using the following commands: yum install mysql And then apt-get install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick And then started the mysql server. I am able to connect to the server from the console my typing mysql -h hostname -u root -p mypass However, when I try to connect to mysql through PHP I get the following errors: PHP Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /export/home/rahul/may/sample.php on line 5 PHP Warning: mysql_query(): A link to the server could not be established in /export/home/rahul/may/sample.php on line 5 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) Can someone please help me out? ---End Message--- ---BeginMessage--- On Sun, May 11, 2008 at 12:30 AM, Rahul [EMAIL PROTECTED] wrote: I am using Fedora Core 4. As I was unable to use PHP or MySQL together, I uninstalled both of them and installed again using the following commands: yum install mysql And then apt-get install php php-devel php-gd php-imap php-ldap php-mysql php-odbc php-pear php-xml php-xmlrpc curl curl-devel perl-libwww-perl ImageMagick And then started the mysql
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
Ok. I apologize for the mix. When I'm mailing someone, I simply don't get Google into mind. :) Thanks, Rahul On Sun, May 11, 2008 at 12:53 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Sun, May 11, 2008 at 1:46 AM, Rahul P [EMAIL PROTECTED] wrote: Ok I removed mysql using yum remove mysql. But is there a special way to tell yum to install that version of mysql? ahh, this is where google comes in for sure. it looks like you could download an older rpm, like from mysql and use 'yum localinstall' or there is a way to search for older versions that are still in the yum repos. heres a quick link i found http://www.fedoraforum.org/forum/showthread.php?t=96684 -nathan -- Rahul Computer Engineering and Systems Division. Department of Electrical Engineering and Computer Science Robert R. McCormick School of Engineering Northwestern University 2145 Sheridan Road, Evanston,IL60208. Administrator: The En?gma Project Website: http://www.enigmaportal.com
Re: [PHP] Can I make EasyPHP on Windows allow remote connections?
On Sun, May 11, 2008 at 1:48 AM, Rahul P [EMAIL PROTECTED] wrote: Well I thought it has something to do with EasyPHP because I'm able to use Remote Desktop Connection of Windows. Actually I've been using EasyPHP through RDC but I thought I could use it directly... rdp has a special port that it runs over. mysql runs over 3306. just because they have the rdp port open doesnt mean they have the mysql one open. but again, good question for the lan admin. i doubt it has anything to do w/ easyPHP. when you say you have a 'web address' for your computer at work, does that mean you can connect to websites hosted on your computer from the internet (like from home for example [not using rdp])? if thats the case then your company also has port 80 open to your system as well, which still doesnt mean that 3306 is open. if you want, you can find out real quick yourself, by using nmap. just use the hostname for your box at work and nmap it. say for example your box has the name mybox.myoffice.com, then you do nmap mybox.myoffice.com if you dont see port 3306 in the list, likely you wont have direct access. but if you do have access over port 80 (web) you can install mysqlAdmin and get to it that way. -nathan
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
On Sun, May 11, 2008 at 1:59 AM, Rahul P [EMAIL PROTECTED] wrote: Ok. I apologize for the mix. When I'm mailing someone, I simply don't get Google into mind. :) no problem, if it were emerge id be much more capable of helping ;) -nathan
Re: [PHP] Can I make EasyPHP on Windows allow remote connections?
Looks like it is closed... Thanks. I will pay a visit to the Root... You've been of great help... Thanks Rahul On Sun, May 11, 2008 at 1:00 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Sun, May 11, 2008 at 1:48 AM, Rahul P [EMAIL PROTECTED] wrote: Well I thought it has something to do with EasyPHP because I'm able to use Remote Desktop Connection of Windows. Actually I've been using EasyPHP through RDC but I thought I could use it directly... rdp has a special port that it runs over. mysql runs over 3306. just because they have the rdp port open doesnt mean they have the mysql one open. but again, good question for the lan admin. i doubt it has anything to do w/ easyPHP. when you say you have a 'web address' for your computer at work, does that mean you can connect to websites hosted on your computer from the internet (like from home for example [not using rdp])? if thats the case then your company also has port 80 open to your system as well, which still doesnt mean that 3306 is open. if you want, you can find out real quick yourself, by using nmap. just use the hostname for your box at work and nmap it. say for example your box has the name mybox.myoffice.com, then you do nmap mybox.myoffice.com if you dont see port 3306 in the list, likely you wont have direct access. but if you do have access over port 80 (web) you can install mysqlAdmin and get to it that way. -nathan -- Rahul Computer Engineering and Systems Division. Department of Electrical Engineering and Computer Science Robert R. McCormick School of Engineering Northwestern University 2145 Sheridan Road, Evanston,IL60208. Administrator: The En?gma Project Website: http://www.enigmaportal.com
Re: [PHP] Month with leading zeros
On 5/10/08, Ron Piggott [EMAIL PROTECTED] wrote: I am wanting to change echo option value=\ . $months[$month] . \; to output the month number, between 01 and 12 --- DATE value m, the month with leading 0's. How do I do this? $months is an array, as I have shown below. Ron ?php $months = array('1' = 'January', '2' = 'February', '3' = 'March', '4' = 'April', '5' = 'May', '6' = 'June', '7' = 'July', '8' = 'August', '9' = 'September', '10' = 'October', '11' = 'November', '12' = 'December'); $current_month = DATE(n); echo SELECT NAME=\order_received_month\\r\n; foreach ($months as $i = $month) { echo option value=\ . $month . \; if ( $i == $current_month ) { echo SELECTED;} echo . $month . /option\r\n; } ? /select -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- -Casey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Month with leading zeros
Ron Piggott wrote: I am wanting to change echo option value=\ . $months[$month] . \; to output the month number, between 01 and 12 --- DATE value m, the month with leading 0's. How do I do this? $months is an array, as I have shown below. Ron ?php $months = array('1' = 'January', '2' = 'February', '3' = 'March', '4' = 'April', '5' = 'May', '6' = 'June', '7' = 'July', '8' = 'August', '9' = 'September', '10' = 'October', '11' = 'November', '12' = 'December'); $current_month = DATE(n); echo SELECT NAME=\order_received_month\\r\n; foreach (range(1, 12) as $month) { echo option value=\ . $months[$month] . \; if ( $month == $current_month ) { echo SELECTED;} echo . $months[$month] . /option\r\n; } ? /select Ok, I will show you two different ways to do this. ?php $months = array( '1' = 'January', '2' = 'February', '3' = 'March', '4' = 'April', '5' = 'May', '6' = 'June', '7' = 'July', '8' = 'August', '9' = 'September', '10' = 'October', '11' = 'November', '12' = 'December', ); foreach ( $months AS $i = $month ) { $sel = ( $i == date('n') ? ' selected=selected' : ''); echo option value='{$month}' {$sel}{$month}/option\r\n; } ? Personally, I would do something like this. ?php $options = array(); for ( $i=1; $i13; $i++ ) { $month = date('F', mktime(0,0,0,$i,2,2000)); $sel = ( $i == date('n') ? ' selected=selected' : ''); $options[] = option value='{$month}' {$sel}{$month}/option; } $options_list = join(\r\n, $options); echo select{$options_list}/select; ? Now, if you are wanting to display the numerical month with leading zero's, then you would want to look at the 'm' option for date() or str_pad(). something like this might show you what you need. ?php # str_pad test echo str_pad(3, 2, '0', STR_PAD_LEFT) ? Hope this helps understand a little more. Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Month with leading zeros
Jim Lucas wrote: Ron Piggott wrote: I am wanting to change echo option value=\ . $months[$month] . \; to output the month number, between 01 and 12 --- DATE value m, the month with leading 0's. How do I do this? $months is an array, as I have shown below. Ron ?php $months = array('1' = 'January', '2' = 'February', '3' = 'March', '4' = 'April', '5' = 'May', '6' = 'June', '7' = 'July', '8' = 'August', '9' = 'September', '10' = 'October', '11' = 'November', '12' = 'December'); $current_month = DATE(n); echo SELECT NAME=\order_received_month\\r\n; foreach (range(1, 12) as $month) { echo option value=\ . $months[$month] . \; if ( $month == $current_month ) { echo SELECTED;} echo . $months[$month] . /option\r\n; } ? /select Ok, I will show you two different ways to do this. ?php $months = array( '1' = 'January', '2' = 'February', '3' = 'March', '4' = 'April', '5' = 'May', '6' = 'June', '7' = 'July', '8' = 'August', '9' = 'September', '10' = 'October', '11' = 'November', '12' = 'December', ); foreach ( $months AS $i = $month ) { $sel = ( $i == date('n') ? ' selected=selected' : ''); echo option value='{$month}' {$sel}{$month}/option\r\n; } ? Personally, I would do something like this. ?php $options = array(); for ( $i=1; $i13; $i++ ) { $month = date('F', mktime(0,0,0,$i,2,2000)); $sel = ( $i == date('n') ? ' selected=selected' : ''); $options[] = option value='{$month}' {$sel}{$month}/option; } $options_list = join(\r\n, $options); echo select{$options_list}/select; ? Now, if you are wanting to display the numerical month with leading zero's, then you would want to look at the 'm' option for date() or str_pad(). something like this might show you what you need. ?php # str_pad test echo str_pad(3, 2, '0', STR_PAD_LEFT) ? Hope this helps understand a little more. Jim sorry should have included this in the first one. http://www.cmsws.com/examples/php/testscripts/[EMAIL PROTECTED]/0002.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP-MYSQL Error: Can't connect to MySQL socket. Can someonehelp me out please?
Rahul P wrote: Ok I removed mysql using yum remove mysql. But is there a special way to tell yum to install that version of mysql? On Sun, May 11, 2008 at 12:44 AM, Rahul P [EMAIL PROTECTED] wrote: On Sun, May 11, 2008 at 12:42 AM, Nathan Nobbe [EMAIL PROTECTED] wrote: On Sun, May 11, 2008 at 1:29 AM, Rahul P [EMAIL PROTECTED] wrote: Oh... This is the fourth time I'm doing that except that this time yum installed mysql6 instead of older versions... I don't see any way out other than reinstalling the OS itself... There are so many dependency failures I'm spending more time troubleshooting than actually coding something :) i dont even think mysql6 is any where near ready for real usage (tho could be wrong). can you see if you could put 5 or 5.1 on there instead? os reinstall sounds painful =/ -nathan -- Rahul Computer Engineering and Systems Division. Department of Electrical Engineering and Computer Science Robert R. McCormick School of Engineering Northwestern University 2145 Sheridan Road, Evanston,IL60208. Administrator: The En?gma Project Website: http://www.enigmaportal.com yum search mysql Find the one that looks like mysql5 or similar and use that. -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Division [maybe a bug]
2008/5/11 Chris W [EMAIL PROTECTED]: jo opp wrote: Hello! $var1= 2155243640%31104000; $var2= 2147309244%31104000; echo $var1 // Return -24651656 echo $var2 // Return 1133244 $var2 return the correct result, but $var1 is wrong (the correct result is 9067640) Probably because the maximum signed 32 bit integer value is 2,147,483,648 OK, but with bigger numbers works fine again. Right now I made a function to deal with this issue: function remainder($dividend,$divisor){ $remainder= $dividend-(floor($dividend/$divisor)*$divisor); return $remainder; } What do you think about it? if you are dealing with numbers that large, consider using some arbitrary precision math functions that can work with as large of numbers as you need. http://us3.php.net/manual/en/refs.mathcrypto.math.php -- Chris W KE5GIX Protect your digital freedom and privacy, eliminate DRM, learn more at http://www.defectivebydesign.org/what_is_drm; Ham Radio Repeater Database. http://hrrdb.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Safe mode story
You could try having apache run as the UID of the user. With a few modifications to apache site config and you should be golden! HTH, Wolf -Original Message- From: admin [EMAIL PROTECTED] Sent: Sunday, May 11, 2008 1:06 AM To: php-general@lists.php.net Subject: [PHP] Safe mode story Hi all, I'm running a Plesk 8.3 mass hosting server equipped with PHP 5.1.6 on CentOS 5, and I'm facing the problem of PHP Safe mode barfing at the UID mismatch of PHP scripts uploaded by user's FTP UID, and later executed by Apache UID, where user's PHP scripts thusly uploaded attempt to write any files while doing their job. Is there an educated solution? What if I relax safe mode checks to gid (safe_mode_gid=On), and given that GID is psacln for every Plesk-hosted customer, with only UIDs being different, is there any risk that folks operating on their own chmod 660 files will be able to overwrite other people's chmod 660 files? Or will open_basedir be enough to prevent unwanted PHP level file access while relaxing safe mode uid check at the same time? (by default, it is properly set by Plesk in %mysite%/conf/httpd.include) ? BTW, safe_mode_exec_dir is empty by default, does it mean if I do set safe_mode_gid then users will be able to exec other Plesk users' cgi-bin scripts etc. because of GIDs being equal?? Safe mode has _got_ to be there for some good reason. Thanks in advance for any tips. -- [The entire original message is not included] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Help with a foreach statement
I am writing a shopping cart. Products assigned in the following fashion: $_SESSION['selection'][$product]=$quantity; I am wanting to display the list of products in the shopping cart in a list for the user to see as they continue shopping. I put the SESSION variable into $cart $cart = $_SESSION['selection']; then I start the foreach and this is where I get messed up. I am trying to ECHO the following syntax to the screen with each selected product: The part I need help with is to write the foreach loop to give me $product (so I may query the database to find out the product name) and the $quantity (so I may show the user what they are purchasing). The part that is messing me up is that this is an array. My ECHO statement should look like this: echo lia href=\ . $path_to_shopping_cart . product/ . $cart[$product_id] . /\ . $product_name . /a - . $quantity . /li\r\n; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] creating an xls file from mysql data
This script will create an xls file from the data that is sent to it When I run this it only gets one recored and it is supposet to get all the records that are past by the $_POST[selectedcontactlist] I think I have a } in the wrong place but I can not figure it out anybody have a suggestion $_POST[selectedcontactlist]=3,45,65,23,12,4,56; //this is a sample of what is past $ExplodeIt = explode(,,rtrim($_POST[selectedcontactlist],,)); $Count = count($ExplodeIt); for ($i=0; $i $Count; $i++) { $sql = SELECT * FROM contacts WHERE id = '$ExplodeIt[$i]'; $sql_result = query($sql); $count = mysql_num_fields($sql_result); for ($i = 0; $i $count; $i++){ $header .= mysql_field_name($sql_result, $i).\t; } while($row = mysql_fetch_row($sql_result)){ $line = ''; foreach($row as $value){ if(!isset($value) || $value == ){ $value = \t; }else{ # important to escape any quotes to preserve them in the data. $value = str_replace('', '', $value); # needed to encapsulate data in quotes because some data might be multi line. # the good news is that numbers remain numbers in Excel even though quoted. $value = '' . $value . '' . \t; } $line .= $value; } $data .= trim($line).\n; } } # this line is needed because returns embedded in the data have \r # and this looks like a box character in Excel $data = str_replace(\r, , $data); # Nice to let someone know that the search came up empty. # Otherwise only the column name headers will be output to Excel. if ($data == ) { $data = \nno matching records found\n; } # This line will stream the file to the user rather than spray it across the screen header(Content-type: application/octet-stream); # replace excelfile.xls with whatever you want the filename to default to header(Content-Disposition: attachment; filename=excelfile.xls); header(Pragma: no-cache); header(Expires: 0); echo $header.\n.$data; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] creating an xls file from mysql data
Hi, You could always do this within mysql itself. You also have the wrong output header and what seems to be some quite inefficient code, anyway take a look at the following. SELECT order_id,product_name,qty FROM orders INTO OUTFILE '/tmp/orders.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '' LINES TERMINATED BY '\n' Thanks Andrew 2008/5/11 Richard Kurth [EMAIL PROTECTED]: This script will create an xls file from the data that is sent to it When I run this it only gets one recored and it is supposet to get all the records that are past by the $_POST[selectedcontactlist] I think I have a } in the wrong place but I can not figure it out anybody have a suggestion $_POST[selectedcontactlist]=3,45,65,23,12,4,56; //this is a sample of what is past $ExplodeIt = explode(,,rtrim($_POST[selectedcontactlist],,)); $Count = count($ExplodeIt); for ($i=0; $i $Count; $i++) { $sql = SELECT * FROM contacts WHERE id = '$ExplodeIt[$i]'; $sql_result = query($sql); $count = mysql_num_fields($sql_result); for ($i = 0; $i $count; $i++){ $header .= mysql_field_name($sql_result, $i).\t; } while($row = mysql_fetch_row($sql_result)){ $line = ''; foreach($row as $value){ if(!isset($value) || $value == ){ $value = \t; }else{ # important to escape any quotes to preserve them in the data. $value = str_replace('', '', $value); # needed to encapsulate data in quotes because some data might be multi line. # the good news is that numbers remain numbers in Excel even though quoted. $value = '' . $value . '' . \t; } $line .= $value; } $data .= trim($line).\n; } } # this line is needed because returns embedded in the data have \r # and this looks like a box character in Excel $data = str_replace(\r, , $data); # Nice to let someone know that the search came up empty. # Otherwise only the column name headers will be output to Excel. if ($data == ) { $data = \nno matching records found\n; } # This line will stream the file to the user rather than spray it across the screen header(Content-type: application/octet-stream); # replace excelfile.xls with whatever you want the filename to default to header(Content-Disposition: attachment; filename=excelfile.xls); header(Pragma: no-cache); header(Expires: 0); echo $header.\n.$data; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to determine if file is writable and deletable
I ended up using posix_access() which is what is_writeable() should be. is_writeable() is virtually useless. Al wrote: I need to determine if a file is truly deletable by a php script, Deleting permissions seem to be the same as writing, they probably have the same criteria. is_writable() seems to virtually useless in most cases. It doesn't take into account the directory ownership/permissions; which, best I can tell, is the real determining factor. I've resorted to having to determine the directory's ownership and then compare the directory's rights with the owner's and then the other ['world']. E.g., Assume my script was loaded with ftp, so it's ownership is the site-name, and I want the scrip to be able to determine if it can delete a file. Thus, the file in question must have its other permissions include write. Surely, there must be an easier way. Thanks, Al -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help with a foreach statement
Hi Ron, This code should work: ?php $path_to_shopping_cart = './'; $iLength = count($cart); foreach ($cart as $product_name = $quantity) { echo lia href=\ . $path_to_shopping_cart . product/ . $cart[$product_id] . /\ . $product_name . /a - . $quantity . /li\r\n; } ? Though I'm not sure about $cart[$product_id]. Where is that coming from?. It makes no sense here. Perhaps you want to do a tri-demensional array in $_session, so you will have a dual-demesnional array in $cart. Let me know, - Craige On Sun, May 11, 2008 at 2:54 PM, Ron Piggott [EMAIL PROTECTED] wrote: I am writing a shopping cart. Products assigned in the following fashion: $_SESSION['selection'][$product]=$quantity; I am wanting to display the list of products in the shopping cart in a list for the user to see as they continue shopping. I put the SESSION variable into $cart $cart = $_SESSION['selection']; then I start the foreach and this is where I get messed up. I am trying to ECHO the following syntax to the screen with each selected product: The part I need help with is to write the foreach loop to give me $product (so I may query the database to find out the product name) and the $quantity (so I may show the user what they are purchasing). The part that is messing me up is that this is an array. My ECHO statement should look like this: echo lia href=\ . $path_to_shopping_cart . product/ . $cart[$product_id] . /\ . $product_name . /a - . $quantity . /li\r\n; -- 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: unsubscribe
You've even had to resort to using classes and other strange stuff to program. Clearly signs of mental fatigue. :-) :o. I think mental fatigue might be evident by one not using it. But that's just me ;) - Craige -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] $_SESSION v. Cookies
I can't see PHP sessions slowing down your site by that amount. As someone said, it should be no more than a split second. If you are having that much of a problem with them, then I would say it is either your implementation, or another determining factor. I would not, personally, stray away from PHP's GC of sessions. I would imagine that any third-party concoction could not be any faster. I would however, check to see how long PHP takes to clean up defunct sessions, and also monitor how many sessions are lying around at any given time. Regards, - Craige -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How to determine if file is writable and deletable
On Sun, 2008-05-11 at 18:09 -0400, Al wrote: I ended up using posix_access() which is what is_writeable() should be. is_writeable() is virtually useless. So you're saying is_writeable() shouldn't work on Windows systems? :p Seems you want is_writeable() to sing AND dance... perhaps too much expecting. 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] Re: Division [maybe a bug]
jo opp wrote: 2008/5/11 Chris W [EMAIL PROTECTED]: jo opp wrote: Hello! $var1= 2155243640%31104000; $var2= 2147309244%31104000; echo $var1 // Return -24651656 echo $var2 // Return 1133244 $var2 return the correct result, but $var1 is wrong (the correct result is 9067640) Probably because the maximum signed 32 bit integer value is 2,147,483,648 OK, but with bigger numbers works fine again. Right now I made a function to deal with this issue: function remainder($dividend,$divisor){ $remainder= $dividend-(floor($dividend/$divisor)*$divisor); return $remainder; } What do you think about it? That will convert the numbers to floating point, which will give you round off error if the numbers get too big. -- Chris W KE5GIX Protect your digital freedom and privacy, eliminate DRM, learn more at http://www.defectivebydesign.org/what_is_drm; Ham Radio Repeater Database. http://hrrdb.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to determine if file is writable and deletable
Al wrote: I ended up using posix_access() which is what is_writeable() should be. is_writeable() is virtually useless. Al wrote: I need to determine if a file is truly deletable by a php script, Deleting permissions seem to be the same as writing, they probably have the same criteria. is_writable() seems to virtually useless in most cases. It doesn't take into account the directory ownership/permissions; which, best I can tell, is the real determining factor. I've resorted to having to determine the directory's ownership and then compare the directory's rights with the owner's and then the other ['world']. E.g., Assume my script was loaded with ftp, so it's ownership is the site-name, and I want the scrip to be able to determine if it can delete a file. Thus, the file in question must have its other permissions include write. Surely, there must be an easier way. Thanks, Al Not if you read Robin's post. -Shawn -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mysql_pconnect issue
hi... running into a problem that i can't seem to solve... using mysql_pconnect() and i'm trying to figure out what parameters have to be used in order to connect to a local mysql session, where mysql is accessed using the defaults (ie, no user/passwd/hostIP) i can connect via the cli, by doing mysql, which accesses the db app.. however, for the life of me, i can't figure out what attributes to use to simply be able to access mysql from within a php app running on apache. it appears that mysql_connect/pconnect requires an actual user/passwd/hostIP in order to work. using mysql_connect(,,) or mysql_connect('','',') returns an error.. i've looked in the php.ini file and set everything (user/passwd/host) to with no louck.. any pointers would be helpful. (i can easily access the mysql if i set up a user (grant access.) but for now, i'm curious as to how to access the default mysql setup... thanks peace -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Ignore Tags
Hello. I am writing a script that scans some content for email addresses and then encrypts them in a way to hide them from spam bots (For more information, http://mailhide.recaptcha.net/ ). The Regular Expressions work perfectly fine, I look for plain email addresses as well as hyperlink email addresses (a href=mailto:[EMAIL PROTECTED] and a href=[EMAIL PROTECTED]). I am nearly done writing the script, the last requested feature is to have some sort of tags or way of making it so that the emails within these tags don't get encrypted. So for example the email within [EMAIL PROTECTED]/nomailhide] won't get encrypted. I know how to scan for the nomailhide tags and get its contents, I just can't figure out how to make it so that the callbacks that encrypt the emails don't touch, or ignore, the emails within the nomailhide tags. Perhaps I'm over complicating things, but I've already asked people in regex and php IRC channels and they too can't figure it out. I've spent 5 hours or so on this one problem and I think my head's about to explode so I'm going to leave it for a while. I would REALLY appreciate it if anyone could please help me out with this in any way possible, I would really value your time. Please, someone, I'm so desperate. If my message isn't really descriptive or anything please let me know, it's just that I'm so sick and tired of all of this.
[PHP] Re: Ignore Tags
Just to show how exhausted I am: I forgot to provide a link to the relevant source code. Here it is: http://paste.blaenkdenum.com/351 On Sun, May 11, 2008 at 9:25 PM, Jorge Peña [EMAIL PROTECTED] wrote: Hello. I am writing a script that scans some content for email addresses and then encrypts them in a way to hide them from spam bots (For more information, http://mailhide.recaptcha.net/ ). The Regular Expressions work perfectly fine, I look for plain email addresses as well as hyperlink email addresses (a href=mailto:[EMAIL PROTECTED] and a href= [EMAIL PROTECTED]). I am nearly done writing the script, the last requested feature is to have some sort of tags or way of making it so that the emails within these tags don't get encrypted. So for example the email within [EMAIL PROTECTED]/nomailhide] won't get encrypted. I know how to scan for the nomailhide tags and get its contents, I just can't figure out how to make it so that the callbacks that encrypt the emails don't touch, or ignore, the emails within the nomailhide tags. Perhaps I'm over complicating things, but I've already asked people in regex and php IRC channels and they too can't figure it out. I've spent 5 hours or so on this one problem and I think my head's about to explode so I'm going to leave it for a while. I would REALLY appreciate it if anyone could please help me out with this in any way possible, I would really value your time. Please, someone, I'm so desperate. If my message isn't really descriptive or anything please let me know, it's just that I'm so sick and tired of all of this.
Re: [PHP] mysql_pconnect issue
bruce wrote: hi... running into a problem that i can't seem to solve... using mysql_pconnect() and i'm trying to figure out what parameters have to be used in order to connect to a local mysql session, where mysql is accessed using the defaults (ie, no user/passwd/hostIP) Use 'localhost' for the host, no idea what you'd use for the user/pass, but mysql requires a username at least. If you're not entering one, it's using the username you are logged in as. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mysql_pconnect issue
On Mon, May 12, 2008 at 12:27 PM, Chris [EMAIL PROTECTED] wrote: bruce wrote: hi... running into a problem that i can't seem to solve... using mysql_pconnect() and i'm trying to figure out what parameters have to be used in order to connect to a local mysql session, where mysql is accessed using the defaults (ie, no user/passwd/hostIP) Use 'localhost' for the host, no idea what you'd use for the user/pass, but mysql requires a username at least. If you're not entering one, it's using the username you are logged in as. I guess the default user is 'root' and password is empty. - forcey -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Ignore Tags
I didn't check out your source, but in terms of a regex that only matches items not surrounded by some special tag, what about negative lookaheads and lookbehinds, like: (?!\[specialtag\])REST_OF_YOUR_REGEX(?!\[specialtag\]) I've not used them in PHP, but just a quick thought that might help. You can read more at the site below: http://www.regular-expressions.info/lookaround.html Adam -Original Message- From: Jorge Peña [EMAIL PROTECTED] [mailto:=?ISO-8859-1?Q? Jorge_Pe=F1a _[EMAIL PROTECTED]?=] Sent: Monday, May 12, 2008 12:27 AM To: php-general@lists.php.net Subject: [PHP] Re: Ignore Tags Just to show how exhausted I am: I forgot to provide a link to the relevant source code. Here it is: http://paste.blaenkdenum.com/351 On Sun, May 11, 2008 at 9:25 PM, Jorge Peña [EMAIL PROTECTED] wrote: Hello. I am writing a script that scans some content for email addresses and then encrypts them in a way to hide them from spam bots (For more information, http://mailhide.recaptcha.net/ ). The Regular Expressions work perfectly fine, I look for plain email addresses as well as hyperlink email addresses (a href=mailto:[EMAIL PROTECTED] and a href= [EMAIL PROTECTED]). I am nearly done writing the script, the last requested feature is to have some sort of tags or way of making it so that the emails within these tags don't get encrypted. So for example the email within [EMAIL PROTECTED]/nomailhide] won't get encrypted. I know how to scan for the nomailhide tags and get its contents, I just can't figure out how to make it so that the callbacks that encrypt the emails don't touch, or ignore, the emails within the nomailhide tags. Perhaps I'm over complicating things, but I've already asked people in regex and php IRC channels and they too can't figure it out. I've spent 5 hours or so on this one problem and I think my head's about to explode so I'm going to leave it for a while. I would REALLY appreciate it if anyone could please help me out with this in any way possible, I would really value your time. Please, someone, I'm so desperate. If my message isn't really descriptive or anything please let me know, it's just that I'm so sick and tired of all of this. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php