Re: [PHP] last modified on a page

2010-06-13 Thread Simon J Welsh
On 14/06/2010, at 4:11 PM, David Mehler wrote:

> Hello,
> I've got what is probably a simple question. I've got a site with a
> footer include file. I want to have a section that displays the last
> time the page was modified. So for example say the index.php was last
> modified today and another page  was modified two days ago. When the
> include is run on the other page it says something like this page was
> last modified and it would be two days ago, but for the index file I
> get this page was last modified and today's date.
> Thanks.
> Dave.
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

Try using filemtime() and $_SERVER['SCRIPT_FILENAME']

---
Simon Welsh
Admin of http://simon.geek.nz/

Who said Microsoft never created a bug-free program? The blue screen never, 
ever crashes!

http://www.thinkgeek.com/brain/gimme.cgi?wid=81d520e5e





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] last modified on a page

2010-06-13 Thread David Mehler
Hello,
I've got what is probably a simple question. I've got a site with a
footer include file. I want to have a section that displays the last
time the page was modified. So for example say the index.php was last
modified today and another page  was modified two days ago. When the
include is run on the other page it says something like this page was
last modified and it would be two days ago, but for the index file I
get this page was last modified and today's date.
Thanks.
Dave.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] String Parse Help for novice

2010-06-13 Thread Adam Richardson
On Sun, Jun 13, 2010 at 9:29 PM, Robert Cummings wrote:

> Rick Dwyer wrote:
>
>> Hello List.
>>
>> I need to parse the PATH portion of URL.  I have assigned the path
>>  portion to a variable using the following:
>>
>> $thepath = parse_url($url);
>>
>>
>> Now I need to break each portion of the path down into its own  variable.
>>  The problem is, the path can vary considerably as follows:
>>
>> /mydirectory/mysubdirectory/anothersubdirectory/mypage.php
>>
>> vs.
>>
>> /mydirectory/mypage.php
>>
>> How do I get the either of the above url paths broken out so the
>>  variables equal the following
>>
>> $dir1 = mydirectory
>> $dir2 = mysubdirectory
>> $dir3 = anothersubdirectory
>> $page = mypage.php
>>
>> ...etc... if there were 5 more subdirectories... they would be
>>  dynamically assigned to a variable.
>>
>>  Thanks for any help.
>>
>
> 
> function my_parse_url( $url )
> {
>$parsed = parse_url( $url );
>$parsed['file'] = basename( $parsed['path'] );
>$parsed['pathbits'] = explode( '/', ltrim( dirname( $parsed['path'] ),
> '/' ) );
>
>return $parsed;
> }
>
> $url = my_parse_url( 'http://foo.fee.com/blah/bleh/bluh/meh.php' );
> print_r( $url );
>
> ?>
>
> Cheers,
> Rob.
> --
> E-Mail Disclaimer: Information contained in this message and any
> attached documents is considered confidential and legally protected.
> This message is intended solely for the addressee(s). Disclosure,
> copying, and distribution are prohibited unless authorized.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Clean and lean, Robert ;)  Nice!

Adam

-- 
Nephtali:  PHP web framework that functions beautifully
http://nephtaliproject.com


Re: [PHP] Quick Question

2010-06-13 Thread Nilesh Govindarajan
On Mon, Jun 14, 2010 at 4:36 AM, Karl DeSaulniers  wrote:
> Hello List,
> I may have asked this before, but can not find any emails about it.
> Does anyone know of a general-javascript email list like this php list?
> Hoping someone here can point me in the right direction.
> TIA
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>


I don't know about MLs, but you can look for some user groups on
google and yahoo.

-- 
Nilesh Govindarajan
Facebook: nilesh.gr
Twitter: nileshgr
Website: www.itech7.com
Cheap and Reliable VPS Hosting: http://j.mp/arHk5e

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] String Parse Help for novice

2010-06-13 Thread Robert Cummings

Rick Dwyer wrote:

Hello List.

I need to parse the PATH portion of URL.  I have assigned the path  
portion to a variable using the following:


$thepath = parse_url($url);


Now I need to break each portion of the path down into its own  
variable.  The problem is, the path can vary considerably as follows:


/mydirectory/mysubdirectory/anothersubdirectory/mypage.php

vs.

/mydirectory/mypage.php

How do I get the either of the above url paths broken out so the  
variables equal the following


$dir1 = mydirectory
$dir2 = mysubdirectory
$dir3 = anothersubdirectory
$page = mypage.php

...etc... if there were 5 more subdirectories... they would be  
dynamically assigned to a variable.


  Thanks for any help.


$parsed['pathbits'] = explode( '/', ltrim( dirname( $parsed['path'] 
), '/' ) );


return $parsed;
}

$url = my_parse_url( 'http://foo.fee.com/blah/bleh/bluh/meh.php' );
print_r( $url );

?>

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] String Parse Help for novice

2010-06-13 Thread Ashley Sheridan
On Sun, 2010-06-13 at 18:52 -0400, Rick Dwyer wrote:

