[PHP] Confused
All, Okay, I am a bit confused. I'm setting up another server to host PHP pages. I followed everything in the Manual for installing PHP. I'm running Windows Server 2003, IIS6.0 and PHP 5.2.6. And...it kind of works... If I do: ?php echo Test; ? it prints fine. If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine. If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'], 13); ? I get no output. If I do: if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE ACTUAL CONNECTION echo Unable to connect to Informix Database\n; // DISPLAY IF CONNECTION FAILS exit(); } I don't get a connection to the database and the Unable to connect to Informix Database\n; does not even display. I get no errors output to the screen and I have display_errors = On And I have error_reporting = E_ALL ~E_NOTICE Any ideas?
RE: [PHP] Confused
This does not seem to be an installation problem - Your test [(!$connect_id = ] fails, since the connect returns false, so it does not run the condition. Compare: ?php if($a = false){echo no good;}else{echo condition true;} ? -Original Message- From: Dan Shirah [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 02, 2008 7:31 PM To: PHP List Subject: [PHP] Confused All, Okay, I am a bit confused. I'm setting up another server to host PHP pages. I followed everything in the Manual for installing PHP. I'm running Windows Server 2003, IIS6.0 and PHP 5.2.6. And...it kind of works... If I do: ?php echo Test; ? it prints fine. If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine. If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'], 13); ? I get no output. If I do: if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE ACTUAL CONNECTION echo Unable to connect to Informix Database\n; // DISPLAY IF CONNECTION FAILS exit(); } I don't get a connection to the database and the Unable to connect to Informix Database\n; does not even display. I get no errors output to the screen and I have display_errors = On And I have error_reporting = E_ALL ~E_NOTICE Any ideas? No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.169 / Virus Database: 270.6.14/1646 - Release Date: 02/09/2008 06:02 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused
On Tue, 2008-09-02 at 13:31 -0400, Dan Shirah wrote: All, Okay, I am a bit confused. I'm setting up another server to host PHP pages. I followed everything in the Manual for installing PHP. I'm running Windows Server 2003, IIS6.0 and PHP 5.2.6. And...it kind of works... If I do: ?php echo Test; ? it prints fine. If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine. If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'], 13); ? I get no output. Add the following: ?php echo 'pre'.\n print_r( $_SERVER ); echo '/pre'.\n; ? See if the AUTH_USER entry is in there. If I do: if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE ACTUAL CONNECTION echo Unable to connect to Informix Database\n; // DISPLAY IF CONNECTION FAILS exit(); } I don't get a connection to the database and the Unable to connect to Informix Database\n; does not even display. Shouldn't that be: if( !($connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) ) I think PHP may support the style you've used, but I sure as heck wouldn't use it. How do you know you don't get a connection to the database? What is the value of $connect_id? Use var_dump( $connect_id ) to find out. I get no errors output to the screen and I have display_errors = On And I have error_reporting = E_ALL ~E_NOTICE Maybe turn on notices as well. That will probably generate a notice for the missing AUTH_USER index. Any ideas? -- 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
Re: [PHP] Confused
If it was that simple then the second line: echo Unable to connect to Informix Database\n; would execute upon the connection failing and that message would be output to my screen. I get Nothing. Just as a simple call to ?php echo substr($_SERVER['AUTH_USER'], 13); ? returns nothing as well. On 9/2/08, Simcha [EMAIL PROTECTED] wrote: This does not seem to be an installation problem - Your test [(!$connect_id = ] fails, since the connect returns false, so it does not run the condition. Compare: ?php if($a = false){echo no good;}else{echo condition true;} ? -Original Message- From: Dan Shirah [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 02, 2008 7:31 PM To: PHP List Subject: [PHP] Confused All, Okay, I am a bit confused. I'm setting up another server to host PHP pages. I followed everything in the Manual for installing PHP. I'm running Windows Server 2003, IIS6.0 and PHP 5.2.6. And...it kind of works... If I do: ?php echo Test; ? it prints fine. If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine. If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'], 13); ? I get no output. If I do: if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE ACTUAL CONNECTION echo Unable to connect to Informix Database\n; // DISPLAY IF CONNECTION FAILS exit(); } I don't get a connection to the database and the Unable to connect to Informix Database\n; does not even display. I get no errors output to the screen and I have display_errors = On And I have error_reporting = E_ALL ~E_NOTICE Any ideas? No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.169 / Virus Database: 270.6.14/1646 - Release Date: 02/09/2008 06:02
RE: [PHP] Confused
Ignore my previous email - It was sloppy. I was not focusing on the email. SY -Original Message- From: Simcha [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 02, 2008 8:41 PM To: 'Dan Shirah'; 'PHP List' Subject: RE: [PHP] Confused This does not seem to be an installation problem - Your test [(!$connect_id = ] fails, since the connect returns false, so it does not run the condition. Compare: ?php if($a = false){echo no good;}else{echo condition true;} ? -Original Message- From: Dan Shirah [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 02, 2008 7:31 PM To: PHP List Subject: [PHP] Confused All, Okay, I am a bit confused. I'm setting up another server to host PHP pages. I followed everything in the Manual for installing PHP. I'm running Windows Server 2003, IIS6.0 and PHP 5.2.6. And...it kind of works... If I do: ?php echo Test; ? it prints fine. If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine. If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'], 13); ? I get no output. If I do: if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE ACTUAL CONNECTION echo Unable to connect to Informix Database\n; // DISPLAY IF CONNECTION FAILS exit(); } I don't get a connection to the database and the Unable to connect to Informix Database\n; does not even display. I get no errors output to the screen and I have display_errors = On And I have error_reporting = E_ALL ~E_NOTICE Any ideas? No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.169 / Virus Database: 270.6.14/1646 - Release Date: 02/09/2008 06:02 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.169 / Virus Database: 270.6.14/1646 - Release Date: 02/09/2008 06:02 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused
Dan Shirah wrote: All, Okay, I am a bit confused. I'm setting up another server to host PHP pages. I followed everything in the Manual for installing PHP. I'm running Windows Server 2003, IIS6.0 and PHP 5.2.6. And...it kind of works... If I do: ?php echo Test; ? it prints fine. If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine. If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'], 13); ? I get no output. AUTH_USER will be empty unless the user has logged in (using whatever Microsoft's equivalent of htpasswd/htdigest is). As suggested previously, print $_SERVER to ensure it's set. If I do: if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE ACTUAL CONNECTION echo Unable to connect to Informix Database\n; // DISPLAY IF CONNECTION FAILS exit(); } I don't get a connection to the database and the Unable to connect to Informix Database\n; does not even display. I get no errors output to the screen and I have display_errors = On And I have error_reporting = E_ALL ~E_NOTICE Any ideas? $connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass); var_dump($connect_id); And, to be sure, maybe echo $database, $host, $user, and $pass. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused
Add the following: ?php echo 'pre'.\n print_r( $_SERVER ); echo '/pre'.\n; ? See if the AUTH_USER entry is in there. AUTH_USER shows up, but does not have a value. From the output of phpinfo() it says, No value How do you know you don't get a connection to the database? What is the value of $connect_id? Use var_dump( $connect_id ) to find out. I know it isn't connecting because I can go to the database and see that there is no active connections to it.
Re: [PHP] Confused
On Tue, 2008-09-02 at 14:27 -0400, Dan Shirah wrote: Add the following: ?php echo 'pre'.\n print_r( $_SERVER ); echo '/pre'.\n; ? See if the AUTH_USER entry is in there. AUTH_USER shows up, but does not have a value. From the output of phpinfo() it says, No value How do you know you don't get a connection to the database? What is the value of $connect_id? Use var_dump( $connect_id ) to find out. I know it isn't connecting because I can go to the database and see that there is no active connections to it. So you're script runs long enough for you to check? 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
Re: [PHP] Confused
On Tue, Sep 2, 2008 at 1:46 PM, Dan Shirah [EMAIL PROTECTED] wrote: If it was that simple then the second line: echo Unable to connect to Informix Database\n; would execute upon the connection failing and that message would be output to my screen. I get Nothing. Just as a simple call to ?php echo substr($_SERVER['AUTH_USER'], 13); ? returns nothing as well. On 9/2/08, Simcha [EMAIL PROTECTED] wrote: This does not seem to be an installation problem - Your test [(!$connect_id = ] fails, since the connect returns false, so it does not run the condition. Compare: ?php if($a = false){echo no good;}else{echo condition true;} ? -Original Message- From: Dan Shirah [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 02, 2008 7:31 PM To: PHP List Subject: [PHP] Confused All, Okay, I am a bit confused. I'm setting up another server to host PHP pages. I followed everything in the Manual for installing PHP. I'm running Windows Server 2003, IIS6.0 and PHP 5.2.6. And...it kind of works... If I do: ?php echo Test; ? it prints fine. If I do: Today is: ?php echo date(l, F j, Y); ? it prints fine. If I do: You are recognized as: ?php echo substr($_SERVER['AUTH_USER'], 13); ? I get no output. If I do: if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE ACTUAL CONNECTION echo Unable to connect to Informix Database\n; // DISPLAY IF CONNECTION FAILS exit(); } I don't get a connection to the database and the Unable to connect to Informix Database\n; does not even display. I get no errors output to the screen and I have display_errors = On And I have error_reporting = E_ALL ~E_NOTICE Any ideas? No virus found in this incoming message. Checked by AVG - http://www.avg.com Version: 8.0.169 / Virus Database: 270.6.14/1646 - Release Date: 02/09/2008 06:02 Look at your server error log. Maybe you have a parse error or something that prevents it from getting to the screen. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused
So you're script runs long enough for you to check? Cheers, Rob. if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { Checks to see if it doesn't connect. If it does connect the page continues to process. If it doesn't connect the error is displayed. echo Unable to connect to Informix Database\n; If I put in the following: echo Point 1; if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE ACTUAL CONNECTION echo Point 2; echo Unable to connect to Informix Database\n; // DISPLAY IF CONNECTION FAILS echo Point 3; exit(); } echo Point 4; The only thing that is output to my screen is Point 1
Re: [PHP] Confused
On Tue, 2008-09-02 at 14:43 -0400, Dan Shirah wrote: So you're script runs long enough for you to check? Cheers, Rob. if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { Checks to see if it doesn't connect. If it does connect the page continues to process. If it doesn't connect the error is displayed. echo Unable to connect to Informix Database\n; If I put in the following: echo Point 1; if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE ACTUAL CONNECTION echo Point 2; echo Unable to connect to Informix Database\n; // DISPLAY IF CONNECTION FAILS echo Point 3; exit(); } echo Point 4; The only thing that is output to my screen is Point 1 Your script is dying then. What does the error log say? Are you sure PHP is using the php.ini you think it's using? Double check by using phpinfo(). 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
Re: [PHP] Confused
On Tue, 2008-09-02 at 14:46 -0400, Robert Cummings wrote: On Tue, 2008-09-02 at 14:43 -0400, Dan Shirah wrote: So you're script runs long enough for you to check? Cheers, Rob. if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { Checks to see if it doesn't connect. If it does connect the page continues to process. If it doesn't connect the error is displayed. echo Unable to connect to Informix Database\n; If I put in the following: echo Point 1; if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE ACTUAL CONNECTION echo Point 2; echo Unable to connect to Informix Database\n; // DISPLAY IF CONNECTION FAILS echo Point 3; exit(); } echo Point 4; The only thing that is output to my screen is Point 1 Your script is dying then. What does the error log say? Are you sure PHP is using the php.ini you think it's using? Double check by using phpinfo(). BTW, my guess is that ifx_connect() doesn't exist. Possibly you don't have ifx support. 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
Re: [PHP] Confused
Your script is dying then. What does the error log say? Are you sure PHP is using the php.ini you think it's using? Double check by using phpinfo(). Cheers, Rob. It is VERY strange! phpinfo() shows that it is using C:\Windows\php.ini phpinfo() also shows display_errors = Off but when I go to the C:\Windows\php.ini file it says display_errors = On...
Re: [PHP] Confused
On Tue, 2008-09-02 at 14:58 -0400, Dan Shirah wrote: Your script is dying then. What does the error log say? Are you sure PHP is using the php.ini you think it's using? Double check by using phpinfo(). Cheers, Rob. It is VERY strange! phpinfo() shows that it is using C:\Windows \php.ini phpinfo() also shows display_errors = Off but when I go to the C: \Windows\php.ini file it says display_errors = On... Does your script, the apache conf, virtual host conf, or a .htaccess conf modify this setting? perhaps php.ini has more than one display_errors entries? 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
Re: [PHP] Confused
On Tue, Sep 2, 2008 at 7:58 PM, Dan Shirah [EMAIL PROTECTED] wrote: Your script is dying then. What does the error log say? Are you sure PHP is using the php.ini you think it's using? Double check by using phpinfo(). Cheers, Rob. It is VERY strange! phpinfo() shows that it is using C:\Windows\php.ini phpinfo() also shows display_errors = Off but when I go to the C:\Windows\php.ini file it says display_errors = On... You can be rewriting it on your vistualhost or in a script somewhere... -- Thanks for your attention, Diogo Neves Web Developer @ SAPO.pt by PrimeIT.pt
Re: [PHP] Confused
On Tue, Sep 2, 2008 at 8:04 PM, Robert Cummings [EMAIL PROTECTED]wrote: On Tue, 2008-09-02 at 14:58 -0400, Dan Shirah wrote: Your script is dying then. What does the error log say? Are you sure PHP is using the php.ini you think it's using? Double check by using phpinfo(). Cheers, Rob. It is VERY strange! phpinfo() shows that it is using C:\Windows \php.ini phpinfo() also shows display_errors = Off but when I go to the C: \Windows\php.ini file it says display_errors = On... Does your script, the apache conf, virtual host conf, or a .htaccess conf modify this setting? perhaps php.ini has more than one display_errors entries? 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 And all other possible places :) -- Thanks for your attention, Diogo Neves Web Developer @ SAPO.pt by PrimeIT.pt
Re: [PHP] Confused
On 9/2/08, Dan Shirah [EMAIL PROTECTED] wrote: Your script is dying then. What does the error log say? Are you sure PHP is using the php.ini you think it's using? Double check by using phpinfo(). Cheers, Rob. It is VERY strange! phpinfo() shows that it is using C:\Windows\php.ini phpinfo() also shows display_errors = Off but when I go to the C:\Windows\php.ini file it says display_errors = On... Have you restarted the server since changes were made? David
Re: [PHP] Confused
Does your script, the apache conf, virtual host conf, or a .htaccess conf modify this setting? perhaps php.ini has more than one display_errors entries? Cheers, Rob. PROGRESS! It just clicked! About 3 years ago when I setup my first PHP server on Windows I saw someone mention that certain versions of ntwdblib.dll were causing all kinds of problems. I copied the ntwdblib.dll from one of my current servers and now I am at least getting the connection errors! YAY! So now my connection error is probably in my ODBC mapping. But I still need to figure out why AUTH_USER is still No Value
Re: [PHP] Confused
On Tue, Sep 2, 2008 at 2:49 PM, Robert Cummings [EMAIL PROTECTED] wrote: On Tue, 2008-09-02 at 14:46 -0400, Robert Cummings wrote: On Tue, 2008-09-02 at 14:43 -0400, Dan Shirah wrote: So you're script runs long enough for you to check? Cheers, Rob. if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { Checks to see if it doesn't connect. If it does connect the page continues to process. If it doesn't connect the error is displayed. echo Unable to connect to Informix Database\n; If I put in the following: echo Point 1; if (!$connect_id = ifx_connect([EMAIL PROTECTED], $user, $pass)) { // THE ACTUAL CONNECTION echo Point 2; echo Unable to connect to Informix Database\n; // DISPLAY IF CONNECTION FAILS echo Point 3; exit(); } echo Point 4; The only thing that is output to my screen is Point 1 Your script is dying then. What does the error log say? Are you sure PHP is using the php.ini you think it's using? Double check by using phpinfo(). BTW, my guess is that ifx_connect() doesn't exist. Possibly you don't have ifx support. 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 Yea I thought the same that is why I recommended the looking at logs idea. Perhaps maybe just running form cli will do it: [EMAIL PROTECTED]:~/Sites$ php5 blah.php Point 1 Fatal error: Call to undefined function ifx_connect() in /home/eric/Sites/blah.php on line 3 Call Stack: 0.0002 60252 1. {main}() /home/eric/Sites/blah.php:0 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused
Yea I thought the same that is why I recommended the looking at logs idea. Perhaps maybe just running form cli will do it: [EMAIL PROTECTED]:~/Sites$ php5 blah.php Point 1 Fatal error: Call to undefined function ifx_connect() in /home/eric/Sites/blah.php on line 3 You probably don't have extension=php_ifx.dll uncommented? Or you don't have php_ifx.dll in your ext folder?
Re: [PHP] Confused
On Tue, Sep 2, 2008 at 3:15 PM, Dan Shirah [EMAIL PROTECTED] wrote: Yea I thought the same that is why I recommended the looking at logs idea. Perhaps maybe just running form cli will do it: [EMAIL PROTECTED]:~/Sites$ php5 blah.php Point 1 Fatal error: Call to undefined function ifx_connect() in /home/eric/Sites/blah.php on line 3 You probably don't have extension=php_ifx.dll uncommented? Or you don't have php_ifx.dll in your ext folder? I don't use windows. I knew I didn't have it enabled. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused
[SOLVED] Just wanted to let you all know I resolved all my problems. AUTH_USER holds a value once I go into IIS/Default Website and go tot he properties of my application folder. Deselect the Anonymous Access and check Intergrated Windows Authentication. For my connection issue I needed version 2000.2.8.0 of the ntwdblib.dll file. The newer version causes issues and will not allow you to connect to an informix database. Thanks to everyone that helped. Dan
Re[2]: [PHP] Confused about handling bytes
Hi, Monday, May 21, 2007, 3:57:56 PM, you wrote: TR Hi, TR Monday, May 21, 2007, 10:50:27 AM, you wrote: JV While I'm sure this is a stupid question and the solution will be JV obvious to everyone here, this is confusing me. JV I'm trying to control a device over a serial port using a PHP script, JV and one of the things I need to do is read a 26-byte string from an JV EEPROM, using a command that returns two bytes at a time, and write JV similar strings using a similar command. For example, to read the first JV two bytes of one such string beginning at address 0x484, I would send: JV 04 84 00 00 BB JV Here's the code I've written so far: JV $string = 1; //which of 200 strings I want to read JV $base = pack(H*,dechex((($string-1)*hexdec(0x1a))+hexdec(0x484))); JV //calculate the base address of the string (the first starts at 0x484) JV for($i=0;$i 13;$i++) { //iterate 13 times (26 bytes / 2 bytes at a time) JV dio_write($serial,$base.\x00\x00\xbb,5); //send the command JV $output[] = dio_read($serial,1); // read first byte JV $output[] = dio_read($serial,1); // read second byte JV $base = pack(H*,dechex(hexdec(bin2hex($base))+2)); //increment address JV } JV There are two things wrong with this. First, the final line isn't doing JV what it's supposed to. Instead of adding 2 to the value of $base each JV time, It's producing a pattern like this: JV 0x484, 0x486, 0x73, 0x73, 0x73, 0x488, 0x48a, 0x48c, 0x48e, 0x490, 0x74, JV 0x74, 0x74 JV Second, the format of $base doesn't seem to be handled correctly in line JV 4 of the above code. Given a value of 0x484, this line should write the JV bytes 04 84, but it is obviously not doing so, given the response I JV get from the device (it sends FF FF instead of the expected value at JV that address, which I get when I remove the variable and manually JV specify the address). JV What are the solutions to these problems? JV Thanks, JV -Joe Veldhuis TR Do your packing after all the calculations: TR ?php TR $output = array(); TR $string = 1; TR for( TR $i=0, $base = (($string-1) * 26) + 0x484; TR $i 26; TR $i++, $base += 2) TR { TR $binarydata = pack(nc*, $base, 0, 0, 0xBB); TR dio_write($serial,$k=strlen($binarydata),5); //send the command TR $output[] = dio_read($serial,1); // read first byte TR $output[] = dio_read($serial,1); // read second byte TR } TR -- TR regards, TR Tom I left some sebug in there, that should have been: ?php $output = array(); $string = 1; for( $i=0, $base = (($string-1) * 26) + 0x484; $i 26; $i++, $base += 2) { $binarydata = pack(nc*, $base, 0, 0, 0xBB); dio_write($serial,$binarydata,5); //send the command $output[] = dio_read($serial,1); // read first byte $output[] = dio_read($serial,1); // read second byte } -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Confused about handling bytes
While I'm sure this is a stupid question and the solution will be obvious to everyone here, this is confusing me. I'm trying to control a device over a serial port using a PHP script, and one of the things I need to do is read a 26-byte string from an EEPROM, using a command that returns two bytes at a time, and write similar strings using a similar command. For example, to read the first two bytes of one such string beginning at address 0x484, I would send: 04 84 00 00 BB Here's the code I've written so far: $string = 1; //which of 200 strings I want to read $base = pack(H*,dechex((($string-1)*hexdec(0x1a))+hexdec(0x484))); //calculate the base address of the string (the first starts at 0x484) for($i=0;$i 13;$i++) { //iterate 13 times (26 bytes / 2 bytes at a time) dio_write($serial,$base.\x00\x00\xbb,5); //send the command $output[] = dio_read($serial,1); // read first byte $output[] = dio_read($serial,1); // read second byte $base = pack(H*,dechex(hexdec(bin2hex($base))+2)); //increment address } There are two things wrong with this. First, the final line isn't doing what it's supposed to. Instead of adding 2 to the value of $base each time, It's producing a pattern like this: 0x484, 0x486, 0x73, 0x73, 0x73, 0x488, 0x48a, 0x48c, 0x48e, 0x490, 0x74, 0x74, 0x74 Second, the format of $base doesn't seem to be handled correctly in line 4 of the above code. Given a value of 0x484, this line should write the bytes 04 84, but it is obviously not doing so, given the response I get from the device (it sends FF FF instead of the expected value at that address, which I get when I remove the variable and manually specify the address). What are the solutions to these problems? Thanks, -Joe Veldhuis -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused about handling bytes
Hi, Monday, May 21, 2007, 10:50:27 AM, you wrote: JV While I'm sure this is a stupid question and the solution will be JV obvious to everyone here, this is confusing me. JV I'm trying to control a device over a serial port using a PHP script, JV and one of the things I need to do is read a 26-byte string from an JV EEPROM, using a command that returns two bytes at a time, and write JV similar strings using a similar command. For example, to read the first JV two bytes of one such string beginning at address 0x484, I would send: JV 04 84 00 00 BB JV Here's the code I've written so far: JV $string = 1; //which of 200 strings I want to read JV $base = pack(H*,dechex((($string-1)*hexdec(0x1a))+hexdec(0x484))); JV //calculate the base address of the string (the first starts at 0x484) JV for($i=0;$i 13;$i++) { //iterate 13 times (26 bytes / 2 bytes at a time) JV dio_write($serial,$base.\x00\x00\xbb,5); //send the command JV $output[] = dio_read($serial,1); // read first byte JV $output[] = dio_read($serial,1); // read second byte JV $base = pack(H*,dechex(hexdec(bin2hex($base))+2)); //increment address JV } JV There are two things wrong with this. First, the final line isn't doing JV what it's supposed to. Instead of adding 2 to the value of $base each JV time, It's producing a pattern like this: JV 0x484, 0x486, 0x73, 0x73, 0x73, 0x488, 0x48a, 0x48c, 0x48e, 0x490, 0x74, JV 0x74, 0x74 JV Second, the format of $base doesn't seem to be handled correctly in line JV 4 of the above code. Given a value of 0x484, this line should write the JV bytes 04 84, but it is obviously not doing so, given the response I JV get from the device (it sends FF FF instead of the expected value at JV that address, which I get when I remove the variable and manually JV specify the address). JV What are the solutions to these problems? JV Thanks, JV -Joe Veldhuis Do your packing after all the calculations: ?php $output = array(); $string = 1; for( $i=0, $base = (($string-1) * 26) + 0x484; $i 26; $i++, $base += 2) { $binarydata = pack(nc*, $base, 0, 0, 0xBB); dio_write($serial,$k=strlen($binarydata),5); //send the command $output[] = dio_read($serial,1); // read first byte $output[] = dio_read($serial,1); // read second byte } -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Confused about how exactly to output image using imagepng function
PHP list, I've looked at the manual entries for imagepng() and imagecreatetruecolor() functions for helping me to create a temporary image for a CAPTCHA system. However, I'm clearly messing up, as what I'm outputting is a bunch of ASCII gibberish to the screen. What I think I need to do in principle is first create the image with imagecreatetruecolor(), then define it as a PNG (?), then display it. So I've got something like this: $image = ImageCreate($width, $height); ImageFill($image, 0, 0, $black); echo 'img src=' . Imagepng($image) . ' height=' . $height . ' width=' . $width .' alt=captcha /' . \n; ImageDestroy($image); As mentioned, this isn't working, so there's a fundamental concept about how PHP creates and displays images that I'm not getting. I'm trying to output an image that, ideally, won't be stored as a file. Or, if it has to be a temporary file, to delete it immediately after displaying it. What part am I not understanding? Thank you for any advice or information. -- Dave M G Ubuntu Feisty 7.04 Kernel 2.6.20-15-386 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused about how exactly to output image using imagepng function
On 5/17/07, Dave M G [EMAIL PROTECTED] wrote: PHP list, I've looked at the manual entries for imagepng() and imagecreatetruecolor() functions for helping me to create a temporary image for a CAPTCHA system. However, I'm clearly messing up, as what I'm outputting is a bunch of ASCII gibberish to the screen. What I think I need to do in principle is first create the image with imagecreatetruecolor(), then define it as a PNG (?), then display it. So I've got something like this: $image = ImageCreate($width, $height); ImageFill($image, 0, 0, $black); echo 'img src=' . Imagepng($image) . ' height=' . $height . ' width=' . $width .' alt=captcha /' . \n; ImageDestroy($image); As mentioned, this isn't working, so there's a fundamental concept about how PHP creates and displays images that I'm not getting. I'm trying to output an image that, ideally, won't be stored as a file. Or, if it has to be a temporary file, to delete it immediately after displaying it. What part am I not understanding? Thank you for any advice or information. It's quite simple, a second PHP script should generate the image, not the same as that isn't gonna work. as src expects an url where the source is located, and what you are doing is that you're giving the source right there. so you should have a second script called image.php or such with code: $image = ImageCreate($width, $height); ImageFill($image, 0, 0, $black); Imagepng($image); ImageDestroy($image); and then in your first page like echo 'img src=image.php height=' . $height . ' width=' . $width .' alt=captcha /' . \n; Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused about how exactly to output image using imagepng function
Save the image as a file. Then html src=filename Dave M G [EMAIL PROTECTED] wrote: PHP list, I've looked at the manual entries for imagepng() and imagecreatetruecolor() functions for helping me to create a temporary image for a CAPTCHA system. However, I'm clearly messing up, as what I'm outputting is a bunch of ASCII gibberish to the screen. What I think I need to do in principle is first create the image with imagecreatetruecolor(), then define it as a PNG (?), then display it. So I've got something like this: $image = ImageCreate($width, $height); ImageFill($image, 0, 0, $black); echo '' . \n; ImageDestroy($image); As mentioned, this isn't working, so there's a fundamental concept about how PHP creates and displays images that I'm not getting. I'm trying to output an image that, ideally, won't be stored as a file. Or, if it has to be a temporary file, to delete it immediately after displaying it. What part am I not understanding? Thank you for any advice or information. -- Dave M G Ubuntu Feisty 7.04 Kernel 2.6.20-15-386 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused about how exactly to output image using imagepng function
2007. 05. 17, csütörtök keltezéssel 14.49-kor Tijnema ! ezt írta: On 5/17/07, Dave M G [EMAIL PROTECTED] wrote: PHP list, I've looked at the manual entries for imagepng() and imagecreatetruecolor() functions for helping me to create a temporary image for a CAPTCHA system. However, I'm clearly messing up, as what I'm outputting is a bunch of ASCII gibberish to the screen. What I think I need to do in principle is first create the image with imagecreatetruecolor(), then define it as a PNG (?), then display it. So I've got something like this: $image = ImageCreate($width, $height); ImageFill($image, 0, 0, $black); echo 'img src=' . Imagepng($image) . ' height=' . $height . ' width=' . $width .' alt=captcha /' . \n; ImageDestroy($image); As mentioned, this isn't working, so there's a fundamental concept about how PHP creates and displays images that I'm not getting. I'm trying to output an image that, ideally, won't be stored as a file. Or, if it has to be a temporary file, to delete it immediately after displaying it. What part am I not understanding? Thank you for any advice or information. It's quite simple, a second PHP script should generate the image, not the same as that isn't gonna work. as src expects an url where the source is located, and what you are doing is that you're giving the source right there. so you should have a second script called image.php or such with code: $image = ImageCreate($width, $height); ImageFill($image, 0, 0, $black); Imagepng($image); ImageDestroy($image); don't forget to send proper content-type header before the image data header(content-type: image/png); or something like that greets Zoltán Németh and then in your first page like echo 'img src=image.php height=' . $height . ' width=' . $width .' alt=captcha /' . \n; Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Confused on the status of a bogus bug report
With reference to: http://bugs.php.net/bug.php?id=40067 I'm confused as to why this was marked bogus, and the message that marked as such doesn't give much insight. It would seem to me that infinite recursion within PHP is a bug. Shouldn't the interpreter catch this sort of thing before it coredumps? Or is the design philosophy for PHP different than that? If anyone can point me to a online explanation for this or other resource, I'd be happy to read up a bit. More than happy to understand why I'm wrong, but right now I feel as if this problem is getting the brush-off. -- Bill Moran Collaborative Fusion Inc. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused on the status of a bogus bug report
Bill Moran wrote: With reference to: http://bugs.php.net/bug.php?id=40067 I'm confused as to why this was marked bogus, and the message that marked as such doesn't give much insight. It would seem to me that infinite recursion within PHP is a bug. Shouldn't the interpreter catch this sort of thing before it coredumps? Or is the design philosophy for PHP different than that? the way I understand it is that there is no decent way for the engine to tell the difference between a piece of recursive code that will complete and a piece of recursive code that will never complete ... so the only sane solution is to leave it up to user land code to make sure the recursive loop is not infinite. put another way if the engine catches/stops what it *thinks* is an infinite loop then how would stopping the loop at an arbitrary location be any better than dumping core? I believe this is why the bug was marked as bogus - sorry I can't explain it any better. If anyone can point me to a online explanation for this or other resource, I'd be happy to read up a bit. More than happy to understand why I'm wrong, but right now I feel as if this problem is getting the brush-off. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused on the status of a bogus bug report
Bill Moran wrote: With reference to: http://bugs.php.net/bug.php?id=40067 I'm confused as to why this was marked bogus, and the message that marked as such doesn't give much insight. It would seem to me that infinite recursion within PHP is a bug. Shouldn't the interpreter catch this sort of thing before it coredumps? Or is the design philosophy for PHP different than that? If anyone can point me to a online explanation for this or other resource, I'd be happy to read up a bit. More than happy to understand why I'm wrong, but right now I feel as if this problem is getting the brush-off. Getting the interpreter to catch infinite recursion would be bad (imo). It can actually come in handy if you handle it properly: while (true) { ... do stuff if ($conditions_are_met) { break; } } I use this type of idea in some scripts and it works quite well (sometimes I forget the break out part and yeh it causes me some confusion :P). I think the bug report is too complicated.. there are lots of variables involved in what you posted there and for one of the php c developers it's too time consuming to try and replicate - both your environment (php version, how you have it set up and so on) and your script. Pear itself is a complicated beast. If you can narrow it down to a really really simple test case then try again. -- 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] Confused on the status of a bogus bug report
On Mon, 2007-01-08 at 23:59 +0100, Jochem Maas wrote: Bill Moran wrote: With reference to: http://bugs.php.net/bug.php?id=40067 I'm confused as to why this was marked bogus, and the message that marked as such doesn't give much insight. It would seem to me that infinite recursion within PHP is a bug. Shouldn't the interpreter catch this sort of thing before it coredumps? Or is the design philosophy for PHP different than that? the way I understand it is that there is no decent way for the engine to tell the difference between a piece of recursive code that will complete and a piece of recursive code that will never complete ... so the only sane solution is to leave it up to user land code to make sure the recursive loop is not infinite. put another way if the engine catches/stops what it *thinks* is an infinite loop then how would stopping the loop at an arbitrary location be any better than dumping core? Ummm, on many systems you end up with a core dump with the following name: core.pid. Now multiply that by 1000 at 16 to 32 megs a piece. Not fun :) Anyways, the core dump happens because memory is exhausted and the engine is unable to allocate anymore. It should be possible for PHP to exit gracefully upon finding itself out of memory... Possibly it could allocate another 1k and write to the error logfile on which line it was running when it ran out of memory. Or better yet, maybe a debug_backtrace() output *drool*. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused on the status of a bogus bug report
On Tue, 2007-01-09 at 10:01 +1100, Chris wrote: Bill Moran wrote: With reference to: http://bugs.php.net/bug.php?id=40067 I'm confused as to why this was marked bogus, and the message that marked as such doesn't give much insight. It would seem to me that infinite recursion within PHP is a bug. Shouldn't the interpreter catch this sort of thing before it coredumps? Or is the design philosophy for PHP different than that? If anyone can point me to a online explanation for this or other resource, I'd be happy to read up a bit. More than happy to understand why I'm wrong, but right now I feel as if this problem is getting the brush-off. Getting the interpreter to catch infinite recursion would be bad (imo). It can actually come in handy if you handle it properly: while (true) { ... do stuff if ($conditions_are_met) { break; } } Determining infinite recursion pre-emptively is too much work. But it should be able to catch too much recursion causing memory exhaustion. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused on the status of a bogus bug report
Robert Cummings wrote: On Tue, 2007-01-09 at 10:01 +1100, Chris wrote: Bill Moran wrote: With reference to: http://bugs.php.net/bug.php?id=40067 I'm confused as to why this was marked bogus, and the message that marked as such doesn't give much insight. It would seem to me that infinite recursion within PHP is a bug. Shouldn't the interpreter catch this sort of thing before it coredumps? Or is the design philosophy for PHP different than that? If anyone can point me to a online explanation for this or other resource, I'd be happy to read up a bit. More than happy to understand why I'm wrong, but right now I feel as if this problem is getting the brush-off. Getting the interpreter to catch infinite recursion would be bad (imo). It can actually come in handy if you handle it properly: while (true) { ... do stuff if ($conditions_are_met) { break; } } Determining infinite recursion pre-emptively is too much work. But it should be able to catch too much recursion causing memory exhaustion. True.. my point was more that just finding disabling infinite recursion would be a bad decision, but of course that's just my opinion :) -- 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] Confused on the status of a bogus bug report
Robert Cummings wrote: On Mon, 2007-01-08 at 23:59 +0100, Jochem Maas wrote: Bill Moran wrote: With reference to: http://bugs.php.net/bug.php?id=40067 I'm confused as to why this was marked bogus, and the message that marked as such doesn't give much insight. It would seem to me that infinite recursion within PHP is a bug. Shouldn't the interpreter catch this sort of thing before it coredumps? Or is the design philosophy for PHP different than that? the way I understand it is that there is no decent way for the engine to tell the difference between a piece of recursive code that will complete and a piece of recursive code that will never complete ... so the only sane solution is to leave it up to user land code to make sure the recursive loop is not infinite. put another way if the engine catches/stops what it *thinks* is an infinite loop then how would stopping the loop at an arbitrary location be any better than dumping core? Ummm, on many systems you end up with a core dump with the following name: core.pid. Now multiply that by 1000 at 16 to 32 megs a piece. Not fun :) core dump files are only generated in debug builds I thought. I may well be completely wrong though :-) Anyways, the core dump happens because memory is exhausted and the engine is unable to allocate anymore. It should be possible for PHP to exit gracefully upon finding itself out of memory... Possibly it could allocate another 1k and write to the error logfile on which line it was running when it ran out of memory. that does sound sane. Or better yet, maybe a debug_backtrace() output *drool*. wouldn't the backtrace be massive, leaving you with the same problem as indicated by your point regarding the core dump files? Cheers, Rob. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused on the status of a bogus bug report
On Tue, 2007-01-09 at 01:11 +0100, Jochem Maas wrote: Robert Cummings wrote: On Mon, 2007-01-08 at 23:59 +0100, Jochem Maas wrote: Bill Moran wrote: With reference to: http://bugs.php.net/bug.php?id=40067 I'm confused as to why this was marked bogus, and the message that marked as such doesn't give much insight. It would seem to me that infinite recursion within PHP is a bug. Shouldn't the interpreter catch this sort of thing before it coredumps? Or is the design philosophy for PHP different than that? the way I understand it is that there is no decent way for the engine to tell the difference between a piece of recursive code that will complete and a piece of recursive code that will never complete ... so the only sane solution is to leave it up to user land code to make sure the recursive loop is not infinite. put another way if the engine catches/stops what it *thinks* is an infinite loop then how would stopping the loop at an arbitrary location be any better than dumping core? Ummm, on many systems you end up with a core dump with the following name: core.pid. Now multiply that by 1000 at 16 to 32 megs a piece. Not fun :) core dump files are only generated in debug builds I thought. I may well be completely wrong though :-) It is configurable, but often forgotten :) Anyways, the core dump happens because memory is exhausted and the engine is unable to allocate anymore. It should be possible for PHP to exit gracefully upon finding itself out of memory... Possibly it could allocate another 1k and write to the error logfile on which line it was running when it ran out of memory. that does sound sane. Or better yet, maybe a debug_backtrace() output *drool*. wouldn't the backtrace be massive, leaving you with the same problem as indicated by your point regarding the core dump files? Good point... maybe just the last 10 to 20 calls... Quite likely the recursion will be seen then :) Admittedly, one can usually grab the same info from the core dump. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] confused about where to load images
Hello, I have just made my first php mini website. I have my header, footer, navigation and main pages. The header, footer and navigation appear as includes in my main page. When I click on my navigation links, I get a new blank browser window with the image on it. This is not what I want. Can you help me with instructing the server to load the image on my main page and in the designated area instead of a new blank page? http://www.squareinch.net/portfolio2.php Thank you in advance.
Fwd: [PHP] confused about where to load images
I still can't make it work. This is what I have for the link to my images in navbar.php: foreach($row as $jobType) { $row = mysql_fetch_array($result2,MYSQL_ASSOC); echo a href='homehome.php?art=.$row['pix']. border='0'{$row ['jobType']}/a; } and this is what I have in my homehome.php (inside the grey frame) where I want the images to load: ?php $image = $_GET['art']; ? img src=images/?php print($image)? border=5 width=289 height=289 http://www.squareinch.net/homehome.php if www is my main directory, my file structure is: www/homehome.php www/images/... www/include/header.html www/include/footer.html www/include/navbar.php Thank you On Oct 5, 2006, at 4:19 AM, Jeremy Jefferson wrote: foreach($row as $jobType) { $row = mysql_fetch_array($result2,MYSQL_ASSOC); /* array variable= $row */ echo a href=portfolio2.php?logo= . $row['pix'] . border='0' {$row['jobType']} /a ; } - Original Message - From: Mel To: Jeremy Jefferson Sent: Thursday, October 05, 2006 7:00 AM Subject: Re: [PHP] confused about where to load images Hello Jeremy and thank you so much for your reply. I am not sure where to add your code!! My logos are dynamically generated by the code bellow from a MySql database! foreach($row as $jobType) { $row = mysql_fetch_array($result2,MYSQL_ASSOC); /* array variable= $row */ echo a href='images/{$row['pix']}' border='0'{$row['jobType']} /a ; } On Oct 5, 2006, at 3:41 AM, Jeremy Jefferson wrote: You need to change the logo links to link to portfolio2.php? logo=logonamehere
Re: [PHP] confused about where to load images
On Thu, October 5, 2006 5:15 am, Meline Martirossian wrote: I have just made my first php mini website. I have my header, footer, navigation and main pages. The header, footer and navigation appear as includes in my main page. When I click on my navigation links, I get a new blank browser window with the image on it. This is not what I want. Can you help me with instructing the server to load the image on my main page and in the designated area instead of a new blank page? http://www.squareinch.net/portfolio2.php ?php require 'header.inc'; require 'navbar.inc'; //probably should be folded into header.inc... if (isset($_REQUEST['logo'])){ $logo = $_REQUEST['logo']; / everything between these marks is about input validity / You don't need it to understand how to do what you want / You need it to understand how not to get hacked $logo = basename($logo); //minimal crude anti-hack scrubbing... //slightly more anti-hack scrubbing if (substr($logo, -4) !== '.jpg'){ echo pInvalid Input/p; require 'footer.inc'; exit; } //In an IDEAL world, you program the logos into a DB //You then check that '$logo' is *in* the DB, so you know it's //a valid logo. //Unless they hack your DB *and* muck with your URL at same time... // end of input validty section ? img src=/images/?php echo $logo? / ?php } else{ ? pPut the square inch logo here or whatever is there when there is no image selected/p ?php } require 'footer.inc'; ? -- Some people have a gift link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused about how to best execute php scripts in /cgi-bin/
Disappointed that there was no response to this message, I nevertheless seemed to have solved the problem by adding AddHandler php-script .php to the Directory stanza for my /cgi-bin/ directory. For the archives, in case anyone is searching for this answer, too. -Kevin KEVIN ZEMBOWER [EMAIL PROTECTED] 09/06/05 10:44AM I'm trying to allow php scripts to execute from the /cgi-bin/ directory, which is currently set up as a ScriptAlias in my Apache2 configuration. I've found lots of references to this, but there seems to be a couple of different ways to accomplish this, and I can't tell which one is recommended or safest. There seems to be lots of security risks associated with some of the solutions proposed. I'm using Debian woody. This was working under Apache 1, but somehow upgrading to Apache 2 broke it, and I haven't been able to fix it. I've found solutions involving changing the ScriptAlias directory to just an Alias, with ExecuteCGI turned on in the Apache2 configuration. I've also found adding an alias to the php4 executable in the cgi-bin directory and adding an Action and AddHandler to the configuration, but I wasn't able to get this working. I get the sense that changing the SafeMode section of /etc/php4/apache2/php.ini is the recommended, safest way, but I haven't been able to find any cookbook-style directions on what to change to allow the execution of the php scripts from /cgi-bin/. Can anyone help me get this set up? Searching the archives of this list produced some information that seemed contradictory and I couldn't understand which methods were recommended. Thank you for your help and advice. -Kevin Zembower - E. Kevin Zembower Internet Systems Group manager Johns Hopkins University Bloomberg School of Public Health Center for Communications Programs 111 Market Place, Suite 310 Baltimore, MD 21202 410-659-6139 -- 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] Confused about how to best execute php scripts in /cgi-bin/
I'm trying to allow php scripts to execute from the /cgi-bin/ directory, which is currently set up as a ScriptAlias in my Apache2 configuration. I've found lots of references to this, but there seems to be a couple of different ways to accomplish this, and I can't tell which one is recommended or safest. There seems to be lots of security risks associated with some of the solutions proposed. I'm using Debian woody. This was working under Apache 1, but somehow upgrading to Apache 2 broke it, and I haven't been able to fix it. I've found solutions involving changing the ScriptAlias directory to just an Alias, with ExecuteCGI turned on in the Apache2 configuration. I've also found adding an alias to the php4 executable in the cgi-bin directory and adding an Action and AddHandler to the configuration, but I wasn't able to get this working. I get the sense that changing the SafeMode section of /etc/php4/apache2/php.ini is the recommended, safest way, but I haven't been able to find any cookbook-style directions on what to change to allow the execution of the php scripts from /cgi-bin/. Can anyone help me get this set up? Searching the archives of this list produced some information that seemed contradictory and I couldn't understand which methods were recommended. Thank you for your help and advice. -Kevin Zembower - E. Kevin Zembower Internet Systems Group manager Johns Hopkins University Bloomberg School of Public Health Center for Communications Programs 111 Market Place, Suite 310 Baltimore, MD 21202 410-659-6139 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Confused - $GLOBALS
I always forget, because they changed it around on POST/GLOBALS/etc at some point, but only on some of them. Grrr. The built-in arrays with names beginning $_ are superglobals, i.e. always global anyway. The only other superglobal is $GLOBALS, which is a anming exception because it existed long before the $_ arrays came into existence. This has not changed at any point in the life of PHP -- the only change was the actual introduction of the $_ versions. Allow me to be more precise. In version 4.1.0 of December 2001's change log, we find this entry: Introduced $_GET, $_POST, $_COOKIE, $_SERVER and $_ENV variables, which deprecate the old $HTTP_*_VARS arrays. In addition to be much shorter to type - these variables are also available regardless of the scope, and there's no need to import them using the 'global' statement. (Andi Zeev) Therefore my prepetual confusion about which thingies are superglobals comes from the old $HTTP_*_VARS arrays, which are not superglobals, and their $_* vars which have the same data, but are superglobals, and the $GLOBALS variable, which has always been a superglobal. So when I was supposed to go convert all my $HTTP_*_VARS, I *also* had to get rid of all the places I used to have to make them global, but now I don't any more... Woof. Can't just global search and replace my source code, can I? Now I know why I'm making that change piece-meal. :-^ -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Confused - $GLOBALS
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm On 09 December 2004 20:41, Richard Lynch wrote: My best guess from skimming your code is that you need: global $_POST; No, he doesn't. in the function that uses $_POST. Or is $_POST always global anyway? Yes. I always forget, because they changed it around on POST/GLOBALS/etc at some point, but only on some of them. Grrr. The built-in arrays with names beginning $_ are superglobals, i.e. always global anyway. The only other superglobal is $GLOBALS, which is a anming exception because it existed long before the $_ arrays came into existence. This has not changed at any point in the life of PHP -- the only change was the actual introduction of the $_ versions. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Confused - $GLOBALS
Below is a snip of a program I am writing, I am a little new to php. Any how, I can't for the life me figure out why one of my functions cannot grab the item_pics1 variable. I have tried passing the variable to the function, tried using $GLOBALS['item_pic1']. So I guess my question is, does PHP in some cases need to have a variable in a if statement sent back to the global scope? everything works but the str_replace item_pics1. Hope this is enough code. if (array_key_exists('pictures', $_POST)) { $how_many_pics = $_POST['pictures']; picture_input($how_many_pics); //process_errors(); $k = '1'; while ($k = $how_many_pics) { $item_pics1 .= td align=\center\A HREF=\pics/full_$k.jpg \ onMouseOver=\hiLite3('img03','clickme5')\; $item_pics1 .= img src=\pics/thumb_$k.jpg\ border=\0 \/td; $k++; } html_form($title, $price, $descrip, $current_items, $title_file_name, $errors); } else { print 'form method=post action=add-item.php'; print 'trtdHow Many pictures do you have?: /tdtdinput type=text name=pictures size=2/td/tr'; print '/form'; } function html_template() { if (file_exists('item.html')) { $html_template = $GLOBALS['html_template']; $html_template = str_replace('{pictures2}', $GLOBALS['item_pics1'], $html_template); $html_template = str_replace('{title}', $GLOBALS['title'], $html_template); $html_template = str_replace('{description}', $GLOBALS['descrip'], $html_template); $html_template = str_replace('{price}', $GLOBALS['price'], $html_template); $item_file_name = $GLOBALS['root_dir'] . / . $GLOBALS['dir'] . /item.html; $item_fh = fopen($item_file_name, 'x+'); fwrite($item_fh, $html_template); } else { $GLOBALS['errors'] .= item.html template does not exsit; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused - $GLOBALS
Danny Brow wrote: Below is a snip of a program I am writing, I am a little new to php. Any how, I can't for the life me figure out why one of my functions cannot grab the item_pics1 variable. I have tried passing the variable to the function, tried using $GLOBALS['item_pic1']. So I guess my question is, does PHP in some cases need to have a variable in a if statement sent back to the global scope? everything works but the str_replace item_pics1. Hope this is enough code. snip If you want to use a variable from outside the function, you either have to pass it to the function; if you want to change it, you have to pass it by reference, or make it global inside the function function foo ( $bar ) { /--code--/ } function foo ( $bar ) { /--code--/ } function foo() { global $var; /--more code--/ } I may be mistaken, but I think the $GLOBALS array was introduced in 4.3.0. http://us4.php.net/manual/en/language.variables.scope.php -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused - $GLOBALS
Belay that...the $GLOBALS array has existed since PHP3 -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused - $GLOBALS
On Thu, 2004-12-09 at 13:41 -0500, John Nichel wrote: Danny Brow wrote: Below is a snip of a program I am writing, I am a little new to php. Any how, I can't for the life me figure out why one of my functions cannot grab the item_pics1 variable. I have tried passing the variable to the function, tried using $GLOBALS['item_pic1']. So I guess my question is, does PHP in some cases need to have a variable in a if statement sent back to the global scope? everything works but the str_replace item_pics1. Hope this is enough code. snip If you want to use a variable from outside the function, you either have to pass it to the function; if you want to change it, you have to pass it by reference, or make it global inside the function function foo ( $bar ) { /--code--/ } function foo ( $bar ) { /--code--/ } function foo() { global $var; /--more code--/ } See this is where the confusion is, I've tried all these and it still does not work. I'm going to read the whole page on variable scope a few times, see if I missed something. Maybe it's something else in my code screwing my up. Thanks. Dan. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused - $GLOBALS
My best guess from skimming your code is that you need: global $_POST; in the function that uses $_POST. Or is $_POST always global anyway? I always forget, because they changed it around on POST/GLOBALS/etc at some point, but only on some of them. Grrr. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused - $GLOBALS
On Thu, 2004-12-09 at 12:40 -0800, Richard Lynch wrote: My best guess from skimming your code is that you need: global $_POST; should I put this at the top of my code with the rest of my variables? in the function that uses $_POST. Or is $_POST always global anyway? No. I always forget, because they changed it around on POST/GLOBALS/etc at some point, but only on some of them. Grrr. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused - $GLOBALS
On Thu, 2004-12-09 at 15:39 -0500, Roger Spears wrote: Danny Brow wrote: On Thu, 2004-12-09 at 13:41 -0500, John Nichel wrote: Danny Brow wrote: Below is a snip of a program I am writing, I am a little new to php. Any how, I can't for the life me figure out why one of my functions cannot grab the item_pics1 variable. I have tried passing the variable to the function, tried using $GLOBALS['item_pic1']. So I guess my question is, does PHP in some cases need to have a variable in a if statement sent back to the global scope? everything works but the str_replace item_pics1. Hope this is enough code. This may seem a little simple, but it's happened to me. Are you sure the variable has a value? Yes, I can do a print $item_pics before and after the function. dan. PS. Roger, sorry for sending this to you twice, you sent your reply to directly and not to the list. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused - $GLOBALS
On Thu, 2004-12-09 at 12:40 -0800, Richard Lynch wrote: My best guess from skimming your code is that you need: global $_POST; in the function that uses $_POST. Or is $_POST always global anyway? I always forget, because they changed it around on POST/GLOBALS/etc at some point, but only on some of them. Grrr. After reading this again, the function does not use $_POST at all. here it is again. function html_template() { global $item_pics1; if (file_exists('item.html')) { print This is item_pics1 . $item_pics1; $html_template = $GLOBALS['html_template']; $html_template = str_replace('{item_pictures}', $item_pics1, $html_template); $html_template = str_replace('{title}', $GLOBALS['title'], $html_template); $html_template = str_replace('{description}', $GLOBALS['descrip'], $html_template); $html_template = str_replace('{price}', $GLOBALS['price'], $html_template); $item_file_name = $GLOBALS['root_dir'] . / . $GLOBALS['dir'] . /item.html; $item_fh = fopen($item_file_name, 'x+'); fwrite($item_fh, $html_template); } else { $GLOBALS['errors'] .= item.html template does not exsit; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused - $GLOBALS
On Friday 10 December 2004 04:48, Danny Brow wrote: On Thu, 2004-12-09 at 12:40 -0800, Richard Lynch wrote: My best guess from skimming your code is that you need: global $_POST; should I put this at the top of my code with the rest of my variables? No in the function that uses $_POST. Or is $_POST always global anyway? No. Yes -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* BOFH Excuse #227: Fatal error right in front of screen */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused - $GLOBALS
Danny Brow wrote: snip function html_template() { global $item_pics1; if (file_exists('item.html')) { print This is item_pics1 . $item_pics1; $html_template = $GLOBALS['html_template']; $html_template = str_replace('{item_pictures}', $item_pics1, $html_template); $html_template = str_replace('{title}', $GLOBALS['title'], $html_template); $html_template = str_replace('{description}', $GLOBALS['descrip'], $html_template); $html_template = str_replace('{price}', $GLOBALS['price'], $html_template); $item_file_name = $GLOBALS['root_dir'] . / . $GLOBALS['dir'] . /item.html; $item_fh = fopen($item_file_name, 'x+'); fwrite($item_fh, $html_template); } else { $GLOBALS['errors'] .= item.html template does not exsit; } } So what is the function doing or not doing? If 'index.html' isn't in the same directory as the script, it will evaluate to false and the only code the function will execute is... $GLOBALS['errors'] .= item.html template does not exsit; Maybe do a print_r ( $GLOBALS ) inside the function to make sure the values you're looking for are actually there. -- John C. Nichel ÜberGeek KegWorks.com 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused - $GLOBALS
On Friday 10 December 2004 04:52, Danny Brow wrote: OK, you never said what your problem was except to say everything works but the str_replace item_pics1. Did you check $GLOBALS['errors'] after calling this function? function html_template() { global $item_pics1; if (file_exists('item.html')) { Is this file supposed to be same as the one below? $item_file_name = $GLOBALS['root_dir'] . / . $GLOBALS['dir'] . /item.html; -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* We are all dying -- and we're gonna be dead for a long time. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused - $GLOBALS
On Fri, 2004-12-10 at 05:52 +0800, Jason Wong wrote: On Friday 10 December 2004 04:52, Danny Brow wrote: OK, you never said what your problem was except to say everything works but the str_replace item_pics1. Did you check $GLOBALS['errors'] after calling this function? No but I'm doing that now. I'm also reading the manual on $GLOBALS right again, this must have been something I missed the first time reading it. function html_template() { global $item_pics1; if (file_exists('item.html')) { Is this file supposed to be same as the one below? $item_file_name = $GLOBALS['root_dir'] . / . $GLOBALS['dir'] . /item.html; no, this is what the original item.html becomes. In my program $GLOBALS['root_dir'] is the root directory of the program, $GLOBALS['dir'] is created based on the current item number, like /var/www/htdocs/items_for_sale/item1 Thanks, dan. -- Jason Wong - Gremlins Associates - www.gremlins.biz Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * -- Search the list archives before you post http://marc.theaimsgroup.com/?l=php-general -- /* We are all dying -- and we're gonna be dead for a long time. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Confused with constructors
I'm trying the example at: http://www.php.net/manual/en/language.oop.constructor.php ?php class A { function A() { echo I am the constructor of A.br /\n; } function B() { echo I am a regular function named B in class A.br /\n; echo I am not a constructor in A.br /\n; } } class B extends A { function C() { echo I am a regular function.br /\n; } } // This will call B() as a constructor. $b = new B; ? Running this on 4.3.9 both as an apache module and from CLI I get: I am a regular function named B in class A. I am not a constructor in A. This is contrary to what the manual says: This is fixed in PHP 4 by modifying the rule to: 'A constructor is a function of the same name as the class it is being defined in.'. Thus in PHP 4, the class B would have no constructor function of its own and the constructor of the base class would have been called, printing 'I am the constructor of A.br /'. Is this an error in the manual? Or a bug in php 4.3.9? Or just me being stupid? -- G W (no bush) ___ ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused with constructors
Try this: class base_object() { function base_object() { echo I'm the base; } function base_test() { echo I'm the base test; } } class extended_object() extends base_object { function extended_object() { echo I'm the extend object; $this-base_object(); } function extended_test() { echo I'm the extended test; } } Barring any syntax errors (I wrote this out of my head), this should show you that the base object is being properly constructed. On 19 Nov 2004, at 09:02, Gerald Wharney wrote: I'm trying the example at: http://www.php.net/manual/en/language.oop.constructor.php ?php class A { function A() { echo I am the constructor of A.br /\n; } function B() { echo I am a regular function named B in class A.br /\n; echo I am not a constructor in A.br /\n; } } class B extends A { function C() { echo I am a regular function.br /\n; } } // This will call B() as a constructor. $b = new B; ? Running this on 4.3.9 both as an apache module and from CLI I get: I am a regular function named B in class A. I am not a constructor in A. This is contrary to what the manual says: This is fixed in PHP 4 by modifying the rule to: 'A constructor is a function of the same name as the class it is being defined in.'. Thus in PHP 4, the class B would have no constructor function of its own and the constructor of the base class would have been called, printing 'I am the constructor of A.br /'. Is this an error in the manual? Or a bug in php 4.3.9? Or just me being stupid? -- G W (no bush) ___ ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.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] confused about magic quotes
Hi! I got a problem: The server im running my scripts on has magic_quotes_gpc=ON. I know, that i just have to stripslashes() the GPC data. But what if magic_quotes_sybase is also set ON? The doc says, that in this case only ' is replaced by '', and nothing happens to , \ and NUL, because magic_quotes_sybase overwrites magic_quotes_gpc behavior. Unfortunately, the doc says nothing about the case magic_quotes_gpc=OFF PLUS magic_quotes_sybase=ON. Does in this case nothing happen to GPC data, as magic_quotes_gpc is set OFF? Or does it result in the same ' to '' replacement, as magic_quotes_sybase is set ON? What's sybase, anyway? I was about to implement a function as follows: function stripslashes_mq_gpc($txt){ if(get_magic_quotes_gpc()==1){ if(get_ini(magic_quotes_sybase)==1){ $txt=preg_replace(/('')/musi,',$txt); // rather use str_replace() ?? }else{ $txt=stripslashes($txt); } } return $txt; } The same is to be done for magic_quotes_runtime, but there's nothing written about the interaction of magic_quotes_runtime and magic_quotes_sybase. So, could anyone help me, please? Thanks, Kai aka Christopher-Robin PS: Apologies for my bad english. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Confused overSimple PHP mySQL date question
Hi, I have checked the recent list archives and looked up various PHP functions. I know what I want should be simple but, apparently not simple enought for me. I have a mysql database that has a date field and a time field. I want users to be able to enter a date and a time in text boxes on an html form and have them end up in the database. I am having no trouble connecting to the database and running queries against the database but I cannot get the dates and times into the database. Of course I also want to search for the database for an entered date on another form. I am not having trouble with SQL statements or mysql_connect() or anything like that just taking a date as a string from a text box and getting into a DATE field in a mysql database. What obvuios thing did I miss? Note I am not using the system date or time stamp, these are entered dates. Regards, Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Confused overSimple PHP mySQL date question
[snip] DATE field in a mysql database. What obvuios thing did I miss? Note I am not using the system date or time stamp, these are entered dates. [/snip] You're using a DATE field in the MySQL database. MySQL requires an ISO formatted date unless you manipulate it, such as 2004-09-14 http://dev.mysql.com/doc/mysql/en/Date_and_time_types.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused overSimple PHP mySQL date question
From: Scott Miller [EMAIL PROTECTED] I have a mysql database that has a date field and a time field. I want users to be able to enter a date and a time in text boxes on an html form and have them end up in the database. Code examples would be good here. Either way, the format for a DATE field is MMDD or '-MM-DD' and the format for a TIME field is HHMMSS or 'HH:MM:SS'. Make sure what you're trying to stick in the database is in that format. If you want to accept another format in your text fields, then you'll need to use date(), strtotime(), mktime(), explode(), etc to format it this way. You really just need one DATETIME or TIMESTAMP field, though... there's reason to keep these values in two separate fields if they are related to the same event. It'll make searching down the road easier. SELECT * FROM events WHERE datetimecolumn BETWEEN NOW() AND INTERVAL + 30 DAY; SELECT * FROM events WHERE datetimecolumn BETWEEN 20040901 AND 20040930; etc... ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Confused...need some programming logic
Hi, I have 13 folders with a few thousand images each, now the client wants me to export the gallerys to another server that does not run phpso he wants plain .htm files. Below is how far I have come to porting this... the idea being: generate .html files then simply copy the images folders to the clients other server and dump the html files there and he has a gallery ready to go..this is how i thought of it: 1: read number of images from a directory (done) 2: After reading, divide the number by 100 (eg: 1348 images equals 14 pages...last page only 48 pics) (done) 3: Dynamically create the .html files via a fopen (done) 4: put 100 img tags to call 100 images per page (confused here) The images are numbered sequentially but dont start from 0 or 1, they start from something like 00047.jpg or 0024.jpg etc I think I will need a foreach (and tried a foreach...but didnt work) but am confused...ANY help appreciated. ** Start code ?php function directory($dir,$filters){ $handle=opendir($dir); $files=array(); if ($filters == all){while(($file = readdir($handle))!==false){$files[] = $file;}} if ($filters != all){ $filters=explode(,,$filters); while (($file = readdir($handle))!==false) { for ($f=0;$fsizeof($filters);$f++): $system=explode(.,$file); if ($system[1] == $filters[$f]){$files[] = $file;} endfor; } } closedir($handle); return $files; } $pics=directory(pics,jpg,JPG,JPEG,jpeg,png,PNG); $total_pics=count($pics); $pages = ceil($total_pics / 100); // using ceil so 12.23 translates to 13 $content=Mag; /* foreach ($pics as $p) // $p is the name of the file {$content.=$content.img src='thumbs/tn_.$p.';} */ for($i=0; $i$pages;$i++) { if($i==0){$j=;}else{$j=$i;} $index=index.$j; if(!$handle = fopen($index..html, w)) {echo Cannot open file ($filename);exit;} if(fwrite($handle, $content) === FALSE) {echo Cannot write to file $filename);exit;} fclose($handle); } echo The end; ? ** End code The above code is working so far as to: 1.read from the dir 2.create the required number of pages while making sure the first page is index.html 3. Writing some content in..in this case just: Mag Thanks, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused...need some programming logic
On Wed, 4 Aug 2004 15:06:45 -0700 (PDT), PHP Gen [EMAIL PROTECTED] wrote: Hi, I have 13 folders with a few thousand images each, now the client wants me to export the gallerys to another server that does not run phpso he wants plain .htm files. Below is how far I have come to porting this... the idea being: generate .html files then simply copy the images folders to the clients other server and dump the html files there and he has a gallery ready to go..this is how i thought of it: 1: read number of images from a directory (done) 2: After reading, divide the number by 100 (eg: 1348 images equals 14 pages...last page only 48 pics) (done) 3: Dynamically create the .html files via a fopen (done) 4: put 100 img tags to call 100 images per page (confused here) I put some code inline below. Should work. If you want a thumbnail gallery, you could also create thumbnails using the GD functions in PHP, same them, and create an img tag with the thumbnail with a link to the fill file. The images are numbered sequentially but dont start from 0 or 1, they start from something like 00047.jpg or 0024.jpg etc I think I will need a foreach (and tried a foreach...but didnt work) but am confused...ANY help appreciated. ** Start code ?php function directory($dir,$filters){ $handle=opendir($dir); $files=array(); if ($filters == all){while(($file = readdir($handle))!==false){$files[] = $file;}} if ($filters != all){ $filters=explode(,,$filters); while (($file = readdir($handle))!==false) { for ($f=0;$fsizeof($filters);$f++): $system=explode(.,$file); if ($system[1] == $filters[$f]){$files[] = $file;} endfor; } } closedir($handle); return $files; } $pics=directory(pics,jpg,JPG,JPEG,jpeg,png,PNG); $total_pics=count($pics); $pages = ceil($total_pics / 100); // using ceil so 12.23 translates to 13 $content=Mag; /* foreach ($pics as $p) // $p is the name of the file {$content.=$content.img src='thumbs/tn_.$p.';} */ for($i=0; $i$pages;$i++) { if($i==0){$j=;}else{$j=$i;} $index=index.$j; if(!$handle = fopen($index..html, w)) {echo Cannot open file ($filename);exit;} if(fwrite($handle, $content) === FALSE) {echo Cannot write to file $filename);exit;} for($j = 0; $j 100; ++$j) { if($pics[$i * 100 + $j]) { echo 'img src='.$pics[$i * 100 + $j].'/br/'; } } fclose($handle); } echo The end; ? ** End code The above code is working so far as to: 1.read from the dir 2.create the required number of pages while making sure the first page is index.html 3. Writing some content in..in this case just: Mag Thanks, Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php !DSPAM:41115bea172812942772655! -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused...need some programming logic
--- Justin Patrin [EMAIL PROTECTED] wrote: 4: put 100 img tags to call 100 images per page (confused here) I put some code inline below. Should work. If you want a thumbnail gallery, you could also create thumbnails using the GD functions in PHP, same them, and create an img tag with the thumbnail with a link to the fill file. Hi, Thanks for replying. I think you misunderstood my problem, your code is just printing the images onto the screen...I need to take 100 img tags and write it to each of the .html pages... eg: if there 112 images in the folder, it should create 2 html files (index.htm and index1.htm - this is already done - THEN insert 100 img tags into the first file (index.htm) and balance 12 img tags into the second file) Ideas? Thanks, -Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused...need some programming logic
On Wed, 4 Aug 2004 15:40:03 -0700 (PDT), PHP Gen [EMAIL PROTECTED] wrote: --- Justin Patrin [EMAIL PROTECTED] wrote: 4: put 100 img tags to call 100 images per page (confused here) I put some code inline below. Should work. If you want a thumbnail gallery, you could also create thumbnails using the GD functions in PHP, same them, and create an img tag with the thumbnail with a link to the fill file. Hi, Thanks for replying. I think you misunderstood my problem, your code is just printing the images onto the screen...I need to take 100 img tags and write it to each of the .html pages... eg: if there 112 images in the folder, it should create 2 html files (index.htm and index1.htm - this is already done - THEN insert 100 img tags into the first file (index.htm) and balance 12 img tags into the second file) Ideas? No, I didn't misunderstand, it was an oversight. Just change the echo to an fwrite. for($j = 0; $j 100; ++$j) { if($pics[$i * 100 + $j]) { fwrite($handle, 'img src='.$pics[$i * 100 + $j].'/br/'); } } -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin-- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Confused...need some programming logic
Hey, Just change the echo to an fwrite. for($j = 0; $j 100; ++$j) { if($pics[$i * 100 + $j]) { fwrite($handle, 'img src='.$pics[$i * 100 + $j].'/br/'); } } Works like a charm, thanks a million. -Mag = -- - The faulty interface lies between the chair and the keyboard. - Creativity is great, but plagiarism is faster! - Smile, everyone loves a moron. :-) __ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] confused big time
On Tue, 2004-04-06 at 20:09, Chris W. Parker wrote: Chris W. Parker on Tuesday, April 06, 2004 5:01 PM said: let me expand both of my points in an attempt to be more verbose. 1. write readable queries. 2. always put single quotes around array keys. $array['key'] here is how i would write your query: ?php $sql = insert into $EventsTable values( NULL , '{$_SESSION['add']['type]}' , '{$_SESSION['add']['start_date']}' , '{$_SESSION['add']['end_date']}' , '{$_SESSION['add']['name']}' , '{$_SESSION['add']['county']}' , '{$_SESSION['add']['discription']}' , '{$_SESSION['add']['StartingDay']}' , '{$_SESSION['add']['StartingMonth']}' , '{$_SESSION['add']['StartingYear']}' , '{$_SESSION['add']['EndingDay']}' , '{$_SESSION['add']['EndingMonth']}' , '{$_SESSION['add']['EndingYear']}'; $sql = insert into $GuestbookTable values( NULL , '{$_SESSION['add']['date']}' , '{$_SESSION['add']['name']}' , '{$_SESSION['add']['email']}' , '{$_SESSION['add']['website']}' , '{$_SESSION['add']['referred']}' , '{$_SESSION['add']['comments']}'); I don't advise this type of insert query. If you ever add a new field to the table all of your queries will break since this style requires ordered matching of values to table fields for every field in the table. You should use the field names in the query: $sql = INSERT INTO $guestbookTable ( field1, field2, field3 ) VALUES ( '$value1', '$value2', '$value3' ) ; Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confused big time
I always found this way of inserting data into a database messy. Here is a handy function to do array inserts and it builds the sql for you. function arrayINSERT($a,$tablename) { $sql = INSERT INTO $tablename (; foreach($a as $key = $value) { $sql .= $key .,; } $sql[strlen($sql)-1] = ')'; $sql .= VALUES (; foreach($a as $key = $value) { if (gettype($value) == 'string') { $sql .= '. addslashes($value) .',; } else { $sql .= $value .,; } } $sql[strlen($sql)-1] = ')'; return $sql; } if you do this : $a['field1'] = $blah; $a['field2'] = $here; $a['field3'] = $etc; $sql = arrayINSERT($a,tablename); it builds the sql statement for you. It covers 99.9% of the inserts your likely to need. I use an update and insert function like this all the time. :-) Mark Richard Davey wrote: $sql = INSERT INTO tablename ( field1, field2, field3 ) VALUES ( '$blah', $here', '$etc' ) ; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confused big time
From: Mark Ackroyd [EMAIL PROTECTED] I always found this way of inserting data into a database messy. Here is a handy function to do array inserts and it builds the sql for you. function arrayINSERT($a,$tablename) { $sql = INSERT INTO $tablename (; foreach($a as $key = $value) { $sql .= $key .,; } $sql[strlen($sql)-1] = ')'; $sql .= VALUES (; foreach($a as $key = $value) { if (gettype($value) == 'string') { $sql .= '. addslashes($value) .',; } else { $sql .= $value .,; } } $sql[strlen($sql)-1] = ')'; return $sql; } To get your list of columns, you could do this: $column_list = implode(',',array_keys($a)); $sql = INSERT INTO $tablename ($column_list) VALUES ; That way you only have to loop through $a once. ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] confused big time
Hello Mark, Wednesday, April 7, 2004, 5:16:04 PM, you wrote: MA it builds the sql statement for you. It covers 99.9% of the inserts MA your likely to need. I use an update and insert function like this all MA the time. :-) That .1% of the time being when you need to insert a value as now() ? (which will break the string check as it'll wrap it with '' which will cause MySQL to insert -00-00 00:00:00) or if it's an enum field with a numeric allowed value? :) -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confused big time
RD That .1% of the time being when you need to insert a value as now() ? RD (which will break the string check as it'll wrap it with '' which will RD cause MySQL to insert -00-00 00:00:00) or if it's an enum field RD with a numeric allowed value? :) Not really, since you usally format a timestamp into something thats db friendly. How many times have you written code where the date 02-01-2004 means the 2nd of Jan or the 1st of Feb?. On a MS SQL BOX the best format is '01-MAR-2004 12:00:00' which is eval'ed as a string. On mysql it's '2004-03-01 12:00:00' if you get into the habbit of *always* converting the date into a db friendly string, then you'll never have date insert problems and it can be used in the function without issues. Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] confused big time
Hello Mark, Wednesday, April 7, 2004, 6:19:31 PM, you wrote: RD That .1% of the time being when you need to insert a value as now() ? RD (which will break the string check as it'll wrap it with '' which will RD cause MySQL to insert -00-00 00:00:00) or if it's an enum field RD with a numeric allowed value? :) MA Not really, since you usally format a timestamp into something thats db MA friendly. How many times have you written code where the date 02-01-2004 But now() IS a DB friendly format for MySQL and is the recommended way of inserting the current time into a datetime or timestamp field. Converting it to a timestamp/datetime locally first is a waste of processing time IMHO and opens you up to a potential (although slight) code error. But, to get your function working, I can see the point :) -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confused big time
RD But now() IS a DB friendly format for MySQL and is the recommended RD way of inserting the current time into a datetime or timestamp RD field. But what about MsSQL, Oracle and postgres to name a few. I have worked on a few projects where you read from one db and load into another db. Dates then become the spawn of satan. RD Converting it to a timestamp/datetime locally first is a waste of RD processing time IMHO and opens you up to a potential RD slight) True that it wastes CPU time, but in todays climate, having developers churning out manageable , readable code is better then something that looks like the perl DeCSS program. If you need the nano seconds that much buy a better box !. Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re[2]: [PHP] confused big time
Hello Mark, Wednesday, April 7, 2004, 6:35:31 PM, you wrote: MA But what about MsSQL, Oracle and postgres to name a few. I have worked MA on a few projects where you read from one db and load into another db. MA Dates then become the spawn of satan. But the MySQL syntax for insert is not the same for other DBs, so you'll ideally need one insert function per DB type anyway :) at which point my original comment applies again. There are other scenarios too.. i.e. INSERT INTO table (val, val2) VALUES (1, val+1) MA True that it wastes CPU time, but in todays climate, having developers MA churning out manageable , readable code is better then something that MA looks like the perl DeCSS program. If you need the nano seconds that MA much buy a better box !. The way people on the list suggested formatting the query IS readable and quickly debug'able to anyone who understands SQL. Obfuscating that into a function could be considered un-readable to some? But, whatever floats your boat mate ;) -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confused big time
You could even do: $sql .= ( '.implode( ',' , $a ).' ); This way everything is quoted though ( but this doesn't matter using MySQL anyway ). If you want to escape the values of $a you could use array_map to do this also without having to loop :-) -- red [...] To get your list of columns, you could do this: $column_list = implode(',',array_keys($a)); $sql = INSERT INTO $tablename ($column_list) VALUES ; That way you only have to loop through $a once. [...] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] confused big time
Andy B mailto:[EMAIL PROTECTED] on Tuesday, April 06, 2004 7:56 PM said: $query=insert into table values( '{$array['index1']['index2']}', '{$array[index2']['index3']}', //so on down the list ); if i understand the readable way right... no, not quite. here is how you should do it (imo): 1. always write SQL commands in upper case. i.e. SELECT name FROM table 2. indent the different sections of the query. i'm not sure that i'm indenting correctly, but i'm basically just copying SQL statements i've seen in the past, as far as indentation goes. $query = INSERT INTO table VALUES ( '{$array['index1']['index2']}' , '{$array['index2']['index3']}' ); oh btw if you do something like that is it possible to insert comments in the middle of a query like that without breaking it up (i.e. for huge queries comment on what the variables are for)?? yes. i don't know if mysql supports them but i think it works like this: $query = INSERT INTO table /* comment */ VALUES ( '{$array['index1']['index2']}' , '{$array['index2']['index3']}' ); hth, chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confused big time
- Original Message - From: Chris W. Parker [EMAIL PROTECTED] To: Andy B [EMAIL PROTECTED] Sent: Wednesday, April 07, 2004 6:30 PM Subject: RE: [PHP] confused big time Andy B mailto:[EMAIL PROTECTED] on Wednesday, April 07, 2004 2:09 PM said: yes you can absolutely do it that way. in this case it's just a matter of preference. got it tnx i think we can close this tread now ok. i hope i've been helpful. sure arekeep up good work -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] confused big time
hi... i have 2 mysql queries first one: //the extra { at the beginning and the extra , at the end of //each variable should be an '... insert into $EventsTable values(NULL, '{$_SESSION[add][type]}', '{$_SESSION[add][start_date]}', '{$_SESSION[add][end_date]}', '{$_SESSION[add][name]}', '{$_SESSION[add][county]}', '{$_SESSION[add][discription]}', '{$_SESSION[add][StartingDay]}', '{$_SESSION[add][StartingMonth]}', '{$_SESSION[add][StartingYear]}', '{$_SESSION[add][EndingDay]}', '{$_SESSION[add][EndingMonth]}', '{$_SESSION[add][EndingYear]}'; and the other one: insert into $GuestbookTable values(NULL, '{$_SESSION[add][date]}', '{$_SESSION[add][name]}', '{$_SESSION[add][email]}', '{$_SESSION[add][website]}', '{$_SESSION[add][referred]}', '{$_SESSION[add][comments]}'); they both use the same identical format to insert the arrays. there is an interesting problem though: the first one complains about use of undefined constant add - assumed 'add' in the second query...the first one doesnt do that?? everything is set up exactly the same for both queries except the relevant variable/array names...
RE: [PHP] confused big time
Andy B mailto:[EMAIL PROTECTED] on Tuesday, April 06, 2004 4:51 PM said: they both use the same identical format to insert the arrays. there is an interesting problem though: the first one complains about use of undefined constant add - assumed 'add' in the second query...the first one doesnt do that?? everything is set up exactly the same for both queries except the relevant variable/array names... two things i would recommend before disecting your code. 1. write readable queries. GOOD: $sql = SELECT name , age , height , etc FROM user WHERE name = '$name' AND height = '5'; 2. always put single quotes around array keys. $array['key'] hth, chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] confused big time
two things i would recommend before disecting your code. 1. write readable queries. GOOD: $sql = SELECT name , age , height , etc FROM user WHERE name = '$name' AND height = '5'; 2. always put single quotes around array keys. $array['key'] 1. how were those queries unreadable?? and 2. whenever i put '' around the array keys in multi dimensional arrays in a query i get a parse error of trying to use undefined keys or it doesnt expand the array all the way... and 3. when i used the {} on the arrays and the '' around the keys all i got was parse error because of the '' around them... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] confused big time
Chris W. Parker on Tuesday, April 06, 2004 5:01 PM said: let me expand both of my points in an attempt to be more verbose. 1. write readable queries. 2. always put single quotes around array keys. $array['key'] here is how i would write your query: ?php $sql = insert into $EventsTable values( NULL , '{$_SESSION['add']['type]}' , '{$_SESSION['add']['start_date']}' , '{$_SESSION['add']['end_date']}' , '{$_SESSION['add']['name']}' , '{$_SESSION['add']['county']}' , '{$_SESSION['add']['discription']}' , '{$_SESSION['add']['StartingDay']}' , '{$_SESSION['add']['StartingMonth']}' , '{$_SESSION['add']['StartingYear']}' , '{$_SESSION['add']['EndingDay']}' , '{$_SESSION['add']['EndingMonth']}' , '{$_SESSION['add']['EndingYear']}'; $sql = insert into $GuestbookTable values( NULL , '{$_SESSION['add']['date']}' , '{$_SESSION['add']['name']}' , '{$_SESSION['add']['email']}' , '{$_SESSION['add']['website']}' , '{$_SESSION['add']['referred']}' , '{$_SESSION['add']['comments']}'); hth, chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] confused big time
MINE: $sql = SELECT name , age , height , etc FROM user WHERE name = '$name' AND height = '5'; um...im not doing selects im doing inserts with variable names... i understand the idea with select but thats not the dealits an insert... and i will retry using the '' on the keys again and make sure my query code is the way it should be... has to be a '' out of place somewhere or something... will let you know what happens and if it doesnt work i will put the errors and code here... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confused big time
Hello Andy, Wednesday, April 7, 2004, 1:06:52 AM, you wrote: AB 1. how were those queries unreadable?? and You're kidding, right? AB 2. whenever i put '' around the array keys in multi dimensional arrays in a AB query i get a parse error of trying to use undefined keys or it doesnt AB expand the array all the way... and If you don't include '' PHP will assume you are trying to use a constant, which (as you haven't defined one anywhere) obviously you're not. $something = $my_array['area1']['blah']['value']; .. is the correct syntax, assuming the array is created as such. $something = $my_array[area1][blah][value]; .. will give you a Constant Undefined error warning, as it should. AB 3. when i used the {} on the arrays and the '' around the keys all i got was AB parse error because of the '' around them... Try this - right before your query dump out the value of $_SESSION with either var_dump() or print_r() - see if ALL of the values you are trying to insert into your query are present and correct. I have a feeling you'll find they aren't. BTW you don't need to insert NULL values in MySQL, you can just not insert anything if null is the default anyway for that field. -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confused big time
Hello Andy, Wednesday, April 7, 2004, 1:18:06 AM, you wrote: AB um...im not doing selects im doing inserts with variable names... i AB understand the idea with select but thats not the dealits an insert... He was showing you a neatly formatted query, the example applies to inserts too: $sql = INSERT INTO tablename ( field1, field2, field3 ) VALUES ( '$blah', $here', '$etc' ) ; There you have a visually instant way of telling where the missing ' is. -- Best regards, Richard Davey http://www.phpcommunity.org/wiki/296.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [fixed!][PHP] confused big time
ok query is fixed for the second one now... now to work on the if(!empty.. tests i have to check and make sure every one of those arrays isnt empty. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] confused big time
Andy B mailto:[EMAIL PROTECTED] on Tuesday, April 06, 2004 5:18 PM said: um...im not doing selects im doing inserts with variable names... i understand the idea with select but thats not the dealits an insert... i was hoping that wouldn't cause any confusion, but i guess it did. the thing to remember is that a query is a query. you know, parts is parts. here is your first query, written better. ?php $sql = INSERT INTO $EventsTable VALUES ( NULL , '{$_SESSION['add']['type']}' , '{$_SESSION['add']['start_date']}' , '{$_SESSION['add']['end_date']}' , '{$_SESSION['add']['name']}' , '{$_SESSION['add']['county']}' , '{$_SESSION['add']['discription']}' , '{$_SESSION['add']['StartingDay']}' , '{$_SESSION['add']['StartingMonth']}' , '{$_SESSION['add']['StartingYear']}' , '{$_SESSION['add']['EndingDay']}' , '{$_SESSION['add']['EndingMonth']}' , '{$_SESSION['add']['EndingYear']}'; ? hth, chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] confused big time
um...im not doing selects im doing inserts with variable names... i understand the idea with select but thats not the dealits an insert... i was hoping that wouldn't cause any confusion, but i guess it did. the thing to remember is that a query is a query. you know, parts is parts. here is your first query, written better. ?php $sql = INSERT INTO $EventsTable VALUES ( NULL , '{$_SESSION['add']['type']}' , '{$_SESSION['add']['start_date']}' , '{$_SESSION['add']['end_date']}' , '{$_SESSION['add']['name']}' , '{$_SESSION['add']['county']}' , '{$_SESSION['add']['discription']}' , '{$_SESSION['add']['StartingDay']}' , '{$_SESSION['add']['StartingMonth']}' , '{$_SESSION['add']['StartingYear']}' , '{$_SESSION['add']['EndingDay']}' , '{$_SESSION['add']['EndingMonth']}' , '{$_SESSION['add']['EndingYear']}'; ? Also noting that there's no closing parenthesis... But maybe it's being added in a following line. Martin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confused big time
He was showing you a neatly formatted query, the example applies to inserts too: $sql = INSERT INTO tablename ( field1, field2, field3 ) VALUES ( '$blah', $here', '$etc' ) ; There you have a visually instant way of telling where the missing ' is. -- Best regards, Richard Davey sorry i got it now... didnt quite get it all right away but it does look better that way more than anything (at least easier to deal with)... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confused big time
AB 1. how were those queries unreadable?? and You're kidding, right? sorry...my bad... never had any writing readable code help anywhere...guess if i do it like c/c++ then it would work better AB 2. whenever i put '' around the array keys in multi dimensional arrays in a AB query i get a parse error of trying to use undefined keys or it doesnt AB expand the array all the way... and If you don't include '' PHP will assume you are trying to use a constant, which (as you haven't defined one anywhere) obviously you're not. $something = $my_array['area1']['blah']['value']; .. is the correct syntax, assuming the array is created as such. $something = $my_array[area1][blah][value]; .. will give you a Constant Undefined error warning, as it should. i keep getting confused on when i need to use a {} around the array to expand it first of all (never had to use them before). the next part of my problem was getting confused with where '' needed to go. i forgot/didnt understand that the '' around the variable/array itself was for mysql server use only and php ignores them to the point that it doesnt parse them (thought it expanded them when using the {} thing). as far as when to put '' around index names in arrays im still confused somewhat on that one: echo $array['index'];//the right way echo $array[index];//right way?? at least i dont get //errors echo $array$array[\'index\'];//works on my server but //never use it AB 3. when i used the {} on the arrays and the '' around the keys all i got was AB parse error because of the '' around them... Try this - right before your query dump out the value of $_SESSION with either var_dump() or print_r() - see if ALL of the values you are trying to insert into your query are present and correct. I have a feeling you'll find they aren't. hmmm well i wont post my $_SESSION var dump here because it took a while just for me to read it... they are all there just the way they should (like i said above i referrenced them the wrong way)... BTW you don't need to insert NULL values in MySQL, you can just not insert anything if null is the default anyway for that field. hmmm the way the table was set up is a timestamp(14) field called Posted and a value of some kind is required because the table was set up with: Posted timestamp(14) default not null so as far as i know of a value of some kind is required (NULL itself or some date string)... sorry for all the trouble with stuff (still dont get lots of stuff) havent done php/mysql stuff for a year yet so kind of new at it i guess... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confused big time
i was hoping that wouldn't cause any confusion, but i guess it did. the thing to remember is that a query is a query. you know, parts is parts. oops stress and the fact that im sort of new at this stuff mixed me up... $query=insert into table values( '{$array['index1']['index2']}', '{$array[index2']['index3']}', //so on down the list ); if i understand the readable way right... oh btw if you do something like that is it possible to insert comments in the middle of a query like that without breaking it up (i.e. for huge queries comment on what the variables are for)?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] confused about logic
Hi All, I have input for where users can enter order numbers in which to search the database to find results matching their entry. To enter multiple order numbers they can comma separate like: 1,34,21,34,54 What I need to do is take those numbers and make a query that would like like: (cart_id in('1','34','21','34','54') OR id in('1','34','21','34','54')) ANY idea how I can accomplish this? Thanks all! Aaron
Re: [PHP] confused about logic
To enter multiple order numbers they can comma separate like: 1,34,21,34,54 What I need to do is take those numbers and make a query that would like like: (cart_id in('1','34','21','34','54') OR id in('1','34','21','34','54')) ANY idea how I can accomplish this? $string = ' . implode( ', ', explode( ',', '1,34,21,34,54' )) . '; echo (cart_id in( $string ) OR id in( $string )); Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] confused about logic
From: Aaron Wolski [EMAIL PROTECTED] I have input for where users can enter order numbers in which to search the database to find results matching their entry. To enter multiple order numbers they can comma separate like: 1,34,21,34,54 What I need to do is take those numbers and make a query that would like like: (cart_id in('1','34','21','34','54') OR id in('1','34','21','34','54')) Why do you need to put quotes around integers?? $var = '1,34,21,34,54'; //replace comma with quote,comma,quote and add quotes to beginning and end $in_clause = ' . str_replace(',',',',$var) . '; $query = WHERE (cart_id IN ($in_clause) OR id IN ($in_clause)); ---John Holmes... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] confused about logic
Chris! Thanks so much. This worked perfectly Aaron -Original Message- From: Chris Boget [mailto:[EMAIL PROTECTED] Sent: March 19, 2004 10:59 AM To: Aaron Wolski; [EMAIL PROTECTED] Subject: Re: [PHP] confused about logic To enter multiple order numbers they can comma separate like: 1,34,21,34,54 What I need to do is take those numbers and make a query that would like like: (cart_id in('1','34','21','34','54') OR id in('1','34','21','34','54')) ANY idea how I can accomplish this? $string = ' . implode( ', ', explode( ',', '1,34,21,34,54' )) . '; echo (cart_id in( $string ) OR id in( $string )); Chris -- 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] confused about logic
Thanks for the time John. Chris's did the trick. I'll keep yours on hand in case I do happen to run into problems. I DO appreciate your help. Thanks again! Aaron -Original Message- From: John W. Holmes [mailto:[EMAIL PROTECTED] Sent: March 19, 2004 11:28 AM To: Aaron Wolski; [EMAIL PROTECTED] Subject: Re: [PHP] confused about logic From: Aaron Wolski [EMAIL PROTECTED] I have input for where users can enter order numbers in which to search the database to find results matching their entry. To enter multiple order numbers they can comma separate like: 1,34,21,34,54 What I need to do is take those numbers and make a query that would like like: (cart_id in('1','34','21','34','54') OR id in('1','34','21','34','54')) Why do you need to put quotes around integers?? $var = '1,34,21,34,54'; //replace comma with quote,comma,quote and add quotes to beginning and end $in_clause = ' . str_replace(',',',',$var) . '; $query = WHERE (cart_id IN ($in_clause) OR id IN ($in_clause)); ---John Holmes... -- 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] confused about logic
Thanks for the time John. Chris's did the trick. I'll keep yours on hand in case I do happen to run into problems. I DO appreciate your help. John's solution is actually technically better than mine in that it's only using one function call (str_replace()) and as such only one possible point of failure whereas mine is using 2 (explode() and implode()) with 2 possible points of failure. This is all totally academic but am just pointing out... Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Confused a little with = to and grater than ...
Well i thought about changeing access levels into numbers so that only LARGER numbers can access lower numbers and Lower numbers can't access anything higher ... if that makes sence ... So 3 can access 2 and 1, 2 can't access 3, but can access 2 and 1 and one can't access 2 or 3, but can 1 ... assuming that $siteAccessLevel is = to eather level-1, level-2 or level-3 ... if ($slevel = $glevel) { is the line i can't seem to get right. *GRIN* any help? code below. if ($siteAccessLevel == level-1) { $slevel = 1; } else if ($siteAccessLevel == level-2) { $slevel = 2; } else if ($siteAccessLevel == level-3) { $slevel = 3; } if ($gAccessLevel == level-1) { $glevel = 1; } else if ($gAccessLevel == level-2) { $glevel = 2; } else if ($gAccessLevel == level-3) { $glevel = 3; } if ($slevel = $glevel) { //LOAD PAGE }else { // ERROR MESSAGE HERE. { -- Philip J. Newman. Head Developer [EMAIL PROTECTED] +64 (9) 576 9491 +64 021-048-3999 -- Friends are like stars You can't allways see them, but they are always there. -- Websites: PhilipNZ.com - Design. http://www.philipnz.com/ [EMAIL PROTECTED] Philip's Domain // Internet Project. http://www.philipsdomain.com/ [EMAIL PROTECTED] Vital Kiwi / NEWMAN.NET.NZ. http://www.newman.net.nz/ [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Confused a little with = to and grater than ...
I think this is what you mean ?php // This looks cleaner, and is a lot easyer to read! $siteAccessLevel = 2; $gAccessLevel = 1; switch ($siteAccessLevel) { case level-1: $slevel = 0; break; case level-2: $slevel = 1; break; case level-3: $slevel = 2; break; } switch ($gAccessLevel) { case level-1: $glevel = 1; break; case level-2: $glevel = 2; break; case level-3: $glevel = 3; break; } if ($slevel $glevel) { echo Access Granted; }else{ echo You don't belong; } ? -Original Message- From: Philip J. Newman [mailto:[EMAIL PROTECTED] Sent: Saturday, March 15, 2003 8:29 PM To: [EMAIL PROTECTED] Subject: [PHP] Confused a little with = to and grater than ... Importance: Low Well i thought about changeing access levels into numbers so that only LARGER numbers can access lower numbers and Lower numbers can't access anything higher ... if that makes sence ... So 3 can access 2 and 1, 2 can't access 3, but can access 2 and 1 and one can't access 2 or 3, but can 1 ... assuming that $siteAccessLevel is = to eather level-1, level-2 or level-3 ... if ($slevel = $glevel) { is the line i can't seem to get right. *GRIN* any help? code below. if ($siteAccessLevel == level-1) { $slevel = 1; } else if ($siteAccessLevel == level-2) { $slevel = 2; } else if ($siteAccessLevel == level-3) { $slevel = 3; } if ($gAccessLevel == level-1) { $glevel = 1; } else if ($gAccessLevel == level-2) { $glevel = 2; } else if ($gAccessLevel == level-3) { $glevel = 3; } if ($slevel = $glevel) { //LOAD PAGE }else { // ERROR MESSAGE HERE. { -- Philip J. Newman. Head Developer [EMAIL PROTECTED] +64 (9) 576 9491 +64 021-048-3999 -- Friends are like stars You can't allways see them, but they are always there. -- Websites: PhilipNZ.com - Design. http://www.philipnz.com/ [EMAIL PROTECTED] Philip's Domain // Internet Project. http://www.philipsdomain.com/ [EMAIL PROTECTED] Vital Kiwi / NEWMAN.NET.NZ. http://www.newman.net.nz/ [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Confused about $_SESSION and $_COOKIE scope..
I'm not sure why this isn't working, been banging my head at it for a couple hours now. I have a file (index.php), which calls a function that draws the header to my page. Inside that function (site_header), is an include to a file (menu.php) which draws dynamic javascript menus based on cookie or session values. I can't seem to access ANY variables, be them $_SESSION, $_COOKIE, or anything else, inside this menu.php file. I've tried even passing simple variables, globalizing them, etc, all the way down to see if I can access them in that menu.php file. I still can't.. the closest I get is being able to access them in the site_header function, but when the include(menu.php) is called, everything seems to vanish. And yes, I have session_start(); at the top of my menu.php file as well.. Can anyone help me out on this? I was under the impression that the superglobals would be available from basically anything.. apparently I was wrong. Thanks, Chad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php