[PHP] Array Question
Is there a php function similar to in_array that can detect if a partial value is in an array value or not: e.g. $var1 = big horse;$var2 = small yellow;$var3 = red hydrant; $theArray = array(big blue horse, small yellow bird, giant red hydrant); Is there a way to find out if $var1 in $theArray or $var2 etc.? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to pass connection as global variable ?
I have various PHP scripts that use the same database. The startup script default.php sets the connection once for all the scripts. This connection is set in $_SESSION to make it a global variable for all scripts. When switching from page default to page faq, I get errors I can't explain. Any help is highly appreciated. TIA, Cor default.php ?php session_start(); require(menu.php); ... $link = mysqli_connect($mysqlhost, $mysqluser, $mysqlpsw, $mysqldb) or die(cannot connect); $_SESSION['connection'] = $link; ... ? faq.php --- ?php require(menu.php); $link = $_SESSION['connection']; $sql = SELECT Question, Answer FROM myfaqs; $result = mysqli_query($link, $sql); // previous line gives: //Notice: Undefined variable: _SESSION in C:\Inetpub\wwwroot\test\faq.php //Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\Inetpub\wwwroot\test\faq.php ... ?
Re: [PHP] How to pass connection as global variable ?
C.R.Vegelin wrote: I have various PHP scripts that use the same database. The startup script default.php sets the connection once for all the scripts. This connection is set in $_SESSION to make it a global variable for all scripts. When switching from page default to page faq, I get errors I can't explain. Any help is highly appreciated. TIA, Cor default.php ?php session_start(); require(menu.php); snip faq.php --- ?php require(menu.php); The first two lines give it away ;) You're missing a session_start(). -- 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] How to pass connection as global variable ?
- Original Message - From: Chris [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] php-general@lists.php.net Sent: Wednesday, July 11, 2007 8:56 AM Subject: Re: [PHP] How to pass connection as global variable ? C.R.Vegelin wrote: I have various PHP scripts that use the same database. The startup script default.php sets the connection once for all the scripts. This connection is set in $_SESSION to make it a global variable for all scripts. When switching from page default to page faq, I get errors I can't explain. Any help is highly appreciated. TIA, Cor default.php ?php session_start(); require(menu.php); snip faq.php --- ?php require(menu.php); The first two lines give it away ;) You're missing a session_start(). -- Postgresql php tutorials http://www.designmagick.com/ Thanks Chris, I included session_start(); as first line in faq.php, but now I get other warnings /errors: Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli in line $result = mysqli_query($link, $sql); Warning: mysqli_error() [function.mysqli-error]: Couldn't fetch mysqli in line if (!$result) { echo Can't execute query ($sql): . mysqli_error($link); exit; } Any idea why ? Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to pass connection as global variable ?
C.R.Vegelin wrote: - Original Message - From: Chris [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] php-general@lists.php.net Sent: Wednesday, July 11, 2007 8:56 AM Subject: Re: [PHP] How to pass connection as global variable ? C.R.Vegelin wrote: I have various PHP scripts that use the same database. The startup script default.php sets the connection once for all the scripts. This connection is set in $_SESSION to make it a global variable for all scripts. When switching from page default to page faq, I get errors I can't explain. Any help is highly appreciated. TIA, Cor default.php ?php session_start(); require(menu.php); snip faq.php --- ?php require(menu.php); The first two lines give it away ;) You're missing a session_start(). -- Postgresql php tutorials http://www.designmagick.com/ Thanks Chris, I included session_start(); as first line in faq.php, but now I get other warnings /errors: Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli in line $result = mysqli_query($link, $sql); Warning: mysqli_error() [function.mysqli-error]: Couldn't fetch mysqli in line if (!$result) { echo Can't execute query ($sql): . mysqli_error($link); exit; } Actually - shoot me for not noticing this before. You can't store a resource or connection in the session. You have to recreate your connection in each page. See http://php.net/session . -- 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] How to pass connection as global variable ?
C.R.Vegelin wrote: I have various PHP scripts that use the same database. The startup script default.php sets the connection once for all the scripts. This connection is set in $_SESSION to make it a global variable for all scripts. When switching from page default to page faq, I get errors I can't explain. Any help is highly appreciated. TIA, Cor default.php ?php session_start(); require(menu.php); snip faq.php --- ?php require(menu.php); The first two lines give it away ;) You're missing a session_start(). -- Postgresql php tutorials http://www.designmagick.com/ Thanks Chris, I included session_start(); as first line in faq.php, but now I get other warnings /errors: Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli in line $result = mysqli_query($link, $sql); Warning: mysqli_error() [function.mysqli-error]: Couldn't fetch mysqli in line if (!$result) { echo Can't execute query ($sql): . mysqli_error($link); exit; } Actually - shoot me for not noticing this before. You can't store a resource or connection in the session. You have to recreate your connection in each page. See http://php.net/session . -- Postgresql php tutorials http://www.designmagick.com/ Hi Chris, I recreated a new connection in faq.php and it's working now. I had the impression that 1 connection could last during a user session, but apparently a user session may need many connections. Thanks again, Cor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Question
On 11/07/07, kvigor [EMAIL PROTECTED] wrote: Is there a php function similar to in_array that can detect if a partial value is in an array value or not: e.g. $var1 = big horse;$var2 = small yellow;$var3 = red hydrant; $theArray = array(big blue horse, small yellow bird, giant red hydrant); Is there a way to find out if $var1 in $theArray or $var2 etc.? There's not a built in function, but it's not hard to write one: function partial_in_array($needle, $haystack) { if (!is_array($needle)) { $needle = array($needle); } $needle = array_map('preg_quote', $needle); foreach ($needle as $pattern) { if (count(preg_grep(/$pattern/, $haystack)) 0) return true; } return false; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to pass connection as global variable ?
C.R.Vegelin wrote: C.R.Vegelin wrote: I have various PHP scripts that use the same database. The startup script default.php sets the connection once for all the scripts. This connection is set in $_SESSION to make it a global variable for all scripts. When switching from page default to page faq, I get errors I can't explain. Any help is highly appreciated. TIA, Cor default.php ?php session_start(); require(menu.php); snip faq.php --- ?php require(menu.php); The first two lines give it away ;) You're missing a session_start(). -- Postgresql php tutorials http://www.designmagick.com/ Thanks Chris, I included session_start(); as first line in faq.php, but now I get other warnings /errors: Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli in line $result = mysqli_query($link, $sql); Warning: mysqli_error() [function.mysqli-error]: Couldn't fetch mysqli in line if (!$result) { echo Can't execute query ($sql): . mysqli_error($link); exit; } Actually - shoot me for not noticing this before. You can't store a resource or connection in the session. You have to recreate your connection in each page. See http://php.net/session . -- Postgresql php tutorials http://www.designmagick.com/ Hi Chris, I recreated a new connection in faq.php and it's working now. I had the impression that 1 connection could last during a user session, but apparently a user session may need many connections. Thanks again, Cor Remember that the http protocol is stateless. Every request made is a new connection to the server. It's due to extra technologies like cookies (and in this case sessions) that some form of 'state' can be maintained. However, because there is no communication between client and server unless the client makes a request you can never actually determine the _current_ status of your session, only in retrospect you can. If a user makes a request, you could say the session is 'in progress', however, after sending that page you don't know if it's still 'in progress' or has ended until you recieve another request, thus telling you it WAS still in progress. Now, as for resources and connections: PHP clears up everything when it finishes sending a response to a request. This does not happen for certain very specific items which were stored away (like in a database or in a session, which is usually just a file). For a connection to be 'open' it needs to be able to communicate with both its' sides (client: your database; and the 'server': PHP), if php 'shuts down' because it finished the request, it doesn't leave anything of itself behind, and as such the 'server' of that connection also disappears, thus creating a broken link which is automatically destroyed. Of course the php engine is smart and knows this would happen, so it 'cleanly' closes the connection before disappearing to reappear again (fresh) on a next request. hope that helps you understand, - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to pass connection as global variable ?
Hi Chris, I recreated a new connection in faq.php and it's working now. I had the impression that 1 connection could last during a user session, but apparently a user session may need many connections. Thanks again, Cor Have a read on persistent connections Regards, Clive. {No electrons were harmed in the creation, transmission or reading of this email. However, many were excited and some may well have enjoyed the experience.} -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php code in html buttons
Hello, What about this. test.php ?php if(isset($_REQUEST['sqlProcess'])) { switch($_REQUEST['sqlProcess']) { case query1: $sql= SELECT FOO FORM BAR WHERE BAZ='BAR' break; } $res = mysqli_query($connect,$sql); } if(!isset($res)) { $strReturn = form name='test' method='post' action='' input type='submit' name='submit' value='click' / input type='hidden' name='sqlProcess' value='query1' / /form } else { $strReturn = do whatever want to with your mysql result; } echo $strReturn; ? Hope helps. To ajaxing this page please look www.xajaxproject.org Regards On Wednesday 11 July 2007 01:59:42 k w wrote: I'm trying to make a button execute some php code when the button is clicked. I'm not sure if it is the button i'm coding wrong or the php code. Here is the code I am using. ?php echo button action='?php mysqli_query($connect,$query)?'Click/button; ? I've got all my variables stored in the php page, and I know they are all correct. But when I push the button it does nothing. I'm not quite sure what I am doing wrong. I have also tried input type=button value=Click OnClick= ?php mysqli_query($connect,$query); ? and form onclick=?php mysqli_query($connect,$query); ? input type=button value=Click /form Obviously i'm a complete newbie. I'd appreciate any help. Thanks. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to pass connection as global variable ?
On 7/11/07, clive [EMAIL PROTECTED] wrote: Hi Chris, I recreated a new connection in faq.php and it's working now. I had the impression that 1 connection could last during a user session, but apparently a user session may need many connections. Thanks again, Cor Have a read on persistent connections That won't help. All that does is tell the database server to leave the connection lying around *just in case* someone else decides that a connection is needed. http://php.net/mysql_pconnect explains it. -- 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] How to pass connection as global variable ?
Thanks M. Sokolewicz for explaining the under water basics ... Cor - Original Message - From: M. Sokolewicz [EMAIL PROTECTED] To: C.R.Vegelin [EMAIL PROTECTED] Cc: Chris [EMAIL PROTECTED]; [EMAIL PROTECTED] php-general@lists.php.net Sent: Wednesday, July 11, 2007 9:56 AM Subject: Re: [PHP] How to pass connection as global variable ? C.R.Vegelin wrote: C.R.Vegelin wrote: I have various PHP scripts that use the same database. The startup script default.php sets the connection once for all the scripts. This connection is set in $_SESSION to make it a global variable for all scripts. When switching from page default to page faq, I get errors I can't explain. Any help is highly appreciated. TIA, Cor default.php ?php session_start(); require(menu.php); snip faq.php --- ?php require(menu.php); The first two lines give it away ;) You're missing a session_start(). -- Postgresql php tutorials http://www.designmagick.com/ Thanks Chris, I included session_start(); as first line in faq.php, but now I get other warnings /errors: Warning: mysqli_query() [function.mysqli-query]: Couldn't fetch mysqli in line $result = mysqli_query($link, $sql); Warning: mysqli_error() [function.mysqli-error]: Couldn't fetch mysqli in line if (!$result) { echo Can't execute query ($sql): . mysqli_error($link); exit; } Actually - shoot me for not noticing this before. You can't store a resource or connection in the session. You have to recreate your connection in each page. See http://php.net/session . -- Postgresql php tutorials http://www.designmagick.com/ Hi Chris, I recreated a new connection in faq.php and it's working now. I had the impression that 1 connection could last during a user session, but apparently a user session may need many connections. Thanks again, Cor Remember that the http protocol is stateless. Every request made is a new connection to the server. It's due to extra technologies like cookies (and in this case sessions) that some form of 'state' can be maintained. However, because there is no communication between client and server unless the client makes a request you can never actually determine the _current_ status of your session, only in retrospect you can. If a user makes a request, you could say the session is 'in progress', however, after sending that page you don't know if it's still 'in progress' or has ended until you recieve another request, thus telling you it WAS still in progress. Now, as for resources and connections: PHP clears up everything when it finishes sending a response to a request. This does not happen for certain very specific items which were stored away (like in a database or in a session, which is usually just a file). For a connection to be 'open' it needs to be able to communicate with both its' sides (client: your database; and the 'server': PHP), if php 'shuts down' because it finished the request, it doesn't leave anything of itself behind, and as such the 'server' of that connection also disappears, thus creating a broken link which is automatically destroyed. Of course the php engine is smart and knows this would happen, so it 'cleanly' closes the connection before disappearing to reappear again (fresh) on a next request. hope that helps you understand, - Tul -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Anyone have an iPhone? OT
Hi gang: Totally off topic. If you bought an iPhone, please contact me off-list -- I have a question. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Creating 'Next' 'Previous' for PHP Photo Gallery
Jim, Code looks extremely promising well explained - let me give it a try and work it out. I'm sure to hit snags - but can't thank you enough. The one thing that comes straight off in my mind looking at the code is - and I may be addressing this prematurely since I haven't tried the code yet - but my thumbnails are in a Separate .php page, and each thumbnail links to the full image which are in a Separate .php page. The Next Previous link I'm trying to create are to be displayed on the full image page. But let me integrate the code and see how I can pass the values along to pages and make it work. Thanks again! On 7/10/07 11:04 AM, Jim Lucas [EMAIL PROTECTED] wrote: Rahul Sitaram Johari wrote: I¹m trying to write a Photo Gallery in PHP. Everything else is pretty much worked out like thumbnails, indexes, titles all the one thing I¹m stuck at is the Next Previous links for the Photos on the main Photo Page. It¹s a simple program where you drop images in a folder and glob() picks up the thumbnails displays them on a page which are automatically linked to the Full Size Images. This is the code: ? $ID = $_GET['ID']; The following code is completely untested. I typed it straight into the email client. You might have to track down a few bugs. It should give you a good start though # Set your page display limit $display_limit = 20; # Collect a list of files $filelist = glob($ID/thumbnails/*.jpg); # get the current page number, set the default to 1 $pageNum = 1; if ( !empty($_GET['pageNum']) ) { $pageNum = (int)$_GET['pageNum']; } # count the total number of files to list $total_files = count($filelist); # calculate the total number of pages to be displayed $total_pages = ceil($total_files/$display_limit); # Initialize the link holder array $links = array(); # Since I don't know the name of your script, I assume that it should link to itself # So I will use $_SERVER['SCRIPT_NAME'] to get the scripts true name # Create Previous tag is needed if ( $pageNum 1 ) { $links[] = a href='{$_SERVER['SCRIPT_NAME']}?ID={$_GET['ID']}pageNum=.($pageNum-1).'Pre vious/a; } # Create Next tag is needed if ( $pageNum $total_pages ) { $links[] = a href='{$_SERVER['SCRIPT_NAME']}?ID={$_GET['ID']}pageNum=.($pageNum+1).'Nex t/a; } # Display the link if they exist echo '[ '.join(' | ', $links).' ]'; foreach ($filelist as $key=$value) { $title = rtrim(basename($value),'.jpg'); $newtitle = preg_replace('/_/', ' ', $title); ? A HREF=photo.php?photo=?php echo basename($value); ?title=?php echo $newtitle; ?ID=?php echo $_GET['ID']; ?KEY=?php echo $key; ? TARGET=photoFrame IMG SRC=?php echo $ID; ?/thumbnails/?php echo basename($value); ?/A ?php echo $newtitle; ? ? } ? I know that $key holds the sequence of images that are being picked up by glob() - I¹m just trying to figure out a way to use this $key to generate the Next Previous link. The problem is everything is passed on to a separate page (photo.php) ... What I¹m thinking is determining which Photo File would be Next or Previous to the one being selected, and passing that along to the (photo.php) page. I¹m just not able to figure out how to pick out the next previous filename and place it in the Query String. Any suggestions? ~~~ Rahul Sitaram Johari CEO, Twenty Four Seventy Nine Inc. W: http://www.rahulsjohari.com E: [EMAIL PROTECTED] ³I morti non sono piu soli ... The dead are no longer lonely² -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] duration of mp3 file
Allow bunnies ... Any takers on this ... I JUST want the duration of the mp3 file - with a small function if possible ... I honestly don't want to use a class like http://www.phpclasses.org/browse/package/112.html The coding is terrible and SERIOUSLY over inflated for what I want. Anyone know of a simple class / function ? S -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checking Post Data against DB Data
OK Chris, I understand that we're checking checking the form data and escaping it, but can explain what's going on in the WHERE clause and 1=1 tad bit more. Chris [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] kvigor wrote: /*Good Morning to All, I am having an issue with the following code. I'm trying to match $newRegistrant(which is concatenated form data) with $oldRegistrant(which is concatenated DB data). First thing I'd suggest is making the code clearer about what's going on. Doing it the way I have below will also make it faster because you don't have to check every registrant to see if they already there - make the database do the work for you. $newRegistrant_query = SELECT conName,conAddress,conCity,conState,conPhone,schName,schCity,schState,strName,strCity,strState FROM central WHERE ; if(isset($_POST['submit'])) { $fields_to_check = array('conName', 'conAddress', 'conCity' . add more fields here); foreach ($fields_to_check as $field_name) { $newRegistrant_query .= $field_name . =' . mysql_real_escape_string($_POST[$field_name]) . ' AND ; } // you can either remove the last AND from the query or just add this on so you don't need to worry about a mal-formed query. $newRegistrant_query .= 1=1; } Then $matchQueryResult_result = mysql_query($newRegistrant_query,$connection) or die (Query Failed.mysql_error()); $found_registrant = false; while ($row = mysql_fetch_assoc($matchQueryResult_result)) { $found_registrant = true; // check your datestamps. } // they have never registered before if (!$found_registrant) { // make up an insert query and add them. } makes it a lot easier to read and be a lot easier to debug. -- 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] duration of mp3 file
Allow bunnies ... Any takers on this ... I JUST want the duration of the mp3 file - with a small function if possible ... I honestly don't want to use a class like http://www.phpclasses.org/browse/package/112.html The coding is terrible and SERIOUSLY over inflated for what I want. Anyone know of a simple class / function ? S Apparently, you can read the header of the file to find the bitrate, then calculate the approximate play duration from that info and the filesize. Here is information on the mp3 file format: http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm ...and here is a discussion thread that provides the calculation and other links: http://www.hydrogenaudio.org/forums/lofiversion/index.php/t46563.html I've never done this, and apparently there is an issue with MP3s that have variable bitrates, but maybe this will get you started in the right direction. HTH - JM -- not anything like a bunny ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] duration of mp3 file
Shyte ... The files are VBR ... I will read up and when I find answer - will revert to list with it as well.. Ps. Everyone is a bunny to me :P S -Original Message- From: Jim Moseby [mailto:[EMAIL PROTECTED] Sent: 11 July 2007 03:55 PM To: 'Steven Macintyre'; php-general@lists.php.net Subject: RE: [PHP] duration of mp3 file Allow bunnies ... Any takers on this ... I JUST want the duration of the mp3 file - with a small function if possible ... I honestly don't want to use a class like http://www.phpclasses.org/browse/package/112.html The coding is terrible and SERIOUSLY over inflated for what I want. Anyone know of a simple class / function ? S Apparently, you can read the header of the file to find the bitrate, then calculate the approximate play duration from that info and the filesize. Here is information on the mp3 file format: http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm ...and here is a discussion thread that provides the calculation and other links: http://www.hydrogenaudio.org/forums/lofiversion/index.php/t46563.ht ml I've never done this, and apparently there is an issue with MP3s that have variable bitrates, but maybe this will get you started in the right direction. HTH - JM -- not anything like a bunny ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Another simple question (Probably) FINISHED!!!!!
So after many days and many questions and the help of many many people, I have finished my task scheduler! I just wanted to say thank you to all who helped. Now I just need to make it look pretty and add some comments so I know why I did what I did. :) Anyone interested in looking at my code can do so here: HTTP://www.raoset.com/tests/ticklers/viewall.txt HTTP://www.raoset.com/tests/ticklers/update.txt and just as a reminder, this is for a totally internal system at this point so I can control all the data going into the database. Maybe I should release it as a package or tutorial... I'll think about it, if you guys think the code is up to snuff. Thanks again everyone! -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Freelance.eu outsource your programming and webdesign projects
Freelance.eu outsource your programming and webdesign projects http://www.freelance.eu freelance, programming, outsourcing, programmer, outsource, php programming, mysql,mysql database database Freelance.eu , temporarily: post your projects for free and free webmaster and programmer signup! -- View this message in context: http://www.nabble.com/Freelance.eu-outsource-your-programming-and-webdesign-projects-tf4062208.html#a11541248 Sent from the PHP - General mailing list archive at Nabble.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] duration of mp3 file
On Wednesday 11 July 2007 21:32, Steven Macintyre wrote: Any takers on this ... I JUST want the duration of the mp3 file - with a small function if possible ... I honestly don't want to use a class like http://www.phpclasses.org/browse/package/112.html The coding is terrible and SERIOUSLY over inflated for what I want. So why not take the part that you need and rewrite it so that it is not so terrible? -- Crayon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] duration of mp3 file
Or you could use ffmpeg executable to get details about the media file. You will have to parse the response of the executable. The only thing is that you must have exec function or an execution function available and ffmpeg installed. This is for linux machines tho... Don't know if ffmpeg is available for windows too. Andy Steven Macintyre wrote: Shyte ... The files are VBR ... I will read up and when I find answer - will revert to list with it as well.. Ps. Everyone is a bunny to me :P S -Original Message- From: Jim Moseby [mailto:[EMAIL PROTECTED] Sent: 11 July 2007 03:55 PM To: 'Steven Macintyre'; php-general@lists.php.net Subject: RE: [PHP] duration of mp3 file Allow bunnies ... Any takers on this ... I JUST want the duration of the mp3 file - with a small function if possible ... I honestly don't want to use a class like http://www.phpclasses.org/browse/package/112.html The coding is terrible and SERIOUSLY over inflated for what I want. Anyone know of a simple class / function ? S Apparently, you can read the header of the file to find the bitrate, then calculate the approximate play duration from that info and the filesize. Here is information on the mp3 file format: http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm ...and here is a discussion thread that provides the calculation and other links: http://www.hydrogenaudio.org/forums/lofiversion/index.php/t46563.ht ml I've never done this, and apparently there is an issue with MP3s that have variable bitrates, but maybe this will get you started in the right direction. HTH - JM -- not anything like a bunny ;-)
Re: [PHP] Array Question
Thanks, I've seen the light by your code. Robin Vickery [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 11/07/07, kvigor [EMAIL PROTECTED] wrote: Is there a php function similar to in_array that can detect if a partial value is in an array value or not: e.g. $var1 = big horse;$var2 = small yellow;$var3 = red hydrant; $theArray = array(big blue horse, small yellow bird, giant red hydrant); Is there a way to find out if $var1 in $theArray or $var2 etc.? There's not a built in function, but it's not hard to write one: function partial_in_array($needle, $haystack) { if (!is_array($needle)) { $needle = array($needle); } $needle = array_map('preg_quote', $needle); foreach ($needle as $pattern) { if (count(preg_grep(/$pattern/, $haystack)) 0) return true; } return false; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Another simple question (Probably) FINISHED!!!!!
On 7/11/07, Jason Pruim [EMAIL PROTECTED] wrote: So after many days and many questions and the help of many many people, I have finished my task scheduler! I just wanted to say thank you to all who helped. Now I just need to make it look pretty and add some comments so I know why I did what I did. :) Anyone interested in looking at my code can do so here: HTTP://www.raoset.com/tests/ticklers/viewall.txt HTTP://www.raoset.com/tests/ticklers/update.txt and just as a reminder, this is for a totally internal system at this point so I can control all the data going into the database. Maybe I should release it as a package or tutorial... I'll think about it, if you guys think the code is up to snuff. Thanks again everyone! -- Jason Pruim Raoset Inc. Technology Manager MQC Specialist 3251 132nd ave Holland, MI, 49424 www.raoset.com [EMAIL PROTECTED] Keeping in mind that you'll still be getting jabs about coding styles from the list (it's an inescapable and inevitable fact here, you know that), I just wanted to be the first to say, congrats on finally getting it done. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Question
On Wed, 2007-07-11 at 09:46 +0100, Robin Vickery wrote: On 11/07/07, kvigor [EMAIL PROTECTED] wrote: Is there a php function similar to in_array that can detect if a partial value is in an array value or not: e.g. $var1 = big horse;$var2 = small yellow;$var3 = red hydrant; $theArray = array(big blue horse, small yellow bird, giant red hydrant); Is there a way to find out if $var1 in $theArray or $var2 etc.? There's not a built in function, but it's not hard to write one: function partial_in_array($needle, $haystack) { if (!is_array($needle)) { $needle = array($needle); } You can reduce the above statement to the following: $needle = (array)$needle; Conversion to array creates an array with one element... the value converted. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Question
Robert Cummings wrote: On Wed, 2007-07-11 at 09:46 +0100, Robin Vickery wrote: On 11/07/07, kvigor [EMAIL PROTECTED] wrote: Is there a php function similar to in_array that can detect if a partial value is in an array value or not: e.g. $var1 = big horse;$var2 = small yellow;$var3 = red hydrant; $theArray = array(big blue horse, small yellow bird, giant red hydrant); Is there a way to find out if $var1 in $theArray or $var2 etc.? There's not a built in function, but it's not hard to write one: function partial_in_array($needle, $haystack) { if (!is_array($needle)) { $needle = array($needle); } You can reduce the above statement to the following: $needle = (array)$needle; Conversion to array creates an array with one element... the value converted. Without raising a notice? -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] duration of mp3 file
Or you can use sox, if you compile it with mp3 support. It works for me... -Original Message- From: Andrei [EMAIL PROTECTED] To: 'Jim Moseby' [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: 07. 07. 11. 16:25 Subject: Re: [PHP] duration of mp3 file Or you could use ffmpeg executable to get details about the media file. You will have to parse the response of the executable. The only thing is that you must have exec function or an execution function available and ffmpeg installed. This is for linux machines tho... Don't know if ffmpeg is available for windows too. Andy Steven Macintyre wrote: Shyte ... The files are VBR ... I will read up and when I find answer - will revert to list with it as well.. Ps. Everyone is a bunny to me :P S -Original Message- From: Jim Moseby [mailto:[EMAIL PROTECTED] Sent: 11 July 2007 03:55 PM To: 'Steven Macintyre'; php-general@lists.php.net Subject: RE: [PHP] duration of mp3 file Allow bunnies ... Any takers on this ... I JUST want the duration of the mp3 file - with a small function if possible ... I honestly don't want to use a class like http://www.phpclasses.org/browse/package/112.html The coding is terrible and SERIOUSLY over inflated for what I want. Anyone know of a simple class / function ? S Apparently, you can read the header of the file to find the bitrate, then calculate the approximate play duration from that info and the filesize. Here is information on the mp3 file format: http://mpgedit.org/mpgedit/mpeg_format/mpeghdr.htm ...and here is a discussion thread that provides the calculation and other links: http://www.hydrogenaudio.org/forums/lofiversion/index.php/t46563.ht ml I've never done this, and apparently there is an issue with MP3s that have variable bitrates, but maybe this will get you started in the right direction. HTH - JM -- not anything like a bunny ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Question
On Wed, 2007-07-11 at 15:52 +0100, Stut wrote: Robert Cummings wrote: On Wed, 2007-07-11 at 09:46 +0100, Robin Vickery wrote: On 11/07/07, kvigor [EMAIL PROTECTED] wrote: Is there a php function similar to in_array that can detect if a partial value is in an array value or not: e.g. $var1 = big horse;$var2 = small yellow;$var3 = red hydrant; $theArray = array(big blue horse, small yellow bird, giant red hydrant); Is there a way to find out if $var1 in $theArray or $var2 etc.? There's not a built in function, but it's not hard to write one: function partial_in_array($needle, $haystack) { if (!is_array($needle)) { $needle = array($needle); } You can reduce the above statement to the following: $needle = (array)$needle; Conversion to array creates an array with one element... the value converted. Without raising a notice? Yep. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Question
Robert Cummings wrote: On Wed, 2007-07-11 at 15:52 +0100, Stut wrote: Robert Cummings wrote: On Wed, 2007-07-11 at 09:46 +0100, Robin Vickery wrote: On 11/07/07, kvigor [EMAIL PROTECTED] wrote: Is there a php function similar to in_array that can detect if a partial value is in an array value or not: e.g. $var1 = big horse;$var2 = small yellow;$var3 = red hydrant; $theArray = array(big blue horse, small yellow bird, giant red hydrant); Is there a way to find out if $var1 in $theArray or $var2 etc.? There's not a built in function, but it's not hard to write one: function partial_in_array($needle, $haystack) { if (!is_array($needle)) { $needle = array($needle); } You can reduce the above statement to the following: $needle = (array)$needle; Conversion to array creates an array with one element... the value converted. Without raising a notice? Yep. Excellent. Don't you just love PHP. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Question
On Wed, 2007-07-11 at 16:07 +0100, Stut wrote: Robert Cummings wrote: On Wed, 2007-07-11 at 15:52 +0100, Stut wrote: Robert Cummings wrote: On Wed, 2007-07-11 at 09:46 +0100, Robin Vickery wrote: On 11/07/07, kvigor [EMAIL PROTECTED] wrote: Is there a php function similar to in_array that can detect if a partial value is in an array value or not: e.g. $var1 = big horse;$var2 = small yellow;$var3 = red hydrant; $theArray = array(big blue horse, small yellow bird, giant red hydrant); Is there a way to find out if $var1 in $theArray or $var2 etc.? There's not a built in function, but it's not hard to write one: function partial_in_array($needle, $haystack) { if (!is_array($needle)) { $needle = array($needle); } You can reduce the above statement to the following: $needle = (array)$needle; Conversion to array creates an array with one element... the value converted. Without raising a notice? Yep. Excellent. Don't you just love PHP. Certainly do :) Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array Question
On 11/07/07, Robert Cummings [EMAIL PROTECTED] wrote: On Wed, 2007-07-11 at 09:46 +0100, Robin Vickery wrote: On 11/07/07, kvigor [EMAIL PROTECTED] wrote: Is there a php function similar to in_array that can detect if a partial value is in an array value or not: e.g. $var1 = big horse;$var2 = small yellow;$var3 = red hydrant; $theArray = array(big blue horse, small yellow bird, giant red hydrant); Is there a way to find out if $var1 in $theArray or $var2 etc.? There's not a built in function, but it's not hard to write one: function partial_in_array($needle, $haystack) { if (!is_array($needle)) { $needle = array($needle); } You can reduce the above statement to the following: $needle = (array)$needle; Conversion to array creates an array with one element... the value converted. Fair enough. I very rarely type cast in PHP, so it never occurred to me to try that. -robin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] duration of mp3 file
http://arrozcru.no-ip.org/ffmpeg_builds/ On 11/07/07, Andrei [EMAIL PROTECTED] wrote: Or you could use ffmpeg executable to get details about the media file. You will have to parse the response of the executable. The only thing is that you must have exec function or an execution function available and ffmpeg installed. This is for linux machines tho... Don't know if ffmpeg is available for windows too. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 objects access/instantiation model
Hi, new to PHP5 and I have a question about the object model. I want to be able to create a class which is allows abstraction from specifics. So for one example, imagine a generic database connection wrapper which can have multiple drivers depending on the database used. Some of the functionality is generic, some is database specific (mysql_ , odbc_). So: Class MySQL_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class ODBC_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class generic { public $driver = null ; function __construct($connection_type) { if $this-connection_type = MySQL { $this-driver = new MySQL_Driver ; } else { $this-driver = new ODBC_Driver ; } } function authenticate { // Using the non-generic connect() from the selected driver $this-driver-prop1 = fooey // These references work fine from within the generic class echo $this-driver-prop1 ; echo $this-driver-function1 ; } function errors { // Reporting non-generic errors from the selected driver } function debug { } ... } $gen = new generic(MySQL) ; // Instantiate the generic database object, which determines its own driver $gen-driver-prop1 = fooey // but they fail from here echo $gen-driver-prop1 ; echo $gen-driver-function1 ; $gen-authenticate() ; // this works ok though, so everything is created correctly So I want to access generic functions as $generic-authenticate(), and database specific functions $generic-driver-runquery. This allows the top level code to be able to be completely generic and not know anything about the underlying database. But I can't ! I can't find a way of accessing the encapsulated object (driver) from the instantiator of generic. Is it possible ? I guess there are lots of workaround ways. I could write lots of middleman code in generic and use things like __set and __get etc but its lots of extra overhead. I also know I could use extends but that makes the code the wrong way around (MySQL_Driver would have to extend generic), hence the top-level application would have to include code to determine which driver to create rather than the db object determining its own connection driver to use. This is true also for just lumping everything in a single class per db type. Surely it must be possible ? Or am I missing something ? I also don't really get the idea of interface and abstract classes ? They don't seem to be any practical use ? Maybe that's me ? Anyway, not really relevant to this post ... Please, please can someone help !! Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP5 objects access/instantiation model (correction)
OK, so that came out fairly illegible. Try again: Hi, new to PHP5 (and the forums evidently !) and I have a question about the object model. I want to be able to create a class which is allows abstraction from specifics. So for one example, imagine a generic database connection wrapper which can have multiple drivers depending on the database used. Some of the functionality is generic, some is database specific (mysql_ , odbc_). So: Class MySQL_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class ODBC_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class generic { public $driver = null ; function __construct($connection_type) { if $this-connection_type = MySQL { $this-driver = new MySQL_Driver ; } else { $this-driver = new ODBC_Driver ; } } // Using the non-generic connect() from the selected driver function authenticate { $this-driver-prop1 = fooey // These references work fine from within // the generic class echo $this-driver-prop1 ; echo $this-driver-function1 ; } // Report non-generic errors from the selected driver function errors { } function debug { } ... } $gen = new generic(MySQL) ; // Instantiate the generic database object, which // determines its own driver $gen-driver-prop1 = fooey // but they fail from here echo $gen-driver-prop1 ; echo $gen-driver-function1 ; // this works ok though, so everything is created // correctly $gen-authenticate() ; So I want to access generic functions as $generic-authenticate(), and database specific functions $generic-driver-runquery. This allows the top level code to be able to be completely generic and not know anything about the underlying database. But I can't ! I can't find a way of accessing the encapsulated object (driver) from the instantiator of generic. Is it possible ? I guess there are lots of workaround ways. I could write lots of middleman code in generic and use things like __set and __get etc but its lots of extra overhead. I also know I could use extends but that makes the code the wrong way around (MySQL_Driver would have to extend generic), hence the top-level application would have to include code to determine which driver to create rather than the db object determining its own connection driver to use. This is true also for just lumping everything in a single class per db type. Surely it must be possible ? Or am I missing something ? I also don't really get the idea of interface and abstract classes ? They don't seem to be any practical use ? Maybe that's me ? Anyway, not really relevant to this post ... Please, please can someone help !! Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 objects access/instantiation model (correction)
On Wed, 2007-07-11 at 16:46 +0100, Steve Perkins wrote: I guess there are lots of workaround ways. I could write lots of middleman code in generic and use things like __set and __get etc but its lots of extra overhead. I also know I could use extends but that makes the code the wrong way around (MySQL_Driver would have to extend generic), hence the top-level application would have to include code to determine which driver to create rather than the db object determining its own connection driver to use. This is true also for just lumping everything in a single class per db type. You want a factory class that creates an instance of the appropriate driver object. The driver object SHOULD extend the generic class. ?php class DbFactory { function __construct() { // :) } function getConnection( $type, $params ) { if( $type == 'MySQL' ) { return new DB_Driver_MySQL; } else if( $type == 'ODBC' ) { return new DB_Driver_ODBC; } return false; } } class DB_Driver_Generic { public $var1; public $var2; function __construct() { } function runQuery( $query ) { } } class DB_Driver_MySQL extends DB_Driver_Generic { function __construct() { parent::__construct(); } } class DB_Driver_ODBC extends DB_Driver_Generic { function __construct() { parent::__construct(); } } ? Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 objects access/instantiation model (correction)
I also don't really get the idea of interface and abstract classes ? They don't seem to be any practical use ? Maybe that's me ? Anyway, not really relevant to this post ... there is a lot of usefulness in these constructs; look into design patterns. also, there are code libraries already written w/ the abstraction you are trying to develop. im not discouraging you from developing your own, but it may be helpful for you to study some of the other code. check out http://pear.php.net/package/MDB2 http://ez.no/doc/components/view/2007.1/(file)/classtrees_Database.html http://www.onphp.org/doxy/trunk/ -nathan ps. i believe interjinn provides a db layer as well : On 7/11/07, Steve Perkins [EMAIL PROTECTED] wrote: OK, so that came out fairly illegible. Try again: Hi, new to PHP5 (and the forums evidently !) and I have a question about the object model. I want to be able to create a class which is allows abstraction from specifics. So for one example, imagine a generic database connection wrapper which can have multiple drivers depending on the database used. Some of the functionality is generic, some is database specific (mysql_ , odbc_). So: Class MySQL_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class ODBC_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class generic { public $driver = null ; function __construct($connection_type) { if $this-connection_type = MySQL { $this-driver = new MySQL_Driver ; } else { $this-driver = new ODBC_Driver ; } } // Using the non-generic connect() from the selected driver function authenticate { $this-driver-prop1 = fooey // These references work fine from within // the generic class echo $this-driver-prop1 ; echo $this-driver-function1 ; } // Report non-generic errors from the selected driver function errors { } function debug { } ... } $gen = new generic(MySQL) ; // Instantiate the generic database object, which // determines its own driver $gen-driver-prop1 = fooey // but they fail from here echo $gen-driver-prop1 ; echo $gen-driver-function1 ; // this works ok though, so everything is created // correctly $gen-authenticate() ; So I want to access generic functions as $generic-authenticate(), and database specific functions $generic-driver-runquery. This allows the top level code to be able to be completely generic and not know anything about the underlying database. But I can't ! I can't find a way of accessing the encapsulated object (driver) from the instantiator of generic. Is it possible ? I guess there are lots of workaround ways. I could write lots of middleman code in generic and use things like __set and __get etc but its lots of extra overhead. I also know I could use extends but that makes the code the wrong way around (MySQL_Driver would have to extend generic), hence the top-level application would have to include code to determine which driver to create rather than the db object determining its own connection driver to use. This is true also for just lumping everything in a single class per db type. Surely it must be possible ? Or am I missing something ? I also don't really get the idea of interface and abstract classes ? They don't seem to be any practical use ? Maybe that's me ? Anyway, not really relevant to this post ... Please, please can someone help !! Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 objects access/instantiation model (correction)
On Wed, 2007-07-11 at 12:07 -0400, Nathan Nobbe wrote: I also don't really get the idea of interface and abstract classes ? They don't seem to be any practical use ? Maybe that's me ? Anyway, not really relevant to this post ... there is a lot of usefulness in these constructs; look into design patterns. also, there are code libraries already written w/ the abstraction you are trying to develop. im not discouraging you from developing your own, but it may be helpful for you to study some of the other code. check out http://pear.php.net/package/MDB2 http://ez.no/doc/components/view/2007.1/(file)/classtrees_Database.html http://www.onphp.org/doxy/trunk/ -nathan ps. i believe interjinn provides a db layer as well : It does :) It was especially important in PHP4 since there was no PDO as there is now in PHP5. Not that I'm particularly familiar with PDO (maybe it has deficiencies?). Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 objects access/instantiation model (correction)
some ideas about class design: 1. properties should normally (read almost always) be private. 2. the apps interface to the DB [connection] is via the 'generic' class, the app should have to know nothing about the drive object and should have no direct access to it. 3. use an interface definition for your drivers (so they all share a common set of method ... a common interface ;-)) this leaves you with the problem of wanting to write as little boilerplate code for making the functionality each driver class implements available via the 'generic' class. I would suggest either a few simple functions like so: class DB { function query() { $args = func_get_args(); return call_user_func_array(array($this-driver, __FUNCTION__), $args); } } which you can simplify into something like: class DB { function __call($meth, $args) { $func = array($this-driver, $meth) if (!is_callable($func)) throw new Exception('undefined interface: '.__CLASS__.'::'$meth); return call_user_func_array($func, $args); } } just an idea :-) ... this seems to me to be something along the decorator pattern, you could choose to do something along the lines of the factory pattern, where by your factory returns a 'driver' object which your application uses (not caring what class of driver it is) ... this would also require that your driver classes share a common interface (actually using a interface definition to enforce it is a seperate issue). an interface example: interface DBDriver { function query($sql, $args); function commit($id); function rollback($id); } class MySQL_DBDriver implements DBDriver { function query($sql, $args) { return mysql_query($sql, $args); } function commit($id); { return true; } function rollback($id); { return true; } } Steve Perkins wrote: // but they fail from here echo $gen-driver-prop1 ; echo $gen-driver-function1 ; what fails exactly? what is the error? // this works ok though, so everything is created // correctly $gen-authenticate() ; PS. I would hazard a guess and say the generic class is not very generic - it's quite specifically a 'database' class, it is an 'abstract' class (not in the php syntax sense) in that the DBMS specifics are hidden away in helper/plugin classes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] ftp_ssl_connect
I installed the certificate on our server, but the ftp_ssl_connect still fails? I have verified that the certificate is valid and works. -Original Message- From: Chris [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 10, 2007 7:07 PM To: Daniel Novotny Cc: 'php-general@lists.php.net' Subject: Re: [PHP] ftp_ssl_connect Daniel Novotny wrote: When I tried to connect through a telnet session I got the following message: Connection failed: The certificate chain was issued by an authority that is not trusted. Get a proper certificate and you'll be right to go then I guess. -- Postgresql php tutorials http://www.designmagick.com/
[PHP] PHP 5.0.1 Date
The time reported by the date() function is off by one hour. Currently our server is configured to EDT (-400) time zone, however our php installation is reporting the timezone at EST (-500). I know in php 5.1.x you can set the timezone in php.ini. However we're not prepared to update php at the moment. Can anybody let me know where PHP 5.0.1 gets the timezone information from? How can I change this so PHP returns the proper date. Thanks, Phil --- Philip Shafer Web Programmer University Web Services Rowan University Glassboro NJ 08028 856-256-4418 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 objects access/instantiation model (correction)
Robert, I looked at your code in InterJinn a couple of times; i havent gone over all of it mind you but it looks pretty sweet. have you had a look at any of the other frameworks i mentioned earlier in this thread? ez components, onPHP, and now there is a new one ive found (in recent thread) Radicore. i really like the xsl approach for templates. All, also, more on topic; there are many different ways to use interfaces and abstract classes in many different design patterns. they all have purpose, pros and cons. take for instance factory method and abstract factory; where the former uses inheritance the later uses composition. the former can produce only a single class of products, but the abstract base class rarely needs revision; whereas the later can produce sets of related product classes; yet every time a new product class is needed or deprecated the abstract factory [interface] needs revision. Steve, you might also check out http://www.phppatterns.com/docs/start i dont think its been maintained in a while, but its a great place to start. also, i think PDO is pretty sweet, but really its only the base of a strong db abstraction layer, such as what youll find in ez components. -nathan ps. i cant decide if i should build my own db layer around pdo or go for a pre-built one from an aforementioned framework; only time will tell : On 7/11/07, Jochem Maas [EMAIL PROTECTED] wrote: some ideas about class design: 1. properties should normally (read almost always) be private. 2. the apps interface to the DB [connection] is via the 'generic' class, the app should have to know nothing about the drive object and should have no direct access to it. 3. use an interface definition for your drivers (so they all share a common set of method ... a common interface ;-)) this leaves you with the problem of wanting to write as little boilerplate code for making the functionality each driver class implements available via the 'generic' class. I would suggest either a few simple functions like so: class DB { function query() { $args = func_get_args(); return call_user_func_array(array($this-driver, __FUNCTION__), $args); } } which you can simplify into something like: class DB { function __call($meth, $args) { $func = array($this-driver, $meth) if (!is_callable($func)) throw new Exception('undefined interface: '.__CLASS__.'::'$meth); return call_user_func_array($func, $args); } } just an idea :-) ... this seems to me to be something along the decorator pattern, you could choose to do something along the lines of the factory pattern, where by your factory returns a 'driver' object which your application uses (not caring what class of driver it is) ... this would also require that your driver classes share a common interface (actually using a interface definition to enforce it is a seperate issue). an interface example: interface DBDriver { function query($sql, $args); function commit($id); function rollback($id); } class MySQL_DBDriver implements DBDriver { function query($sql, $args) { return mysql_query($sql, $args); } function commit($id); { return true; } function rollback($id); { return true; } } Steve Perkins wrote: // but they fail from here echo $gen-driver-prop1 ; echo $gen-driver-function1 ; what fails exactly? what is the error? // this works ok though, so everything is created // correctly $gen-authenticate() ; PS. I would hazard a guess and say the generic class is not very generic - it's quite specifically a 'database' class, it is an 'abstract' class (not in the php syntax sense) in that the DBMS specifics are hidden away in helper/plugin classes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 objects access/instantiation model (correction)
On Wed, 2007-07-11 at 12:50 -0400, Nathan Nobbe wrote: Robert, I looked at your code in InterJinn a couple of times; i havent gone over all of it mind you but it looks pretty sweet. It's very different in many respects from other styles of coding. It's an MVC approach for the most part but the way libraries are accessed is different than what I've seen elsewhere. In general class names are only used in two places... when extending a class, and in the registration of a class to a service. Instead classes are registered as services/libraries and instances are retrieved by a general factory mechanism that returns the instance based on the service/library name. In this way almost all aspects of the framework can be overloaded, even if they are core features, without ever touching the core code itself or ever having to change class references within your code since you can just register a different class for the service and all existing uses of that service will now use the newly registered version. This was very useful even before PHP5 got autoload (and even still IMHO) because the loader would load the class's code on an as requested basis. have you had a look at any of the other frameworks i mentioned earlier in this thread? ez components I work with a version of ez components on almost a daily basis (pre-existing CMS that a client had set up) ... it makes me scream because their template engine is godawful because it uses a block approach that requires changing the PHP code if you move blocks out of registered nestings. It's absolutely horrible. The code for the classes is generally disgusting also, but that's just my opinion. Fortunately, I was allowed to hook in InterJinn as needed and so new stuff uses the ez components framework bu generally punts the work to InterJinn modules / services / and templates. We've found run time speed to be much greater for those modules and the maintainability of the content is much, much, easier. , onPHP, and now there is a new one ive found (in recent thread) Radicore. i really like the xsl approach for templates. XSL is nice, but it's complex for the average Joe content developer. When I created InterJinn I wanted something with similar capabilities but without the restriction of well-formed-ness for the HTML content in general (so that existing content could still be adapted with minimal disruption - my new site is XHTML strict). So I created custom tags that can wrap well-formed or not-so-well formed content and process as necessary. Generally speaking though the template engine isn't in any way limited to just custom tags, it can include anything since it's pluggable and extendable. Also, unlike most other template engines, TemplateJinn compiles to the actual PHP code the web server loads, so there's no run-time hit, and in fact, there can be a run time bonus on some aspects. For instance headers, footers, etc, etc can be punted to separate templates but at compile time they are brought together to create the final page. That's not to say TemplateJinn can't be used at run-time, it can be, and it is in the case of the ez components hooking since ezcomponents uses a front end loader. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Anyone have an iPhone? OT
On Wednesday 11 July 2007 19:58, tedd wrote: If you bought an iPhone, please contact me off-list -- I have a question. They have: http://www.willitblend.com/videos.aspx?type=unsafevideo=iphone -- Crayon -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Mac popup happy?
Could anybody point me in the right general direction for why Mac OS X Safari and Firefox would open up a new window/tab for this link? a href=http://complaintsdevbrowse.hostedlabs.com/redirect_by_entry_id.php?entry_id=146802;FW: VitalChek Order Confirmation/a It's password-protected to keep Google out until we launch, but I could send you a login offline, if you really want... Here is the actual HTTP exchange captured by LiveHTTPHeaders in Firefox on Windows: http://complaintsdevbrowse.hostedlabs.com/redirect_by_entry_id.php?entry_id=146802 GET /redirect_by_entry_id.php?entry_id=146802 HTTP/1.1 Host: complaintsdevbrowse.hostedlabs.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://complaintsdevwww.hostedlabs.com/tagged/confirmation.htm Authorization: Basic bHluY2g6ZnJlZDAwNw== HTTP/1.x 302 Found Date: Wed, 11 Jul 2007 19:14:04 GMT Server: HTTPD Set-Cookie: complaints=72de46df781bc8b305a69dc11b580ff0; path=/; domain=hostedlabs.com; secure Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Location: http://complaintsdevwww.hostedlabs.com/2007/july/3/FW__VitalChek_Order_Confirmation_146802.htm Content-Encoding: gzip Vary: Accept-Encoding Keep-Alive: timeout=3, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html; charset=UTF-8 The redirect script is about as simple as it gets: ?php set_include_path('/webapps/data/sagacity.com/complaints.com/includes'); require 'globals.inc'; $public = /webapps/data/sagacity.com/complaints.com/static; $entry_id = (int) $_GET['entry_id']; $pattern =$public/*/*/*/*_$entry_id.htm; $files = glob($pattern); if (is_array($files) count($files) === 1){ $basename = substr($files[0], strlen($public)); error_log(about to redirect to $STATICURL$basename); header(Location: $STATICURL$basename); exit; } header(Location: http://complaints.com;); ? In this instance, globals.inc is a rather large file that gets included solely to set $STATICURL to 'http://complaintsdevwww.hostedlabs.com' I'm just not seeing any rational explanation for why my boss' computer is doing popups in all this. Surely a re-direct to a different sub-domain doesn't make Mac OS X decide it's a Good Idea to do popups... Does it?... The sub-domains are needed as the 'www' sub-domain will be a world-wide distributed server-farm DCN static data setup, while the 'browse' one will be a different world-wide distributed server-farm of PHP application boxes... I realize this isn't a PHP question, really, but I don't know what kind of a question it *IS* to know where to start looking, and my keyword combinations to Google have only returned a LOT of results with no relevance to my actual issue, as you might imagine... :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] PHP 5.0.1 Date
Almost for sure from the TZ environment variable, and almost for sure there's more about it in the FAQ, IIRC: http://php.net/faq.php On Wed, July 11, 2007 11:14 am, Shafer, Philip wrote: The time reported by the date() function is off by one hour. Currently our server is configured to EDT (-400) time zone, however our php installation is reporting the timezone at EST (-500). I know in php 5.1.x you can set the timezone in php.ini. However we're not prepared to update php at the moment. Can anybody let me know where PHP 5.0.1 gets the timezone information from? How can I change this so PHP returns the proper date. Thanks, Phil --- Philip Shafer Web Programmer University Web Services Rowan University Glassboro NJ 08028 856-256-4418 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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
[PHP] Re: 縁談はあるのに独身をやめない 女性達の本当の理由とは??
I completely agree there. Darren 独身貴族の生態系 wrote: ルックスが悪いわけじゃない。仕事を頑張りたいだけが理由じゃない。 「だったらなぜ?」それは当然の疑問です。リサーチの結果これほど性的に飢えた人種はいないという事実が発覚し分離改装となりました。 今回のご案内はこちらです! ■□■ 完全無料制・独身貴族攻略大全集 ■□■ 家庭を持つ安定 < 独身の自由な性生活 http://fochun.com/kouryaku/4/ 1・コミニティーとして使用するも良し・出会いのキッカケとして使用するも良し 2・独身貴族攻略大全集の名の下に集まった女性のみが参加。確実さは一目瞭然!独身だから電話だって何時でもOKよ。 3・全システム完全無料で利用できるので安心の中で近所のとコミュニケート出来る。 等の利点を兼ね備えてまったく新しいコミュニティとして分離改装いたしました! リニューアル記念として、簡単に取得できるフリーメールアドレス(yahoo・goo・hotmail)等での参加も可能となっておりますのでぜひこの機会にお試しくださいませ! http://fochun.com/kouryaku/4/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP5 objects access/instantiation model (correction)
You probably ought to have: class mysql_driver extends generic_driver { } Seems like that would be the most reasonable OOP model, imho. That said, I suspect that if you do something like: $driver = $this-driver; You then may be able to access the driver-specific data using $driver-propl; etc. On Wed, July 11, 2007 10:46 am, Steve Perkins wrote: OK, so that came out fairly illegible. Try again: Hi, new to PHP5 (and the forums evidently !) and I have a question about the object model. I want to be able to create a class which is allows abstraction from specifics. So for one example, imagine a generic database connection wrapper which can have multiple drivers depending on the database used. Some of the functionality is generic, some is database specific (mysql_ , odbc_). So: Class MySQL_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class ODBC_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class generic { public $driver = null ; function __construct($connection_type) { if $this-connection_type = MySQL { $this-driver = new MySQL_Driver ; } else { $this-driver = new ODBC_Driver ; } } // Using the non-generic connect() from the selected driver function authenticate { $this-driver-prop1 = fooey // These references work fine from within // the generic class echo $this-driver-prop1 ; echo $this-driver-function1 ; } // Report non-generic errors from the selected driver function errors { } function debug { } ... } $gen = new generic(MySQL) ; // Instantiate the generic database object, which // determines its own driver $gen-driver-prop1 = fooey // but they fail from here echo $gen-driver-prop1 ; echo $gen-driver-function1 ; // this works ok though, so everything is created // correctly $gen-authenticate() ; So I want to access generic functions as $generic-authenticate(), and database specific functions $generic-driver-runquery. This allows the top level code to be able to be completely generic and not know anything about the underlying database. But I can't ! I can't find a way of accessing the encapsulated object (driver) from the instantiator of generic. Is it possible ? I guess there are lots of workaround ways. I could write lots of middleman code in generic and use things like __set and __get etc but its lots of extra overhead. I also know I could use extends but that makes the code the wrong way around (MySQL_Driver would have to extend generic), hence the top-level application would have to include code to determine which driver to create rather than the db object determining its own connection driver to use. This is true also for just lumping everything in a single class per db type. Surely it must be possible ? Or am I missing something ? I also don't really get the idea of interface and abstract classes ? They don't seem to be any practical use ? Maybe that's me ? Anyway, not really relevant to this post ... Please, please can someone help !! Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] Mac popup happy?
Richard, I'm using Firefox on Mac OS X 10.3.9 ... Clicking your link takes me to a page with http authentication asking me for usr/pass. Where are you seeing the pop-up phenomena? I have Safari as well to check with. I can't get past the Authorization to see where you get the pop-up. On 7/11/07 4:23 PM, Richard Lynch [EMAIL PROTECTED] wrote: Could anybody point me in the right general direction for why Mac OS X Safari and Firefox would open up a new window/tab for this link? a href=http://complaintsdevbrowse.hostedlabs.com/redirect_by_entry_id.php?entry _id=146802FW: VitalChek Order Confirmation/a It's password-protected to keep Google out until we launch, but I could send you a login offline, if you really want... Here is the actual HTTP exchange captured by LiveHTTPHeaders in Firefox on Windows: http://complaintsdevbrowse.hostedlabs.com/redirect_by_entry_id.php?entry_id=14 6802 GET /redirect_by_entry_id.php?entry_id=146802 HTTP/1.1 Host: complaintsdevbrowse.hostedlabs.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0. 8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: http://complaintsdevwww.hostedlabs.com/tagged/confirmation.htm Authorization: Basic bHluY2g6ZnJlZDAwNw== HTTP/1.x 302 Found Date: Wed, 11 Jul 2007 19:14:04 GMT Server: HTTPD Set-Cookie: complaints=72de46df781bc8b305a69dc11b580ff0; path=/; domain=hostedlabs.com; secure Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Location: http://complaintsdevwww.hostedlabs.com/2007/july/3/FW__VitalChek_Order_Confirm ation_146802.htm Content-Encoding: gzip Vary: Accept-Encoding Keep-Alive: timeout=3, max=100 Connection: Keep-Alive Transfer-Encoding: chunked Content-Type: text/html; charset=UTF-8 The redirect script is about as simple as it gets: ?php set_include_path('/webapps/data/sagacity.com/complaints.com/includes'); require 'globals.inc'; $public = /webapps/data/sagacity.com/complaints.com/static; $entry_id = (int) $_GET['entry_id']; $pattern =$public/*/*/*/*_$entry_id.htm; $files = glob($pattern); if (is_array($files) count($files) === 1){ $basename = substr($files[0], strlen($public)); error_log(about to redirect to $STATICURL$basename); header(Location: $STATICURL$basename); exit; } header(Location: http://complaints.com;); ? In this instance, globals.inc is a rather large file that gets included solely to set $STATICURL to 'http://complaintsdevwww.hostedlabs.com' I'm just not seeing any rational explanation for why my boss' computer is doing popups in all this. Surely a re-direct to a different sub-domain doesn't make Mac OS X decide it's a Good Idea to do popups... Does it?... The sub-domains are needed as the 'www' sub-domain will be a world-wide distributed server-farm DCN static data setup, while the 'browse' one will be a different world-wide distributed server-farm of PHP application boxes... I realize this isn't a PHP question, really, but I don't know what kind of a question it *IS* to know where to start looking, and my keyword combinations to Google have only returned a LOT of results with no relevance to my actual issue, as you might imagine... :-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] duration of mp3 file
On Wed, July 11, 2007 8:32 am, Steven Macintyre wrote: Allow bunnies ... Any takers on this ... I JUST want the duration of the mp3 file - with a small function if possible ... I honestly don't want to use a class like http://www.phpclasses.org/browse/package/112.html The coding is terrible and SERIOUSLY over inflated for what I want. Anyone know of a simple class / function ? id3_lib and/or the PHP ID3 project may or may not let you pull the duration out of the early frames of the MP3... Though those are also quite a bit over-inflated for what you want... If all else fails, and if a reasonable margin of error is acceptable... A CRUDE hack to get an estimate, if you know in advance that all the files are a certain audio quality, is to just divide the filesize by some factor that's an average of the ratio between duration/filesize of some known sample files... I often eyeball an MP3 filesize in the shell and can tell you to within a few seconds how long it is, just based on filesize, as they are all stereo 128K, at least in my collection. Except the ones named lofi which are mono 64K, and that's a different ratio is all :-) The point being that if it's just eye candy to tell the user how long the thing is, you don't NEED microsecond accuracy anyway, just do something like: //very crude estimate, if I did the math in my head right... $ratio = 6000; //128K, stereo, a meg a minute, give or take... $filesize = filesize($mp3); $duration = $filesize / $ratio; $minutes = floor($duration / 60); $seconds = $duration - ($minutes * 60); echo $minutes:$seconds minutes; Sometimes we programmers get so wrapped up in perfection and detail work, we ignore a seemingly overly simplistic solution, to our detriment. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] PHP5 objects access/instantiation model (correction)
Yeah. I've been working on re-writing it using bits from everyone !! It's a good learning process to find out how PHP handles OOP. I thoroughly recommend it, it's the only way to learn. Some things just can't be learnt from the manual! Cheers All. -Original Message- From: Richard Lynch [mailto:[EMAIL PROTECTED] Sent: 11 July 2007 21:29 To: Steve Perkins Cc: php-general@lists.php.net Subject: Re: [PHP] PHP5 objects access/instantiation model (correction) You probably ought to have: class mysql_driver extends generic_driver { } Seems like that would be the most reasonable OOP model, imho. That said, I suspect that if you do something like: $driver = $this-driver; You then may be able to access the driver-specific data using $driver-propl; etc. On Wed, July 11, 2007 10:46 am, Steve Perkins wrote: OK, so that came out fairly illegible. Try again: Hi, new to PHP5 (and the forums evidently !) and I have a question about the object model. I want to be able to create a class which is allows abstraction from specifics. So for one example, imagine a generic database connection wrapper which can have multiple drivers depending on the database used. Some of the functionality is generic, some is database specific (mysql_ , odbc_). So: Class MySQL_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class ODBC_driver { public prop1 ; public connect() { echo Foo; } public runquery() { echo Foo; } ... } Class generic { public $driver = null ; function __construct($connection_type) { if $this-connection_type = MySQL { $this-driver = new MySQL_Driver ; } else { $this-driver = new ODBC_Driver ; } } // Using the non-generic connect() from the selected driver function authenticate { $this-driver-prop1 = fooey // These references work fine from within // the generic class echo $this-driver-prop1 ; echo $this-driver-function1 ; } // Report non-generic errors from the selected driver function errors { } function debug { } ... } $gen = new generic(MySQL) ; // Instantiate the generic database object, which // determines its own driver $gen-driver-prop1 = fooey // but they fail from here echo $gen-driver-prop1 ; echo $gen-driver-function1 ; // this works ok though, so everything is created // correctly $gen-authenticate() ; So I want to access generic functions as $generic-authenticate(), and database specific functions $generic-driver-runquery. This allows the top level code to be able to be completely generic and not know anything about the underlying database. But I can't ! I can't find a way of accessing the encapsulated object (driver) from the instantiator of generic. Is it possible ? I guess there are lots of workaround ways. I could write lots of middleman code in generic and use things like __set and __get etc but its lots of extra overhead. I also know I could use extends but that makes the code the wrong way around (MySQL_Driver would have to extend generic), hence the top-level application would have to include code to determine which driver to create rather than the db object determining its own connection driver to use. This is true also for just lumping everything in a single class per db type. Surely it must be possible ? Or am I missing something ? I also don't really get the idea of interface and abstract classes ? They don't seem to be any practical use ? Maybe that's me ? Anyway, not really relevant to this post ... Please, please can someone help !! Thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to pass connection as global variable ?
You can't make a database connection survive past the end of a script. So putting it in the $_SESSION is about as pointless as it gets. On Wed, July 11, 2007 3:47 am, C.R.Vegelin wrote: I have various PHP scripts that use the same database. The startup script default.php sets the connection once for all the scripts. This connection is set in $_SESSION to make it a global variable for all scripts. When switching from page default to page faq, I get errors I can't explain. Any help is highly appreciated. TIA, Cor default.php ?php session_start(); require(menu.php); ... $link = mysqli_connect($mysqlhost, $mysqluser, $mysqlpsw, $mysqldb) or die(cannot connect); $_SESSION['connection'] = $link; ... ? faq.php --- ?php require(menu.php); $link = $_SESSION['connection']; $sql = SELECT Question, Answer FROM myfaqs; $result = mysqli_query($link, $sql); // previous line gives: //Notice: Undefined variable: _SESSION in C:\Inetpub\wwwroot\test\faq.php //Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\Inetpub\wwwroot\test\faq.php ... ? -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] Array Question
On Wed, July 11, 2007 9:52 am, Stut wrote: $needle = (array)$needle; Conversion to array creates an array with one element... the value converted. Without raising a notice? Sure looks like it: php -d error_reporting=2047 -r '$foo = (array) foo; var_dump($foo);' array(1) { [0]= string(3) foo } But I'd have to say that the intent is not all that clear, really, and I'd be leery of this feature, personally. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] Editing Files with PHP
On Tue, July 10, 2007 7:33 pm, David Wonderly wrote: I am trying to create a small script to open a file and edit it. However, when I open a file with PHP in it the PHP is stripped out. It open as if I was viewing the page source. How do I fix this? Here is the code I am using. form action=filewrite.php method=post textarea rows=15 cols=70 name=content ?php include($file) ; include executes the PHP in the file. readfile just reads it as-is ? /textarea input type=text name=filename / input type=submit / /form Filewrite looks like this ?php $File = $filename; $Handle = fopen($File, 'r+'); $Data = $content; fwrite($Handle, $Data); fclose($Handle); print Data Written.; ? Like I said, it is very simple but, I can write php if I start with a blank page but, I can open a file and view it. All of the files are at david.wonderly.com Your filewrite looks suspiciously like http://php.net/file_put_contents :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] Array Question
On Wed, 2007-07-11 at 16:11 -0500, Richard Lynch wrote: On Wed, July 11, 2007 9:52 am, Stut wrote: $needle = (array)$needle; Conversion to array creates an array with one element... the value converted. Without raising a notice? Sure looks like it: php -d error_reporting=2047 -r '$foo = (array) foo; var_dump($foo);' array(1) { [0]= string(3) foo } But I'd have to say that the intent is not all that clear, really, and I'd be leery of this feature, personally. I wouldn't be leery at all. It's been around for a very long time and it's documented: http://www.php.net/manual/en/language.types.array.php#language.types.array.casting Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Php code in html buttons
On Tue, July 10, 2007 5:59 pm, k w wrote: I'm trying to make a button execute some php code when the button is clicked. I'm not sure if it is the button i'm coding wrong or the php code. Here is the code I am using. ?php echo button action='?php mysqli_query($connect,$query)?'Click/button; ? [sportscaster voice-over] Joe: Hey Bob, let's look at a slow-motion instant-replay of this common PHP newbie fallacy scenario Bob: Sure Joe! Joe: Okay, so here goes: The user requests a HTTP URL document. The webserver fires up. The webserver finds that it needs PHP to generate the document. PHP fires up. Bob: Wow, look at it go! That's fast! Joe: Yeah, it is fast. PHP has generated the document, and spits it out. Bob: Boy, it's already finished. Hey, it's quit! Joe: That's right, Bob. PHP has FINISHED EXECUTION, and has exited. Now watch this! Bob: Oh boy, I see it coming now... Joe: Yep, there it is. There's some HTML in the browser, trying to execute some PHP code... Bob: But you can see, PHP has LONG FINISHED and is OUTTA HERE!!! Joe: That's right, Bob, PHP is simply not around to execute that code. Bob: So what can you do, Joe? Joe: Well, if you can live with the browser going back-n-forth to the web-server, with a significant lag time... Bob: Oooh, well, I can see how that might be useful sometimes... Joe: In those cases, you can use Ajax. Bob: Anything else? Joe: Not really. Until you get back to the webserver and PHP, there's just no PHP available. Unless your user is in the extreme minority of uber-PHP-geeks that has installed this EXPERIMENTAL PHP browser plug-in thingie: http://pecl.php.net/package/PHPScript Bob: Whoa, Joe, I don't think I've ever even heard of anybody who's ever installed that. Joe: Me neither, though I met Wez Furlong who wrote it, so I have to assume HE has installed it at least once... [cue to cool Guinness commercial] -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] Php code in html buttons
On Tue, July 10, 2007 5:59 pm, k w wrote: I'm trying to make a button execute some php code when the button is clicked. I'm not sure if it is the button i'm coding wrong or the php code. Here is the code I am using. ?php echo button action='?php mysqli_query($connect,$query)?'Click/button; ? Actually, since I've answered this one the same way quite a few times, I decided to just put it in my blog: http://richardlynch.blogspot.com/2007/07/php-in-html.html Now if I can just remember to use that link the next time instead of typing it all again... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] Array Question
On Wed, July 11, 2007 4:16 pm, Robert Cummings wrote: But I'd have to say that the intent is not all that clear, really, and I'd be leery of this feature, personally. I wouldn't be leery at all. It's been around for a very long time and it's documented: http://www.php.net/manual/en/language.types.array.php#language.types.array.casting As soon as I hit send I knew that would be mis-interpreted... Leery is the wrong word. Sorry. It just seems a bit to clever to me... I suspect I'd skim this code a hundred times and not realize what it was doing. But maybe that's just me. :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] Proper way to remove an element from an array
On Tue, July 10, 2007 4:23 pm, Dan wrote: I know in some languages there's a right way to remove an element from an array and other ways that will give you problems. In PHP can I just set $arrayname[key] = null? Or will I then end up with key = null as a value. I looked on php.net under array functions for a bit and I didn't find any sort of remove element function. I've just never needed to do this before. http://php.net/unset Setting to null should also work, I think, but only in some versions... The value NULL hasn't been around as long as unset. And there were minor releases where I THINK it went a bit funky about whether you'd have that key in the array, for some weird situations... unset has been around and has worked the same for a lonnng time. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] Problem with GD after upgrading Entropy 5.1.6 - 5.2.2
Comment out the header(Content-type); Change error_reporting to E_ALL. Surf directly to chart.php. See error messages. Fix them. On Tue, July 10, 2007 3:26 pm, M5 wrote: I've got a little PHP script that generates charts, that has been working perfectly every day for the past couple years. Since upgrading the Xserve's PHP from 5.1.6 to 5.2.2 (both Entropy), it has stopped working. Specifically, it doesn't return any GIFs (charts). Actually, it will output a GIF providing that session_start() isn't called at the beginning of chart.php. The reason session_start() is called is that the data needed by chart.php resides as session variablesso the session needs to be propogated to chart.php when it's called. My gut feeling is that *something* in chart.php is now throwing a notice or warning or something, and that is corrupting the GIF file (which returns as a broken icon). Here's the beginning of chart.php, which as I mentioned, was working perfectly verbatim up until last week: ?php session_start(); error_reporting(0); header(Content-type: image/gif); [...] Here is a modified version of the above, based on comments I've gleaned from various forums. (It still doesn't work, btw.) ?php @session_start(); @set_time_limit(0); @error_reporting(0); // session_start(); header(Content-type: image/gif); header(Cache-Control: cache, must-revalidate); header(Pragma: public); [...] ...Rene -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] About Fraud Prevention
On Tue, July 10, 2007 1:51 pm, Kelvin Park wrote: I'm trying to make a program with PHP, that prevents ecommerce fraud orders. Technically, what's the most effective way to prevent fraud orders on e-commerce web sites? Don't take orders. Oh. You probably want a better answer than that. Well, it could fill volumes, most likely... You basically want to just take this whole problem and shove off MOST of it onto the experts' shoulders by having the bank processing the credit cards, rather than trying to do much of it yourself. The merchant accounts have different options... Getting the users' address and using the AVS (Address Verification System) so that you aren't just taking raw credit card numbers can help. Using that extra 3 (or 4) digits on the back of the card can help. I understand that at least one site simply won't ship to an entire country, after being burned several times by scammers who routinely infiltrate the mail system of said country, and packages just plain disappear long before the fraud comes to light. Now if I actually knew what country that was, it would be of more use, but there it is... You also should check out what some of the more popular shopping cart packages do in this arena -- They pretty much all suck all around, but some of them must have something you can glean from them. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] About Fraud Prevention
On Tue, July 10, 2007 1:59 pm, Stut wrote: Kelvin Park wrote: I'm trying to make a program with PHP, that prevents ecommerce fraud orders. Technically, what's the most effective way to prevent fraud orders on e-commerce web sites? Give everything away for free. And take donations instead of actually charging, if you need a revenue stream. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] Checking Post Data against DB Data
Doing a select to get every record, and then looping through them all, concatenating a bunch of stuff together, and then using PHP to test == is not very efficient... Why not just: $sql = array_map('mysql_real_insert_string', $POST); $query = select count(*) from central ; $query .= where conName = $sql[conName] ; $query .=and conAddress = $sql[conAddress] ; . . . $query .=and SOME_DATETIME_FIELD_WHEN_THEY_REGISTERED = date_sub(now(), interval 1 day) ; Also note that your are currently comparing the $_POST['timeStamp'] which is *probably* generated at the time the HTML form was sent with time(); which is when the script is processing, which will be MUCH less than one day, unless a user opens up the form, walks away for 24 hours, and then comes back to complete registration... You need a field in the database from previous registration to compare to time(). Also note that, in general, it's very very very easy to subvert this by simply changing non-essential data in the input. E.g., I live at: 6112 N Wolcott 6112 North Wolcott 6112 N. Wolcott 6112 N Wolcott Ave . . . I could easily register 20 times a day, if I like, and you'd never catch it. So, given all that, and given what you are TRYING to do, I'd suggest just going on their PHONE number, and requiring a valid phone number to win or JUST going on their email address and requiring a valid email. It all depends how serious you are about the 1 per day rule, though... On Tue, July 10, 2007 9:55 am, kvigor wrote: /*Good Morning to All, I am having an issue with the following code. I'm trying to match $newRegistrant(which is concatenated form data) with $oldRegistrant(which is concatenated DB data). The code is suppose to check if the Registrants match, if they do, then check if last registration was less than 24hrs ago, if it is it sets $FLAG to 1 and throws and error at the user. Problem is the follow code only displays the error message from the //unknown check section, and not the //central check section. I know the code is virtually identical except for the table it's pulling data from. POST data has been mysql escaped. And form is submitted twice w/same info and no FLAG/error message*/ //I hope this helps. Because I NEED HELP :-( ?php include(dbconnection.php); $_POST['timeStamp'] = date(Y-m-d h:i:s); $timeStamp = $_POST['timeStamp']; //FORMATTING FROM DATA= if(isset($_POST['submit'])) { $_POST['conName'] = strtoupper($_POST['conName']); $_POST['conAddress'] = strtoupper($_POST['conAddress']); $_POST['conCity'] = strtoupper($_POST['conCity']); $_POST['conState'] = strtoupper($_POST['conState']); $_POST['conZip'] = strtoupper($_POST['conZip']); $_POST['conPhone'] = strtoupper($_POST['conPhone']); $_POST['schName'] = strtoupper($_POST['schName']); $_POST['schAddress'] = strtoupper($_POST['schAddress']); $_POST['schCity'] = strtoupper($_POST['schCity']); $_POST['schState'] = strtoupper($_POST['schState']); $_POST['schZip'] = strtoupper($_POST['schZip']); $_POST['strCity'] = strtoupper($_POST['strCity']); $_POST['strState'] = strtoupper($_POST['strState']); $_POST['strName'] = strtoupper($_POST['strName']); } //END FORMATTING FROM DATA== //CHECKING TO SEE IF THE USER HAS REGISTERED IN LAST 24 HRS= $newRegistrant = $_POST['conName'].$_POST['conAddress'].$_POST['conCity'].$_POST['conState'].$_POST['conPhone'].$_POST['schName'].$_POST['schCity'].$_POST['schState'].$_POST['strName'].$_POST['strCity'].$_POST['strState'];//NEW REGISTRANT global $newRegistrant; //Begin Central Check $matchQuery_cen = SELECT conName,conAddress,conCity,conState,conPhone,schName,schCity,schState,strName,strCity,strState FROM central; $matchQueryResult_cen = mysql_query($matchQuery_cen,$connection) or die (Query Failed.mysql_error()); while($matchrow_cen = mysql_fetch_assoc($matchQueryResult_cen)) { extract($matchrow_cen); $oldRegistrant = $conName.$conAddress.$conCity.$conState.$conPhone.$schName.$schCity.$schState.$strName.$strCity.$strState; $varStamp = $_POST['timeStamp']; //CURRENT DATE in MySQL DATETIME FORMAT $varStamp = strtotime($varStamp); //CONVERT DATETIME FORMAT INTO MATHMATICAL DATA/UNIX-STAMP $varStamp = $varStamp + '86400'; //STORED TIME OF REGISTRANT + 1 DAY $currentTime = time(); // CURRENT DATE IN MATHMATICAL DATA/UNIX-STAMP if($oldRegistrant == $newRegistrant $currentTime $varStamp ) { $FLAG = 1; global $FLAG; } else { $FLAG = 2; global $FLAG; } } //End Century Check= //Unknown
Re: [PHP] Creating 'Next' 'Previous' for PHP Photo Gallery
Don't try to figure out the name of the photo that is next/previous. Just do it by number and use http://php.net/array_slice after you do glob. This is a bit of a hack, as, technically, the Operating System is NOT required to return the files in any particular order, nor does glob document itself as returning them in order... So, you could also throw in a 'sort' or you can just live with the fact that it's only going to work by coincidence... If the number of files in one directory is HUGE, sort may be too expensive... But probably not, so try it with the sort first and then see. On Tue, July 10, 2007 9:01 am, Rahul Sitaram Johari wrote: I¹m trying to write a Photo Gallery in PHP. Everything else is pretty much worked out like thumbnails, indexes, titles all the one thing I¹m stuck at is the Next Previous links for the Photos on the main Photo Page. It¹s a simple program where you drop images in a folder and glob() picks up the thumbnails displays them on a page which are automatically linked to the Full Size Images. This is the code: ? $ID = $_GET['ID']; foreach (glob($ID/thumbnails/*.jpg) as $key=$value) { $title = rtrim(basename($value),'.jpg'); $newtitle = preg_replace('/_/', ' ', $title); ? A HREF=photo.php?photo=?php echo basename($value); ?title=?php echo $newtitle; ?ID=?php echo $_GET['ID']; ?KEY=?php echo $key; ? TARGET=photoFrame IMG SRC=?php echo $ID; ?/thumbnails/?php echo basename($value); ?/A ?php echo $newtitle; ? ? } ? I know that $key holds the sequence of images that are being picked up by glob() - I¹m just trying to figure out a way to use this $key to generate the Next Previous link. The problem is everything is passed on to a separate page (photo.php) ... What I¹m thinking is determining which Photo File would be Next or Previous to the one being selected, and passing that along to the (photo.php) page. I¹m just not able to figure out how to pick out the next previous filename and place it in the Query String. Any suggestions? ~~~ Rahul Sitaram Johari CEO, Twenty Four Seventy Nine Inc. W: http://www.rahulsjohari.com E: [EMAIL PROTECTED] ³I morti non sono piu soli ... The dead are no longer lonely² -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] About Eclipse JVM Termination
On Tue, July 10, 2007 4:25 am, Kelvin Park wrote: Do you know the cause of this error? Yes. You are using Java instead of PHP. I'm trying to run it on 64bit Fedora 7. I have AMD64 and JRE 1.6.0_02 64bit is installed. Do you know how to fix the following error? if yes how? Yes. Uninstall Java and install PHP instead. You *did* ask this on a PHP mailing list, after all... :-) -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] PHP list as a blog
On Wed, June 13, 2007 3:04 pm, Robert Cummings wrote: But you might not. It depends on what you decide to include() instead of redirecting. I guess in the included source you could code aorund not having the correct URL parameters and default to something sensible, but that still doesn't address the content/request mismatch. Bought a house, and I've been away from the list, so I'm resurrecting this only to point out... As far as I'm concerned, if it requires a login to see X, and you ask for X and aren't logged in, seeing the login page with the URL X *IS* the perfectly valid answer for what you should see. If I needed Google to index my content that requires a login, then I don't need a login because that's just a plain silly setup... Google's gonna have a bunch of pages that users can't see unless they login? Then it's not a login; It's a scam to collect a bunch of user data. :-) :-) :-) PS And I could just look at the Google User Agent and not require login for that, which anybody could forge, but so what? They'll get the same damn info by knowing what to search for in Google anyway, if I'm giving Google the content without a login. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] gnererating geocodes from a postcode
On Thu, June 14, 2007 6:02 am, Ross wrote: I have done this before with a paid service in the uk www.postcodeanywhere.co.uk but is there a free service where I can automatically genereate this from the postcode? At present I am using multimap to get the 'lat' and 'lon' information I want. This is too slowww. Very old post, but I saw no answers... US and Canada have freely-available open content databases of one kind or another. Not so sure about UK... You could *cache* the results of any given postcode, and would probably eventually have all of them... One project I've never quite gotten back to yet was to build an open commons content type db of all country/postcode lat/long datasets... Or at least, all countries that have sane enough postal systems to be able to do so without killing myself... -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] Re: PHP Brain Teasers
On Tue, July 3, 2007 3:51 pm, Jochem Maas wrote: $I = null; sleep(10); $I = rear(); function rear() {}; Looks like a snooze alarm to me... :-) Mine was trying to go for an old funk song that starts: What goes up, must come down. Spinning wheel got to go 'round Drop all the painted ponies by the riverside. [mumble] let the spinning wheel slide. Only later did I realize I broke the cardinal rule of Name That Tune and have NO IDEA what the song title is nor who wrote/sang it... And Google and lyrics search are not helping much so far... Sorry!!! -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] Where does PHP look for php.ini??
On Fri, July 6, 2007 7:53 pm, Stut wrote: Tijnema wrote: I just noted that my php (CLI and Apache2 SAPI) doesn't read my php.ini in /etc I have compiled php with --prefix=/usr, and my /usr/etc is symlinked to /etc, but it doesn't read the php.ini file.. when I use the CLI with -c /etc it works fine :) php -i on the command line, or phpinfo() in a SAPI script will tell you where it expects to find it, as well as whether it did find it. For the archives: That's not quite 100% correct... If you've set PhpIniDirectory in Apache2, for example, and php.ini isn't in that directory, php will fall back onto looking for it in the default compile-in location, and then it will tell you in phpinfo() that it couldn't find php.ini in that compiled-in location, with no mention that it looked in the PhpIniDirectory as well... I spent about half an hour trying to figure out what was wrong with my httpd.conf because of this... Then threw php.ini into the directory and it worked just fine. YMMV -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie 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] Array Question
On Wed, 2007-07-11 at 16:40 -0500, Richard Lynch wrote: On Wed, July 11, 2007 4:16 pm, Robert Cummings wrote: But I'd have to say that the intent is not all that clear, really, and I'd be leery of this feature, personally. I wouldn't be leery at all. It's been around for a very long time and it's documented: http://www.php.net/manual/en/language.types.array.php#language.types.array.casting As soon as I hit send I knew that would be mis-interpreted... Glad I didn't disappoint :) Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP list as a blog
On Wed, 2007-07-11 at 17:51 -0500, Richard Lynch wrote: On Wed, June 13, 2007 3:04 pm, Robert Cummings wrote: But you might not. It depends on what you decide to include() instead of redirecting. I guess in the included source you could code aorund not having the correct URL parameters and default to something sensible, but that still doesn't address the content/request mismatch. Bought a house, and I've been away from the list, so I'm resurrecting this only to point out... As far as I'm concerned, if it requires a login to see X, and you ask for X and aren't logged in, seeing the login page with the URL X *IS* the perfectly valid answer for what you should see. If I needed Google to index my content that requires a login, then I don't need a login because that's just a plain silly setup... Google's gonna have a bunch of pages that users can't see unless they login? Then it's not a login; It's a scam to collect a bunch of user data. :-) :-) :-) PS And I could just look at the Google User Agent and not require login for that, which anybody could forge, but so what? They'll get the same damn info by knowing what to search for in Google anyway, if I'm giving Google the content without a login. I guess what you're suggesting is a lot like using a relative URL in a redirect... it works, it saves some time, but it's not quite right ;) Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Checking Post Data against DB Data
kvigor wrote: OK Chris, I understand that we're checking checking the form data and escaping it, but can explain what's going on in the WHERE clause and 1=1 tad bit more. Instead of looking at all records in your original attempt (which will work fine for 10 records), you limit what you are looking at (which works a lot better for 50,000 records). The 1=1 is something that the database will remove internally but basically it stops an invalid query: select * from table where a='b' and c='d' and That's why I said you can either remove the last and: select * from table where a='b' and c='d' or add 1=1: select * from table where a='b' and c='d' and 1=1 They work out the same. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] getting the next element of an associative array
let's say we have the following associative array: $array = array( red = ferrari, yellow = volkswagen, green = mercedes, blue = volvo ); then we have a current index into the array: $index = yellow; $current = $array[$index]; now: how do i get the key of the next array element (in this case green)? $next = ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php