> OK, sorry for any confusion.
> 
> Here is all my code:
> 
> $url = "http" . ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://". 
> $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
> $thepath = parse_url($url);
> 
> So, given that the URL can vary as follows:
> 
> /mydirectory/mysubdirectory/anothersubdirectory/mypage.php
> vs.
> /mydirectory/mypage.php
> 
> How do I get the either of the above url paths broken out so the  
> variables equal the following
> 
> $dir1 = mydirectory
> $dir2 = mysubdirectory
> $dir3 = anothersubdirectory
> $page = mypage.php
> 
> ...etc... if there were 5 more subdirectories... they would be  
> dynamically assigned to a variable.
> 
>   --Rick
> 
> 
> 
> 
> 
> On Jun 13, 2010, at 6:42 PM, Ashley Sheridan wrote:
> 
> > On Sun, 2010-06-13 at 18:35 -0400, Rick Dwyer wrote:
> >
> >> OK, I get the following error:
> >>
> >> Warning: basename() expects parameter 1 to be string, array given  
> >> in
> >>
> >> When I use the following:
> >>
> >> $thepath = parse_url($url);
> >> $filename = basename($thepath);
> >>
> >> Is my variable thepath not automatically string?
> >>
> >>  --Rick
> >>
> >>
> >> On Jun 13, 2010, at 6:23 PM, Ashley Sheridan wrote:
> >>
> >>> On Sun, 2010-06-13 at 18:13 -0400, Rick Dwyer wrote:
> 
>  Hello List.
> 
>  I need to parse the PATH portion of URL.  I have assigned the path
>  portion to a variable using the following:
> 
>  $thepath = parse_url($url);
> 
> 
>  Now I need to break each portion of the path down into its own
>  variable.  The problem is, the path can vary considerably as  
>  follows:
> 
>  /mydirectory/mysubdirectory/anothersubdirectory/mypage.php
> 
>  vs.
> 
>  /mydirectory/mypage.php
> 
>  How do I get the either of the above url paths broken out so the
>  variables equal the following
> 
>  $dir1 = mydirectory
>  $dir2 = mysubdirectory
>  $dir3 = anothersubdirectory
>  $page = mypage.php
> 
>  ...etc... if there were 5 more subdirectories... they would be
>  dynamically assigned to a variable.
> 
>   Thanks for any help.
> 
>   --Rick
> 
> 
> 
> >>>
> >>> $filename = basename($path);
> >>> $parts = explode('/', $path);
> >>> $directories = array_pop($parts);
> >>>
> >>> Now you have your directories in the $directories array and the
> >>> filename in $filename.
> >>>
> >>> Thanks,
> >>> Ash
> >>> http://www.ashleysheridan.co.uk
> >>>
> >>>
> >>
> >>
> >
> >
> > Because you've given it an array. Your original question never  
> > mentioned
> > you were using parse_url() on the original array string. parse_url()
> > breaks the string into its component parts, much like my explode
> > example.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> 
> 


Take out the parse_url line and use the code I gave you, or keep the
parse_url line and drop my explode line.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] String Parse Help for novice

2010-06-13 Thread Rick Dwyer

OK, sorry for any confusion.

Here is all my code:

$url = "http" . ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://". 
$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];

$thepath = parse_url($url);

So, given that the URL can vary as follows:

/mydirectory/mysubdirectory/anothersubdirectory/mypage.php
vs.
/mydirectory/mypage.php

How do I get the either of the above url paths broken out so the  
variables equal the following


$dir1 = mydirectory
$dir2 = mysubdirectory
$dir3 = anothersubdirectory
$page = mypage.php

...etc... if there were 5 more subdirectories... they would be  
dynamically assigned to a variable.


 --Rick





On Jun 13, 2010, at 6:42 PM, Ashley Sheridan wrote:


On Sun, 2010-06-13 at 18:35 -0400, Rick Dwyer wrote:


OK, I get the following error:

Warning: basename() expects parameter 1 to be string, array given  
in


When I use the following:

$thepath = parse_url($url);
$filename = basename($thepath);

Is my variable thepath not automatically string?

 --Rick


On Jun 13, 2010, at 6:23 PM, Ashley Sheridan wrote:


On Sun, 2010-06-13 at 18:13 -0400, Rick Dwyer wrote:


Hello List.

I need to parse the PATH portion of URL.  I have assigned the path
portion to a variable using the following:

$thepath = parse_url($url);


Now I need to break each portion of the path down into its own
variable.  The problem is, the path can vary considerably as  
follows:


/mydirectory/mysubdirectory/anothersubdirectory/mypage.php

vs.

/mydirectory/mypage.php

How do I get the either of the above url paths broken out so the
variables equal the following

$dir1 = mydirectory
$dir2 = mysubdirectory
$dir3 = anothersubdirectory
$page = mypage.php

...etc... if there were 5 more subdirectories... they would be
dynamically assigned to a variable.

 Thanks for any help.

 --Rick





$filename = basename($path);
$parts = explode('/', $path);
$directories = array_pop($parts);

Now you have your directories in the $directories array and the
filename in $filename.

Thanks,
Ash
http://www.ashleysheridan.co.uk








Because you've given it an array. Your original question never  
mentioned

you were using parse_url() on the original array string. parse_url()
breaks the string into its component parts, much like my explode
example.

Thanks,
Ash
http://www.ashleysheridan.co.uk





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] String Parse Help for novice

2010-06-13 Thread Karl DeSaulniers


On Jun 13, 2010, at 5:40 PM, Ashley Sheridan wrote:


On Sun, 2010-06-13 at 17:35 -0500, Karl DeSaulniers wrote:


On Jun 13, 2010, at 5:31 PM, Ashley Sheridan wrote:

> On Sun, 2010-06-13 at 17:27 -0500, Karl DeSaulniers wrote:
>
>> On Jun 13, 2010, at 5:23 PM, Ashley Sheridan wrote:
>>
>>> On Sun, 2010-06-13 at 18:13 -0400, Rick Dwyer wrote:
>>>
 Hello List.

 I need to parse the PATH portion of URL.  I have assigned the  
path

 portion to a variable using the following:

 $thepath = parse_url($url);


 Now I need to break each portion of the path down into its own
 variable.  The problem is, the path can vary considerably as
 follows:

 /mydirectory/mysubdirectory/anothersubdirectory/mypage.php

 vs.

 /mydirectory/mypage.php

 How do I get the either of the above url paths broken out so the
 variables equal the following

 $dir1 = mydirectory
 $dir2 = mysubdirectory
 $dir3 = anothersubdirectory
 $page = mypage.php

 ...etc... if there were 5 more subdirectories... they would be
 dynamically assigned to a variable.

   Thanks for any help.

   --Rick



>>>
>>>
>>> $filename = basename($path);
>>> $parts = explode('/', $path);
>>> $directories = array_pop($parts);
>>>
>>> Now you have your directories in the $directories array and the
>>> filename
>>> in $filename.
>>>
>>> Thanks,
>>> Ash
>>> http://www.ashleysheridan.co.uk
>>>
>>>
>>
>>
>> Hi Ash,
>> What about the "//" in  the beginning?
>>
>>
>> Karl DeSaulniers
>> Design Drumm
>> http://designdrumm.com
>>
>>
>
>
> As your example string didn't have a double slash I didn't write  
code

> for that, but it's easy enough to remove 0-length strings from the
> $directories array.
>
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>

:) Rick's example, but how in your example do we look for a double
forward slash?
THX

Karl DeSaulniers
Design Drumm
http://designdrumm.com




You don't look for one, that's the point. The explode() breaks the  
string into an array at every occurrence of a '/' character. This  
will leave zero length strings in the array if there is a double //  
(which wasn't in any given example in this thread that I saw) When  
you use the array, just don't do anything with empty elements!


Thanks,
Ash
http://www.ashleysheridan.co.uk





Ahh.. that makes sense. Thanks Ash.


Karl DeSaulniers
Design Drumm
http://designdrumm.com



Re: [PHP] String Parse Help for novice

2010-06-13 Thread Ashley Sheridan
On Sun, 2010-06-13 at 18:35 -0400, Rick Dwyer wrote:

> OK, I get the following error:
> 
> Warning: basename() expects parameter 1 to be string, array given in
> 
> When I use the following:
> 
> $thepath = parse_url($url);
> $filename = basename($thepath);
> 
> Is my variable thepath not automatically string?
> 
>   --Rick
> 
> 
> On Jun 13, 2010, at 6:23 PM, Ashley Sheridan wrote:
> 
> > On Sun, 2010-06-13 at 18:13 -0400, Rick Dwyer wrote:
> >>
> >> Hello List.
> >>
> >> I need to parse the PATH portion of URL.  I have assigned the path
> >> portion to a variable using the following:
> >>
> >> $thepath = parse_url($url);
> >>
> >>
> >> Now I need to break each portion of the path down into its own
> >> variable.  The problem is, the path can vary considerably as follows:
> >>
> >> /mydirectory/mysubdirectory/anothersubdirectory/mypage.php
> >>
> >> vs.
> >>
> >> /mydirectory/mypage.php
> >>
> >> How do I get the either of the above url paths broken out so the
> >> variables equal the following
> >>
> >> $dir1 = mydirectory
> >> $dir2 = mysubdirectory
> >> $dir3 = anothersubdirectory
> >> $page = mypage.php
> >>
> >> ...etc... if there were 5 more subdirectories... they would be
> >> dynamically assigned to a variable.
> >>
> >>   Thanks for any help.
> >>
> >>   --Rick
> >>
> >>
> >>
> >
> > $filename = basename($path);
> > $parts = explode('/', $path);
> > $directories = array_pop($parts);
> >
> > Now you have your directories in the $directories array and the  
> > filename in $filename.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> 
> 


Because you've given it an array. Your original question never mentioned
you were using parse_url() on the original array string. parse_url()
breaks the string into its component parts, much like my explode
example.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] String Parse Help for novice

2010-06-13 Thread Karl DeSaulniers


On Jun 13, 2010, at 5:35 PM, Rick Dwyer wrote:


OK, I get the following error:

Warning: basename() expects parameter 1 to be string, array given  
in


When I use the following:

$thepath = parse_url($url);
$filename = basename($thepath);

Is my variable thepath not automatically string?

 --Rick


Oops I meant
echo($the_path);
or echo both and see.


Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] String Parse Help for novice

2010-06-13 Thread Ashley Sheridan
On Sun, 2010-06-13 at 17:35 -0500, Karl DeSaulniers wrote:

> On Jun 13, 2010, at 5:31 PM, Ashley Sheridan wrote:
> 
> > On Sun, 2010-06-13 at 17:27 -0500, Karl DeSaulniers wrote:
> >
> >> On Jun 13, 2010, at 5:23 PM, Ashley Sheridan wrote:
> >>
> >>> On Sun, 2010-06-13 at 18:13 -0400, Rick Dwyer wrote:
> >>>
>  Hello List.
> 
>  I need to parse the PATH portion of URL.  I have assigned the path
>  portion to a variable using the following:
> 
>  $thepath = parse_url($url);
> 
> 
>  Now I need to break each portion of the path down into its own
>  variable.  The problem is, the path can vary considerably as  
>  follows:
> 
>  /mydirectory/mysubdirectory/anothersubdirectory/mypage.php
> 
>  vs.
> 
>  /mydirectory/mypage.php
> 
>  How do I get the either of the above url paths broken out so the
>  variables equal the following
> 
>  $dir1 = mydirectory
>  $dir2 = mysubdirectory
>  $dir3 = anothersubdirectory
>  $page = mypage.php
> 
>  ...etc... if there were 5 more subdirectories... they would be
>  dynamically assigned to a variable.
> 
>    Thanks for any help.
> 
>    --Rick
> 
> 
> 
> >>>
> >>>
> >>> $filename = basename($path);
> >>> $parts = explode('/', $path);
> >>> $directories = array_pop($parts);
> >>>
> >>> Now you have your directories in the $directories array and the
> >>> filename
> >>> in $filename.
> >>>
> >>> Thanks,
> >>> Ash
> >>> http://www.ashleysheridan.co.uk
> >>>
> >>>
> >>
> >>
> >> Hi Ash,
> >> What about the "//" in  the beginning?
> >>
> >>
> >> Karl DeSaulniers
> >> Design Drumm
> >> http://designdrumm.com
> >>
> >>
> >
> >
> > As your example string didn't have a double slash I didn't write code
> > for that, but it's easy enough to remove 0-length strings from the
> > $directories array.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> 
> :) Rick's example, but how in your example do we look for a double  
> forward slash?
> THX
> 
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
> 
> 


You don't look for one, that's the point. The explode() breaks the
string into an array at every occurrence of a '/' character. This will
leave zero length strings in the array if there is a double // (which
wasn't in any given example in this thread that I saw) When you use the
array, just don't do anything with empty elements!

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] String Parse Help for novice

2010-06-13 Thread Karl DeSaulniers


On Jun 13, 2010, at 5:35 PM, Rick Dwyer wrote:


OK, I get the following error:

Warning: basename() expects parameter 1 to be string, array given  
in


When I use the following:

$thepath = parse_url($url);
$filename = basename($thepath);

Is my variable thepath not automatically string?

 --Rick




try echo($url); and see


Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] String Parse Help for novice

2010-06-13 Thread Rick Dwyer

OK, I get the following error:

Warning: basename() expects parameter 1 to be string, array given in

When I use the following:

$thepath = parse_url($url);
$filename = basename($thepath);

Is my variable thepath not automatically string?

 --Rick


On Jun 13, 2010, at 6:23 PM, Ashley Sheridan wrote:


On Sun, 2010-06-13 at 18:13 -0400, Rick Dwyer wrote:


Hello List.

I need to parse the PATH portion of URL.  I have assigned the path
portion to a variable using the following:

$thepath = parse_url($url);


Now I need to break each portion of the path down into its own
variable.  The problem is, the path can vary considerably as follows:

/mydirectory/mysubdirectory/anothersubdirectory/mypage.php

vs.

/mydirectory/mypage.php

How do I get the either of the above url paths broken out so the
variables equal the following

$dir1 = mydirectory
$dir2 = mysubdirectory
$dir3 = anothersubdirectory
$page = mypage.php

...etc... if there were 5 more subdirectories... they would be
dynamically assigned to a variable.

  Thanks for any help.

  --Rick





$filename = basename($path);
$parts = explode('/', $path);
$directories = array_pop($parts);

Now you have your directories in the $directories array and the  
filename in $filename.


Thanks,
Ash
http://www.ashleysheridan.co.uk





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] String Parse Help for novice

2010-06-13 Thread Karl DeSaulniers


On Jun 13, 2010, at 5:31 PM, Ashley Sheridan wrote:


On Sun, 2010-06-13 at 17:27 -0500, Karl DeSaulniers wrote:


On Jun 13, 2010, at 5:23 PM, Ashley Sheridan wrote:


On Sun, 2010-06-13 at 18:13 -0400, Rick Dwyer wrote:


Hello List.

I need to parse the PATH portion of URL.  I have assigned the path
portion to a variable using the following:

$thepath = parse_url($url);


Now I need to break each portion of the path down into its own
variable.  The problem is, the path can vary considerably as  
follows:


/mydirectory/mysubdirectory/anothersubdirectory/mypage.php

vs.

/mydirectory/mypage.php

How do I get the either of the above url paths broken out so the
variables equal the following

$dir1 = mydirectory
$dir2 = mysubdirectory
$dir3 = anothersubdirectory
$page = mypage.php

...etc... if there were 5 more subdirectories... they would be
dynamically assigned to a variable.

  Thanks for any help.

  --Rick






$filename = basename($path);
$parts = explode('/', $path);
$directories = array_pop($parts);

Now you have your directories in the $directories array and the
filename
in $filename.

Thanks,
Ash
http://www.ashleysheridan.co.uk





Hi Ash,
What about the "//" in  the beginning?


Karl DeSaulniers
Design Drumm
http://designdrumm.com





As your example string didn't have a double slash I didn't write code
for that, but it's easy enough to remove 0-length strings from the
$directories array.

Thanks,
Ash
http://www.ashleysheridan.co.uk




:) Rick's example, but how in your example do we look for a double  
forward slash?

THX

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] String Parse Help for novice

2010-06-13 Thread Ashley Sheridan
On Sun, 2010-06-13 at 17:27 -0500, Karl DeSaulniers wrote:

> On Jun 13, 2010, at 5:23 PM, Ashley Sheridan wrote:
> 
> > On Sun, 2010-06-13 at 18:13 -0400, Rick Dwyer wrote:
> >
> >> Hello List.
> >>
> >> I need to parse the PATH portion of URL.  I have assigned the path
> >> portion to a variable using the following:
> >>
> >> $thepath = parse_url($url);
> >>
> >>
> >> Now I need to break each portion of the path down into its own
> >> variable.  The problem is, the path can vary considerably as follows:
> >>
> >> /mydirectory/mysubdirectory/anothersubdirectory/mypage.php
> >>
> >> vs.
> >>
> >> /mydirectory/mypage.php
> >>
> >> How do I get the either of the above url paths broken out so the
> >> variables equal the following
> >>
> >> $dir1 = mydirectory
> >> $dir2 = mysubdirectory
> >> $dir3 = anothersubdirectory
> >> $page = mypage.php
> >>
> >> ...etc... if there were 5 more subdirectories... they would be
> >> dynamically assigned to a variable.
> >>
> >>   Thanks for any help.
> >>
> >>   --Rick
> >>
> >>
> >>
> >
> >
> > $filename = basename($path);
> > $parts = explode('/', $path);
> > $directories = array_pop($parts);
> >
> > Now you have your directories in the $directories array and the  
> > filename
> > in $filename.
> >
> > Thanks,
> > Ash
> > http://www.ashleysheridan.co.uk
> >
> >
> 
> 
> Hi Ash,
> What about the "//" in  the beginning?
> 
> 
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
> 
> 


As your example string didn't have a double slash I didn't write code
for that, but it's easy enough to remove 0-length strings from the
$directories array.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] String Parse Help for novice

2010-06-13 Thread Karl DeSaulniers


On Jun 13, 2010, at 5:23 PM, Ashley Sheridan wrote:


On Sun, 2010-06-13 at 18:13 -0400, Rick Dwyer wrote:


Hello List.

I need to parse the PATH portion of URL.  I have assigned the path
portion to a variable using the following:

$thepath = parse_url($url);


Now I need to break each portion of the path down into its own
variable.  The problem is, the path can vary considerably as follows:

/mydirectory/mysubdirectory/anothersubdirectory/mypage.php

vs.

/mydirectory/mypage.php

How do I get the either of the above url paths broken out so the
variables equal the following

$dir1 = mydirectory
$dir2 = mysubdirectory
$dir3 = anothersubdirectory
$page = mypage.php

...etc... if there were 5 more subdirectories... they would be
dynamically assigned to a variable.

  Thanks for any help.

  --Rick






$filename = basename($path);
$parts = explode('/', $path);
$directories = array_pop($parts);

Now you have your directories in the $directories array and the  
filename

in $filename.

Thanks,
Ash
http://www.ashleysheridan.co.uk





Hi Ash,
What about the "//" in  the beginning?


Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] String Parse Help for novice

2010-06-13 Thread Karl DeSaulniers


On Jun 13, 2010, at 5:13 PM, Rick Dwyer wrote:


Hello List.

I need to parse the PATH portion of URL.  I have assigned the path  
portion to a variable using the following:


$thepath = parse_url($url);


Now I need to break each portion of the path down into its own  
variable.  The problem is, the path can vary considerably as follows:


/mydirectory/mysubdirectory/anothersubdirectory/mypage.php

vs.

/mydirectory/mypage.php

How do I get the either of the above url paths broken out so the  
variables equal the following


$dir1 = mydirectory
$dir2 = mysubdirectory
$dir3 = anothersubdirectory
$page = mypage.php

...etc... if there were 5 more subdirectories... they would be  
dynamically assigned to a variable.


 Thanks for any help.

 --Rick



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Hi Rick,

Just a thought, but cant you do something to separate them according  
to the "/" (forward slash)?

maybe preg_replace or something. Sorry not much more help.


Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] String Parse Help for novice

2010-06-13 Thread Ashley Sheridan
On Sun, 2010-06-13 at 18:13 -0400, Rick Dwyer wrote:

> Hello List.
> 
> I need to parse the PATH portion of URL.  I have assigned the path  
> portion to a variable using the following:
> 
> $thepath = parse_url($url);
> 
> 
> Now I need to break each portion of the path down into its own  
> variable.  The problem is, the path can vary considerably as follows:
> 
> /mydirectory/mysubdirectory/anothersubdirectory/mypage.php
> 
> vs.
> 
> /mydirectory/mypage.php
> 
> How do I get the either of the above url paths broken out so the  
> variables equal the following
> 
> $dir1 = mydirectory
> $dir2 = mysubdirectory
> $dir3 = anothersubdirectory
> $page = mypage.php
> 
> ...etc... if there were 5 more subdirectories... they would be  
> dynamically assigned to a variable.
> 
>   Thanks for any help.
> 
>   --Rick
> 
> 
> 


$filename = basename($path);
$parts = explode('/', $path);
$directories = array_pop($parts);

Now you have your directories in the $directories array and the filename
in $filename.

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] String Parse Help for novice

2010-06-13 Thread Rick Dwyer

Hello List.

I need to parse the PATH portion of URL.  I have assigned the path  
portion to a variable using the following:


$thepath = parse_url($url);


Now I need to break each portion of the path down into its own  
variable.  The problem is, the path can vary considerably as follows:


/mydirectory/mysubdirectory/anothersubdirectory/mypage.php

vs.

/mydirectory/mypage.php

How do I get the either of the above url paths broken out so the  
variables equal the following


$dir1 = mydirectory
$dir2 = mysubdirectory
$dir3 = anothersubdirectory
$page = mypage.php

...etc... if there were 5 more subdirectories... they would be  
dynamically assigned to a variable.


 Thanks for any help.

 --Rick



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: PHP - Header ERROR

2010-06-13 Thread Steve

On 6/13/2010 9:37 AM, Shawn McKenzie wrote:

On 06/13/2010 08:43 AM, Don Wieland wrote:
   

Hello,

I have a contact form with three fields, name, email, and comment, and a
CAPTCHA

I am doing some basic validation for empty fields but am getting a PHP
error when trying to redirect back to the original page with an ERROR,

It seems when my COMMENT field containss, it generates the PHP
ERROR. Nohttp://www.dwdataconcepts.com/DevSup.html

Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro 9
or higher
http://www.appointment10.com

For a quick overview -
http://www.appointment10.com/Appt10_Promo/Overview.html


 

You still haven't given us what ERROR you receive, but you need to
urlencode() $_POST['comment'] and the other values in the URL query string.

   


echo "HI";
header(...

This part will cause an error since outputting anything will cause the 
headers to be sent (unless output buffering is on). Once sent, the 
headers cannot be modified.


You should also think about using urlencode on the values being sent in 
the redirect URLs, or even using a code to reference each error.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: PHP - Header ERROR

2010-06-13 Thread Shawn McKenzie
On 06/13/2010 08:43 AM, Don Wieland wrote:
> Hello,
> 
> I have a contact form with three fields, name, email, and comment, and a
> CAPTCHA
> 
> I am doing some basic validation for empty fields but am getting a PHP
> error when trying to redirect back to the original page with an ERROR,
> 
> It seems when my COMMENT field contains s, it generates the PHP
> ERROR. No  that is necessary for the GET STRING return?
> 
> if($_POST['name'] AND $_POST['email'] AND $_POST['comment']) {
> }else{
> header("location: contactus.php?Error=Missing values in REQUIRED
> FIELDS&name=".$_POST['name']."&email=".$_POST['email']."&comment=".$_POST['comment']);
> 
> exit();
> }
> 
> 
> session_start();
> 
> 
> 
> if($_SESSION['Captcha_Str'] != $_POST['scode']) {
> echo "HI";
> header("location: contactus.php?Error=You did not enter your SECURITY
> CODE correctly. It is case
> sensitive.&name=".$_POST['name']."&email=".$_POST['email']."&comment=".$_POST['comment']);
> 
> exit();
> }
> 
> 
> Don Wieland
> D W   D a t a   C o n c e p t s
> ~
> d...@dwdataconcepts.com
> Direct Line - (949) 305-2771
> 
> Integrated data solutions to fit your business needs.
> 
> Need assistance in dialing in your FileMaker solution? Check out our
> Developer Support Plan at:
> http://www.dwdataconcepts.com/DevSup.html
> 
> Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro 9
> or higher
> http://www.appointment10.com
> 
> For a quick overview -
> http://www.appointment10.com/Appt10_Promo/Overview.html
> 
> 

You still haven't given us what ERROR you receive, but you need to
urlencode() $_POST['comment'] and the other values in the URL query string.

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Cookie access with CLI

2010-06-13 Thread Shawn McKenzie
On 06/13/2010 09:58 AM, David Česal wrote:
> Hello,
> 
> I'm trying to access (from CLI) some website, where login is required.
> Please, is it possible to set/save some cookies first (login session
> information) and then access the website as logged user? All through CLI.
> 
>  
> 
> Thank you very much for any information.
> 
>  
> 
> David Cesal
> 
> 

I'm almost positive you can do this with cURL and it should be fairly
simple.  Check it out.

http://php.net/manual/en/book.curl.php

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] howto run sql script with php?

2010-06-13 Thread Brandon Rampersad
niggers

On Sun, Jun 13, 2010 at 11:07 AM, Stephan Ebelt  wrote:

> On Sun, Jun 13, 2010 at 12:52:18PM +0200, Stephan Ebelt wrote:
> [...]
> > > Use mysqli - it supports running multiple queries at once.
> >
> > sometimes its as easy as that. I'll give it a try.
>
> not quite as easy:  mysqli->multi_query() works nice with many queries in a
> string but that DELIMITER syntax still produces an error...
>
> stephan
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
A Brandon_R Production


Re: [PHP] PHP - Header ERROR

2010-06-13 Thread Ashley Sheridan
On Sun, 2010-06-13 at 08:06 -0700, Don Wieland wrote:

> On Jun 13, 2010, at 7:53 AM, Ashley Sheridan wrote:
> 
> > On Sun, 2010-06-13 at 07:50 -0700, Don Wieland wrote:
> >
> >> Yeah - I thought about that, but I don't know how to do this. I  
> >> have a
> >> partner who admins my virtual private server. Oh well ;-)
> >>
> >>
> >>
> >> It is probably something I need to do to the header() string to
> >> accommodate the s. I am redirecting back to the original form,
> >> displaying an ERROR, then re-populating the fields via the GET  
> >> string.
> >> The omission of this is CHOKING PHP.
> >>
> >>
> >>
> >> Don
> >>
> >>
> >> On Jun 13, 2010, at 7:39 AM, Ashley Sheridan wrote:
> >>
> >>
> >>
> >>> Turn on display_errors in your php.ini, or read the error log. That
> >>> will show you exactly what your error is, and then if you don't know
> >>> how to fix that error, post it back here.
> >>
> >>
> >>
> >> Don Wieland
> >> D W   D a t a   C o n c e p t s
> >> ~
> >> d...@dwdataconcepts.com
> >> Direct Line - (949) 305-2771
> >>
> >>
> >> Integrated data solutions to fit your business needs.
> >>
> >>
> >> Need assistance in dialing in your FileMaker solution? Check out our
> >> Developer Support Plan at:
> >> http://www.dwdataconcepts.com/DevSup.html
> >>
> >>
> >> Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro
> >> 9 or higher
> >> http://www.appointment10.com
> >>
> >>
> >>
> >> For a quick overview -
> >>
> >> http://www.appointment10.com/Appt10_Promo/Overview.html
> >>
> >>
> >>
> >
> > Add a line in to your .htaccess file then to turn error displaying on.
> > Note that if this is a live server then you shouldn't really do this,
> > but if you have to, turn them back off again asap.
> >
> > php_flag display_errors off
> >
> 
> When I look at my FTP client, I cannot see this .htaccess file. This  
> is a live server, so I am hesitant to find it anyways. I will wait for  
> my partner to assist me with this config so I can see the error.
> 
> Unless someone know what I am missing by description. We'll see ;-)
> 
> 
> > ps. please keep the list copied in, as other people might be able to
> > benefit from the thread.
> >
> 
> OOPS! Sorry, we'll do from now on.
> 
> Don


If the file doesn't exist you can make it. Some FTP clients may hide the
file as it begins with a period. By default, this character is used to
hide files on *nix-based systems. Windows tends to choke every now and
again on .htaccess files, as it sees it as a file with no name and just
an extension.

You mentioned that there were newline characters in the URL you were
attempting to redirect to. URLs can't contain newline characters, so
that could be causing it to choke. If in doubt, put the URL into a
string first and echo that out and see what the result is. You may need
to view the source of the output in your browser, as the browser will be
treating that string as HTML by default, which treats whitespace
differently.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] howto run sql script with php?

2010-06-13 Thread Stephan Ebelt
On Sun, Jun 13, 2010 at 12:52:18PM +0200, Stephan Ebelt wrote:
[...]
> > Use mysqli - it supports running multiple queries at once.
> 
> sometimes its as easy as that. I'll give it a try.

not quite as easy:  mysqli->multi_query() works nice with many queries in a
string but that DELIMITER syntax still produces an error...  

stephan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP - Header ERROR

2010-06-13 Thread Don Wieland


On Jun 13, 2010, at 7:53 AM, Ashley Sheridan wrote:


On Sun, 2010-06-13 at 07:50 -0700, Don Wieland wrote:

Yeah - I thought about that, but I don't know how to do this. I  
have a

partner who admins my virtual private server. Oh well ;-)



It is probably something I need to do to the header() string to
accommodate the s. I am redirecting back to the original form,
displaying an ERROR, then re-populating the fields via the GET  
string.

The omission of this is CHOKING PHP.



Don


On Jun 13, 2010, at 7:39 AM, Ashley Sheridan wrote:




Turn on display_errors in your php.ini, or read the error log. That
will show you exactly what your error is, and then if you don't know
how to fix that error, post it back here.




Don Wieland
D W   D a t a   C o n c e p t s
~
d...@dwdataconcepts.com
Direct Line - (949) 305-2771


Integrated data solutions to fit your business needs.


Need assistance in dialing in your FileMaker solution? Check out our
Developer Support Plan at:
http://www.dwdataconcepts.com/DevSup.html


Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro
9 or higher
http://www.appointment10.com



For a quick overview -

http://www.appointment10.com/Appt10_Promo/Overview.html





Add a line in to your .htaccess file then to turn error displaying on.
Note that if this is a live server then you shouldn't really do this,
but if you have to, turn them back off again asap.

php_flag display_errors off



When I look at my FTP client, I cannot see this .htaccess file. This  
is a live server, so I am hesitant to find it anyways. I will wait for  
my partner to assist me with this config so I can see the error.


Unless someone know what I am missing by description. We'll see ;-)



ps. please keep the list copied in, as other people might be able to
benefit from the thread.



OOPS! Sorry, we'll do from now on.

Don

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Cookie access with CLI

2010-06-13 Thread Ashley Sheridan
On Sun, 2010-06-13 at 16:58 +0200, David Česal wrote:

> Hello,
> 
> I'm trying to access (from CLI) some website, where login is required.
> Please, is it possible to set/save some cookies first (login session
> information) and then access the website as logged user? All through CLI.
> 
>  
> 
> Thank you very much for any information.
> 
>  
> 
> David Cesal
> 


I don't believe cookies are available in a CLI script, they are a
construct of the browser/web server setup. Running PHP via the command
line is just like any other script over the command line.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] howto run sql script with php?

2010-06-13 Thread Stephan Ebelt
On Sun, Jun 13, 2010 at 12:14:53PM +0100, Ashley Sheridan wrote:
>On Sun, 2010-06-13 at 12:52 +0200, Stephan Ebelt wrote:
> 
>  On Sun, Jun 13, 2010 at 11:29:14AM +0200, Peter Lind wrote:
>  > On 13 June 2010 11:05, Stephan Ebelt <[1]...@shared-files.de> wrote:
>  > > Hello,
>  > >
>  > > I am trying to run a .sql script produced with mysql-dump from a php 
> script but
>  > > failed to find a rudimentary robust solution yet.
>  > >
>  > > mysql_query() can only run one query at a time. Thus its necessary to 
> somehow
>  > > parse the input file and separate the queries... which is difficult 
> since the
>  > > syntax can be quite complex.
>  > >
>  >
>  > Use mysqli - it supports running multiple queries at once.
> 
>  sometimes its as easy as that. I'll give it a try.
> 
>  thanks,
>  stephan
> 
> 
> 
>Why do you have to use PHP at all to do this? You could run the query
>directly at the MySQL console.
> 
>Failing that, why not use a tool such as phpMyAdmin, which will do all the
>hard work for you?

I use it to deploy schema updates and run unittests. So there are many sql
files running many times actually. Its been working fine for years until I came
up with wanting a trigger recently...

good point to check how phpMyAdmin does this. They must have faced the same
problem.

stephan

> 
>Thanks,
>Ash
>[2]http://www.ashleysheridan.co.uk
> 
> References
> 
>Visible links
>1. mailto:s...@shared-files.de
>2. http://www.ashleysheridan.co.uk/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Cookie access with CLI

2010-06-13 Thread David Česal
Hello,

I'm trying to access (from CLI) some website, where login is required.
Please, is it possible to set/save some cookies first (login session
information) and then access the website as logged user? All through CLI.

 

Thank you very much for any information.

 

David Cesal



Re: [PHP] PHP - Header ERROR

2010-06-13 Thread Ashley Sheridan
On Sun, 2010-06-13 at 07:50 -0700, Don Wieland wrote:

> Yeah - I thought about that, but I don't know how to do this. I have a
> partner who admins my virtual private server. Oh well ;-)
> 
> 
> 
> It is probably something I need to do to the header() string to
> accommodate the s. I am redirecting back to the original form,
> displaying an ERROR, then re-populating the fields via the GET string.
> The omission of this is CHOKING PHP.
> 
> 
> 
> Don
> 
> 
> On Jun 13, 2010, at 7:39 AM, Ashley Sheridan wrote:
> 
> 
> 
> > Turn on display_errors in your php.ini, or read the error log. That
> > will show you exactly what your error is, and then if you don't know
> > how to fix that error, post it back here.
> 
> 
> 
> Don Wieland
> D W   D a t a   C o n c e p t s
> ~
> d...@dwdataconcepts.com
> Direct Line - (949) 305-2771
> 
> 
> Integrated data solutions to fit your business needs.
> 
> 
> Need assistance in dialing in your FileMaker solution? Check out our
> Developer Support Plan at:
> http://www.dwdataconcepts.com/DevSup.html
> 
> 
> Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro
> 9 or higher
> http://www.appointment10.com
> 
> 
> 
> For a quick overview - 
> 
> http://www.appointment10.com/Appt10_Promo/Overview.html
> 
> 
> 

Add a line in to your .htaccess file then to turn error displaying on.
Note that if this is a live server then you shouldn't really do this,
but if you have to, turn them back off again asap.

php_flag display_errors off

ps. please keep the list copied in, as other people might be able to
benefit from the thread.

psps. please try not to top post; every time you do, a kitten dies ;)

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] PHP - Header ERROR

2010-06-13 Thread Ashley Sheridan
On Sun, 2010-06-13 at 06:43 -0700, Don Wieland wrote:

> Hello,
> 
> I have a contact form with three fields, name, email, and comment, and  
> a CAPTCHA
> 
> I am doing some basic validation for empty fields but am getting a PHP  
> error when trying to redirect back to the original page with an ERROR,
> 
> It seems when my COMMENT field contains s, it generates the PHP  
> ERROR. No  comment that is necessary for the GET STRING return?
> 
> if($_POST['name'] AND $_POST['email'] AND $_POST['comment']) {
> }else{
> header("location: contactus.php?Error=Missing values in REQUIRED  
> FIELDS&name=".$_POST['name']."&email=".$_POST['email']."&comment=". 
> $_POST['comment']);
> exit();
> }
> 
> 
> session_start();
> 
> 
> 
> if($_SESSION['Captcha_Str'] != $_POST['scode']) {
> echo "HI";
> header("location: contactus.php?Error=You did not enter your SECURITY  
> CODE correctly. It is case sensitive.&name=".$_POST['name']."&email=". 
> $_POST['email']."&comment=".$_POST['comment']);
> exit();
> }
> 
> 
> Don Wieland
> D W   D a t a   C o n c e p t s
> ~
> d...@dwdataconcepts.com
> Direct Line - (949) 305-2771
> 
> Integrated data solutions to fit your business needs.
> 
> Need assistance in dialing in your FileMaker solution? Check out our  
> Developer Support Plan at:
> http://www.dwdataconcepts.com/DevSup.html
> 
> Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro  
> 9 or higher
> http://www.appointment10.com
> 
> For a quick overview -
> http://www.appointment10.com/Appt10_Promo/Overview.html
> 


What exactly is the error you're seeing?

Thanks,
Ash
http://www.ashleysheridan.co.uk




[PHP] PHP - Header ERROR

2010-06-13 Thread Don Wieland

Hello,

I have a contact form with three fields, name, email, and comment, and  
a CAPTCHA


I am doing some basic validation for empty fields but am getting a PHP  
error when trying to redirect back to the original page with an ERROR,


It seems when my COMMENT field contains s, it generates the PHP  
ERROR. No comment that is necessary for the GET STRING return?


if($_POST['name'] AND $_POST['email'] AND $_POST['comment']) {
}else{
header("location: contactus.php?Error=Missing values in REQUIRED  
FIELDS&name=".$_POST['name']."&email=".$_POST['email']."&comment=". 
$_POST['comment']);

exit();
}


session_start();



if($_SESSION['Captcha_Str'] != $_POST['scode']) {
echo "HI";
header("location: contactus.php?Error=You did not enter your SECURITY  
CODE correctly. It is case sensitive.&name=".$_POST['name']."&email=". 
$_POST['email']."&comment=".$_POST['comment']);

exit();
}


Don Wieland
D W   D a t a   C o n c e p t s
~
d...@dwdataconcepts.com
Direct Line - (949) 305-2771

Integrated data solutions to fit your business needs.

Need assistance in dialing in your FileMaker solution? Check out our  
Developer Support Plan at:

http://www.dwdataconcepts.com/DevSup.html

Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro  
9 or higher

http://www.appointment10.com

For a quick overview -
http://www.appointment10.com/Appt10_Promo/Overview.html



Re: [PHP] howto run sql script with php?

2010-06-13 Thread Ashley Sheridan
On Sun, 2010-06-13 at 12:52 +0200, Stephan Ebelt wrote:

> On Sun, Jun 13, 2010 at 11:29:14AM +0200, Peter Lind wrote:
> > On 13 June 2010 11:05, Stephan Ebelt  wrote:
> > > Hello,
> > >
> > > I am trying to run a .sql script produced with mysql-dump from a php 
> > > script but
> > > failed to find a rudimentary robust solution yet.
> > >
> > > mysql_query() can only run one query at a time. Thus its necessary to 
> > > somehow
> > > parse the input file and separate the queries... which is difficult since 
> > > the
> > > syntax can be quite complex.
> > >
> > 
> > Use mysqli - it supports running multiple queries at once.
> 
> sometimes its as easy as that. I'll give it a try.
> 
> thanks,
> stephan
> 
> 


Why do you have to use PHP at all to do this? You could run the query
directly at the MySQL console.

Failing that, why not use a tool such as phpMyAdmin, which will do all
the hard work for you?

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] howto run sql script with php?

2010-06-13 Thread Stephan Ebelt
On Sun, Jun 13, 2010 at 11:29:14AM +0200, Peter Lind wrote:
> On 13 June 2010 11:05, Stephan Ebelt  wrote:
> > Hello,
> >
> > I am trying to run a .sql script produced with mysql-dump from a php script 
> > but
> > failed to find a rudimentary robust solution yet.
> >
> > mysql_query() can only run one query at a time. Thus its necessary to 
> > somehow
> > parse the input file and separate the queries... which is difficult since 
> > the
> > syntax can be quite complex.
> >
> 
> Use mysqli - it supports running multiple queries at once.

sometimes its as easy as that. I'll give it a try.

thanks,
stephan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] howto run sql script with php?

2010-06-13 Thread Peter Lind
On 13 June 2010 11:05, Stephan Ebelt  wrote:
> Hello,
>
> I am trying to run a .sql script produced with mysql-dump from a php script 
> but
> failed to find a rudimentary robust solution yet.
>
> mysql_query() can only run one query at a time. Thus its necessary to somehow
> parse the input file and separate the queries... which is difficult since the
> syntax can be quite complex.
>

Use mysqli - it supports running multiple queries at once.

Regards
Peter


-- 

WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] howto run sql script with php?

2010-06-13 Thread Stephan Ebelt
Hello,

I am trying to run a .sql script produced with mysql-dump from a php script but
failed to find a rudimentary robust solution yet.

mysql_query() can only run one query at a time. Thus its necessary to somehow
parse the input file and separate the queries... which is difficult since the
syntax can be quite complex.

So far I managed to run most CREATE TABLE and INSERT queries just by
dropping newlines (\n) and explode()ing the input by ';'. Now I am stuck with a
CREATE TRIGGER statement because mysql-dump does this:

===
DELIMITER ;;
CREATE TRIGGER ... ON ...
FOR EACH ROW BEGIN ...
...
END;
;;
DELIMITER ;
===

exploding that string by ';' results in 4 (or more) queries which are invalid
syntax then. And I have no glue on what else mysql-dump may come up with on
other occasions.

does anyone know how to do that properly?

I dont favor importing the dumps via shell command like 'cat some.dump | mysql'
either. 

stephan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php