php-general Digest 22 May 2006 13:20:49 -0000 Issue 4142

Topics (messages 236593 through 236625):

Re: Uploading Files - SOLVED
        236593 by: P. Guethlein

Re: Problem after migration of script from Fedora Core to RHEL
        236594 by: Chris
        236595 by: Chris

Re: Uploading Files - Beginner
        236596 by: P. Guethlein

Need Help Please
        236597 by: marvin hunkin
        236598 by: Wolf
        236599 by: Chris
        236600 by: Chris
        236601 by: John Nichel
        236603 by: Paul Novitski

/usr/local/libexec/apache22/libphp4.so not installed
        236602 by: Noah
        236604 by: Noah
        236605 by: Chris
        236609 by: Noah
        236610 by: Chris

Thank You for Helping Me
        236606 by: marvin hunkin

Getting the right path output from $_SERVER
        236607 by: Dave M G
        236608 by: Chris

PHP 4.4.3RC1 testing
        236611 by: Derick Rethans

Array name out of field value with data
        236612 by: Jonas Rosling
        236614 by: nicolas figaro
        236616 by: Jonas Rosling

getRow method of DB_Common class
        236613 by: Nirmalya Lahiri
        236615 by: Chris

Cookies & https
        236617 by: Michael Satterwhite
        236620 by: Stut
        236622 by: Chris

Group date with category
        236618 by: Jonas Rosling
        236619 by: Dave Goodchild

Convert a .pl script to .php (willing to pay via paypal or CC)
        236621 by: Ryan A

oops! flock() not work
        236623 by: n.g.
        236624 by: n.g.

Re: Date() finding yesterday
        236625 by: Jef Sullivan

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
It worked perfectly!

ES Simple Uploader Script located at
http://www.hotscripts.com/PHP/Scripts_and_Programs/File_Manipulation/Upload_Systems/index.html

If anyone else is on their learning curve...

-Pete



At 04:56 PM 05/21/2006, P. Guethlein wrote:
I'm still very frustrated trying to figure out how to upload a file. I must have tried 15 different coding examples and none of them work.

When I try and debug and do a
print_r($_FILES);

All I'm getting back is array() with no data.

File upload is allowed in my php.ini

Can anyone offer any other insight before my laptop sails into the wall ?<smile>

Thanks, -Pete




At 02:03 PM 05/21/2006, tedd wrote:
At 1:52 AM -0700 5/21/06, P. Guethlein wrote:
I'm at one of those frustration levels.... can't seem to get a script working that will post and upload a file to the server. I"m working with the below. Can you help?

Guethlein:

Yes, try this -- watch for line breaks. Also, create folders "uploads/tmp".

The code works "as is" for me except that I have to give the "tmp" folder 0777 permissions* because the code runs as "nobody". I haven't figured out how to get around that, but I can change the uploaded file's permissions without error. (If anyone wants to show me OFF-LIST how to do this without setting the tmp folder to 0777, I'm all ears, but don't beat me up because I'm trying to learn.)

Code follows:

<?php

// This allows users to upload files to the server.

if (isset($_POST['submit'])) // handle the form -- start of main Submit conditional..
{

// Create the file name.

$filename = $_FILES['upload']['name'];
$file_loaded = 0;

// Move the file over.

if (move_uploaded_file($_FILES['upload']['tmp_name'], "uploads/tmp/$filename"))
 {
 echo '<p>The file has been uploaded to the server.</p>';
 chmod("uploads/tmp/$filename", 0755);
 echo ( '<p>' . $filename . '</p>' );
 }
else
 {
 echo ('<p><font color="red">ERROR: The file was not upload.</font></p>');
 }
}
else
{

?>

<form enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
 <p>
 <input type="hidden" name="MAX_FILE_SIZE" value="30000">
 </p>
 <fieldset>
 <legend>Select the file to upload:</legend>
 <p>
 <b>File:</b>
 <input type="file" name="upload" />
 </p>
 </fieldset>
 <p>
 <input type="submit" name="submit" value="Submit" />
 </p>
</form>

<?php
}
?>

hth's

tedd

* Larry Ullman in his books says to use 0777 permission for uploading files. However, he does say that it is less secure and should be placed outside of the web directory.
--
------------------------------------------------------------------------------------
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


--- End Message ---
--- Begin Message ---
benmoreassynt wrote:
Hi,

This has me confused. Have just moved servers from FC4 box to RHEL box.
Basically all the settings seem to be the same. PHP5.0.4, MySQL 5.0.20
....
So it is telling that the script is trying to insert duplicate entries. The
exact same script works fine on the old box without entering duplicate
entries.

It has nothing to do with the script and everything to do with the database.

You might need to reset the auto_increment count (search the archives, there have been lots of examples on how to do this posted - otherwise search http://dev.mysql.com).

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Chris wrote:
benmoreassynt wrote:

Hi,

This has me confused. Have just moved servers from FC4 box to RHEL box.
Basically all the settings seem to be the same. PHP5.0.4, MySQL 5.0.20

....

So it is telling that the script is trying to insert duplicate entries. The
exact same script works fine on the old box without entering duplicate
entries.


It has nothing to do with the script and everything to do with the database.

You might need to reset the auto_increment count (search the archives, there have been lots of examples on how to do this posted - otherwise search http://dev.mysql.com).


Forgot to add.. this is especially true if you have copied data from one server to the other. A database dump should do this for you, if you've done it by hand then you're on your own..

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Jay,

Thanks for the response. I finally found a script that actually worked immediately. I posted the link in an earlier message. I found the authors directly link
here http://www.energyscripts.com/Products/product2.html
for others that may need help.

-Pete


At 05:23 PM 05/21/2006, you wrote:
[snip]
I'm still very frustrated trying to figure out how to upload a
file.  I must have tried 15 different coding examples and none of them
work.

When I try and debug and do a
print_r($_FILES);

All I'm getting back is array() with no data.

File upload is allowed in my php.ini

Can anyone offer any other insight before my laptop sails into the
wall ?<smile>
[/snip]

Have you tried the very simple example shown in the manual?
http://us3.php.net/manual/en/features.file-upload.php

I will be right by my computer for a while, so make sure to reply to the
list. Pay particular attention to MAX_FILE_SIZE. Even if file upload is
allowed in you php.in are you running in safe mode?

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

--- End Message ---
--- Begin Message ---
Hi.
doing an assignment, for my Certificate Four In Website Administration.
now got a couple of problems.
will explain what i have to do.
create a html form, which i have done.
in textpad.
now, when i open the form, it does not set focus to the first form field which is the user name.
goes to the login button.
why is this?
can any one help me?
okay, will explain.
and to create a script for a login page, on a network.
and using php, and now got the user to enter their username and password, and then to display a message, saying the person logged in, and to display the date. if the user, types in the wrong user name and password, then a error message is displayed, and a link back to the form, is displayed. now got the problem of a error, when checking to see if the error happened or not, and whether to let them in or not.
so will paste the html form, and the php code below.
if any one can help me how to fix these problems, then let me know asap.
cheers Marvin.


Html Form:


Code Starts Here:

<html>
<head>
<script language=text/javascript>
function SetFocus
{
document.forms[0].username.focus();
}
</script>
<title>User Login Form</title>
</head>
<body onload="SetFocus();">
<form action="UserDetails.php" method="post">
<p>User Name: <input type="text" name="username"> </p> <br>
<p>Password: <input type="password" name="password"> </p> <br>
<p><input type="submit" value="Login"> </p>
</form>
</body>
</html>


Php Code:


Code Starts Here:

        <?php
$_POST['username'];
$_POST['password'];
if ('username'='username') & ('password'='password')
{
echo "Letting you login into the tafe network. <br>\n";
echo "Marvin Hunkin has successfully logged into the Tafe network. <br>\n";
echo "Please Wait ... Loading Your Personal Settings ... <br>\n";
gmdate('d-m-Y', time()+(10*60*60));
}
else
{
echo "Not letting you login into the tafe network. <br>\n";
echo "Error! You did not type in a correct username! Please try again... <br>\n"; echo "Click on the link below to return back to the login form and enter your correct user name and password. <br>\n";
echo"'<a href="UserDetails.html">Return To Login Form</a>'";
}
?>

Code Error:

Code Starts Here:

Parse error: parse error in c:\program files\easyphp1-8\www\userdetails.php on line 4

I am Using Easy Php 1-8, and using http://localhost in the browser, and sending my files to the www folder of easy php.
Have A Great Day.
Marvin.

--- End Message ---
--- Begin Message ---
Sure we can...  Go back and read your manual.  Then surf Google.

Then tell us where you are getting the certificate from since some of us
might be wasting our time taking a class some place that teaches you so
poorly.

Wolf

--- End Message ---
--- Begin Message ---
marvin hunkin wrote:
Hi.
doing an assignment, for my Certificate Four In Website Administration.

Wow someone doing an assignment has written some code :) Good stuff!

$_POST['username'];
$_POST['password'];
if ('username'='username') & ('password'='password')

This little bit of code is your problem.

Firstly you want to assign the username and password to some variables:

$posted_username = $_POST['username'];
$posted_password = $_POST['password'];

http://www.php.net/manual/en/language.variables.php#language.variables.basics

Then you want to check them:

if ($posted_username == 'username' && $posted_password == 'password')
{
....

in php, one = means "assignment"

http://www.php.net/manual/en/language.operators.assignment.php

to check a variable, use two - "==".

http://www.php.net/manual/en/language.operators.comparison.php


Lastly for some extra credit, you should read http://phpsec.org/projects/.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Wolf wrote:
Sure we can...  Go back and read your manual.  Then surf Google.

Then tell us where you are getting the certificate from since some of us
might be wasting our time taking a class some place that teaches you so
poorly.

At least there were attempts at code which makes a nice change.. ;)

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
marvin hunkin wrote:
Hi.
doing an assignment, for my Certificate Four In Website Administration.

The tutor list is down the hall.

now got a couple of problems.
will explain what i have to do.
create a html form, which i have done.
in textpad.
now, when i open the form, it does not set focus to the first form field which is the user name.
goes to the login button.
why is this?
can any one help me?

Yes.  Buy a book on Javascript.

okay, will explain.
and to create a script for a login page, on a network.
and using php, and now got the user to enter their username and password, and then to display a message, saying the person logged in, and to display the date. if the user, types in the wrong user name and password, then a error message is displayed, and a link back to the form, is displayed. now got the problem of a error, when checking to see if the error happened or not, and whether to let them in or not.
so will paste the html form, and the php code below.
if any one can help me how to fix these problems, then let me know asap.
cheers Marvin.


Html Form:


Code Starts Here:

<html>
<head>
<script language=text/javascript>
function SetFocus
{
document.forms[0].username.focus();
}
</script>
<title>User Login Form</title>
</head>
<body onload="SetFocus();">
<form action="UserDetails.php" method="post">
<p>User Name: <input type="text" name="username"> </p> <br>
<p>Password: <input type="password" name="password"> </p> <br>
<p><input type="submit" value="Login"> </p>
</form>
</body>
</html>


Php Code:


Code Starts Here:

    <?php
$_POST['username'];
$_POST['password'];
if ('username'='username') & ('password'='password')
{
echo "Letting you login into the tafe network. <br>\n";
echo "Marvin Hunkin has successfully logged into the Tafe network. <br>\n";
echo "Please Wait ... Loading Your Personal Settings ... <br>\n";
gmdate('d-m-Y', time()+(10*60*60));
}
else
{
echo "Not letting you login into the tafe network. <br>\n";
echo "Error! You did not type in a correct username! Please try again... <br>\n"; echo "Click on the link below to return back to the login form and enter your correct user name and password. <br>\n";
echo"'<a href="UserDetails.html">Return To Login Form</a>'";
}
?>

Code Error:

Code Starts Here:

Parse error: parse error in c:\program files\easyphp1-8\www\userdetails.php on line 4

I am Using Easy Php 1-8, and using http://localhost in the browser, and sending my files to the www folder of easy php.
Have A Great Day.
Marvin.


Instead of cutting and pasting, RTFM and understand what your code is (not) doing.

If this is level four, Most of us here would be a Grand Poobah.

--
By-Tor.com
...it's all about the Rush
http://www.by-tor.com

--- End Message ---
--- Begin Message ---
At 07:38 PM 5/21/2006, marvin hunkin wrote:
now, when i open the form, it does not set focus to the first form field which is the user name.
goes to the login button.
why is this?


Marvin,

Although someone else has suggested you use JavaScript to set the focus on a particular form field, I urge you instead to use HTML tabindex property:

<p>User Name: <input tabindex="1" type="text" name="username"> </p> <br>
<p>Password: <input tabindex="2" type="password" name="password"> </p> <br>
<p><input tabindex="3" type="submit" value="Login"> </p>

HTML 4.01 Specification
17 Forms
17.11 Giving focus to an element
17.11.1 Tabbing navigation
http://www.w3.org/TR/html4/interact/forms.html#h-17.11.1

Simplistic JavaScript solutions place focus on an input field after the page has completely loaded, often after the user has begun interacting with the form, causing irritating focus jumps in mid-input.

Regards,
Paul
--- End Message ---
--- Begin Message ---
FreeBSD-4.11

After rebuilding php4-4.4.2_2 with Apache Module and apache-2.2.2 I no longer
and finding that /usr/local/libexec/apache22/libphp4.so is getting installed.

Any clues as to what I am doing wrong?  I cant figure it out at the moment.  


--- snip ---

# /usr/local/etc/rc.d/apache22.sh restart
Performing sanity check on apache22 configuration:
httpd: Syntax error on line 101 of /usr/local/etc/apache22/httpd.conf: Cannot
load /usr/local/libexec/apache22/libphp4.so into server: Cannot open
"/usr/local/libexec/apache22/libphp4.so"

# grep php4 /usr/local/etc/apache/httpd.conf
LoadModule php4_module        libexec/apache22/libphp4.so

# pkg_info | grep apache
apache-2.2.2        Version 2.2 of Apache web server with prefork MPM.

# pkg_info | grep php
php4-4.4.2_2        PHP Scripting Language (Apache Module and CLI)
php4-bz2-4.4.2_2    The bz2 shared extension for php
php4-ctype-4.4.2_2  The ctype shared extension for php
php4-domxml-4.4.2_2 The domxml shared extension for php
php4-ftp-4.4.2_2    The ftp shared extension for php
php4-gd-4.4.2_2     The gd shared extension for php
php4-gettext-4.4.2_2 The gettext shared extension for php
php4-iconv-4.4.2_2  The iconv shared extension for php
php4-imap-4.4.2_2   The imap shared extension for php
php4-ldap-4.4.2_2   The ldap shared extension for php
php4-mbstring-4.4.2_2 The mbstring shared extension for php
php4-mcal-4.4.2_2   The mcal shared extension for php
php4-mcrypt-4.4.2_2 The mcrypt shared extension for php
php4-mysql-4.4.2_2  The mysql shared extension for php
php4-openssl-4.4.2_2 The openssl shared extension for php
php4-pcre-4.4.2_2   The pcre shared extension for php
php4-session-4.4.2_2 The session shared extension for php
php4-xml-4.4.2_2    The xml shared extension for php
php4-xmlrpc-4.4.2_1 The xmlrpc shared extension for php
php4-zlib-4.4.2_2   The zlib shared extension for php


# ls /usr/local/libexec/apache22
httpd.exp               mod_cache.so            mod_log_config.so
mod_actions.so          mod_cern_meta.so        mod_logio.so
mod_alias.so            mod_cgi.so              mod_mime.so
mod_asis.so             mod_charset_lite.so     mod_mime_magic.so
mod_auth_basic.so       mod_dav.so              mod_negotiation.so
mod_auth_digest.so      mod_dav_fs.so           mod_rewrite.so
mod_authn_anon.so       mod_deflate.so          mod_setenvif.so
mod_authn_dbm.so        mod_dir.so              mod_speling.so
mod_authn_default.so    mod_disk_cache.so       mod_ssl.so
mod_authn_file.so       mod_env.so              mod_status.so
mod_authz_dbm.so        mod_expires.so          mod_unique_id.so
mod_authz_default.so    mod_file_cache.so       mod_userdir.so
mod_authz_groupfile.so  mod_filter.so           mod_usertrack.so
mod_authz_host.so       mod_headers.so          mod_version.so
mod_authz_owner.so      mod_imagemap.so         mod_vhost_alias.so
mod_authz_user.so       mod_include.so
mod_autoindex.so        mod_info.so

--- End Message ---
--- Begin Message ---
FreeBSD-4.11

After rebuilding php4-4.4.2_2 with Apache Module and apache-2.2.2 from
/usr/ports - I no longer am finding that
/usr/local/libexec/apache22/libphp4.so is getting installed.

Any clues as to what I am doing wrong?  I cant figure it out at the moment.  


--- snip ---

# /usr/local/etc/rc.d/apache22.sh restart
Performing sanity check on apache22 configuration:
httpd: Syntax error on line 101 of /usr/local/etc/apache22/httpd.conf: Cannot
load /usr/local/libexec/apache22/libphp4.so into server: Cannot open
"/usr/local/libexec/apache22/libphp4.so"

# grep php4 /usr/local/etc/apache/httpd.conf
LoadModule php4_module        libexec/apache22/libphp4.so

# pkg_info | grep apache
apache-2.2.2        Version 2.2 of Apache web server with prefork MPM.

# pkg_info | grep php
php4-4.4.2_2        PHP Scripting Language (Apache Module and CLI)
php4-bz2-4.4.2_2    The bz2 shared extension for php
php4-ctype-4.4.2_2  The ctype shared extension for php
php4-domxml-4.4.2_2 The domxml shared extension for php
php4-ftp-4.4.2_2    The ftp shared extension for php
php4-gd-4.4.2_2     The gd shared extension for php
php4-gettext-4.4.2_2 The gettext shared extension for php
php4-iconv-4.4.2_2  The iconv shared extension for php
php4-imap-4.4.2_2   The imap shared extension for php
php4-ldap-4.4.2_2   The ldap shared extension for php
php4-mbstring-4.4.2_2 The mbstring shared extension for php
php4-mcal-4.4.2_2   The mcal shared extension for php
php4-mcrypt-4.4.2_2 The mcrypt shared extension for php
php4-mysql-4.4.2_2  The mysql shared extension for php
php4-openssl-4.4.2_2 The openssl shared extension for php
php4-pcre-4.4.2_2   The pcre shared extension for php
php4-session-4.4.2_2 The session shared extension for php
php4-xml-4.4.2_2    The xml shared extension for php
php4-xmlrpc-4.4.2_1 The xmlrpc shared extension for php
php4-zlib-4.4.2_2   The zlib shared extension for php


# ls /usr/local/libexec/apache22
httpd.exp               mod_cache.so            mod_log_config.so
mod_actions.so          mod_cern_meta.so        mod_logio.so
mod_alias.so            mod_cgi.so              mod_mime.so
mod_asis.so             mod_charset_lite.so     mod_mime_magic.so
mod_auth_basic.so       mod_dav.so              mod_negotiation.so
mod_auth_digest.so      mod_dav_fs.so           mod_rewrite.so
mod_authn_anon.so       mod_deflate.so          mod_setenvif.so
mod_authn_dbm.so        mod_dir.so              mod_speling.so
mod_authn_default.so    mod_disk_cache.so       mod_ssl.so
mod_authn_file.so       mod_env.so              mod_status.so
mod_authz_dbm.so        mod_expires.so          mod_unique_id.so
mod_authz_default.so    mod_file_cache.so       mod_userdir.so
mod_authz_groupfile.so  mod_filter.so           mod_usertrack.so
mod_authz_host.so       mod_headers.so          mod_version.so
mod_authz_owner.so      mod_imagemap.so         mod_vhost_alias.so
mod_authz_user.so       mod_include.so
mod_autoindex.so        mod_info.so

--- End Message ---
--- Begin Message ---
Noah wrote:
FreeBSD-4.11

After rebuilding php4-4.4.2_2 with Apache Module and apache-2.2.2 from
/usr/ports - I no longer am finding that
/usr/local/libexec/apache22/libphp4.so is getting installed.

Any clues as to what I am doing wrong? I cant figure it out at the moment.

The error makes perfect sense - there is no file.

Apache2 has no idea what php is, so you need to re-compile php4 against the new apache2.

You can't just copy the existing one because things would be quite different internally between apache1 and apache2.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
On Mon, 22 May 2006 14:24:33 +1000, Chris wrote
> Noah wrote:
> > FreeBSD-4.11
> > 
> > After rebuilding php4-4.4.2_2 with Apache Module and apache-2.2.2 from
> > /usr/ports - I no longer am finding that
> > /usr/local/libexec/apache22/libphp4.so is getting installed.
> > 
> > Any clues as to what I am doing wrong?  I cant figure it out at the moment.
> 
> The error makes perfect sense - there is no file.
> 
> Apache2 has no idea what php is, so you need to re-compile php4 
> against the new apache2.


Hi there,

Okay I am not really understanding you here.  what are you suggesting I do
here?  I did the following

1) uninstalled php4 and apache2
2) rebuilt and installed apache2 fresh from /usr/ports
3) then rebuilt and installed php4 fresh from /usr/ports with apache module
created.
4) still the same error:  # /usr/local/etc/rc.d/apache22.sh restart
Performing sanity check on apache22 configuration:
httpd: Syntax error on line 101 of /usr/local/etc/apache22/httpd.conf: Cannot
load /usr/local/libexec/apache22/libphp4.so into server: Cannot open
"/usr/local/libexec/apache22/libphp4.so"
5) Also php4 and apache2.2 was working something just broke since the last usr
ports upgrade.

I need steps for what exactly to do next because I dont know what else to try.

cheers,

Noah
 


> 
> You can't just copy the existing one because things would be quite 
> different internally between apache1 and apache2.
> 
> -- 
> Postgresql & php tutorials
> http://www.designmagick.com/
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Noah wrote:
On Mon, 22 May 2006 14:24:33 +1000, Chris wrote

Noah wrote:

FreeBSD-4.11

After rebuilding php4-4.4.2_2 with Apache Module and apache-2.2.2 from
/usr/ports - I no longer am finding that
/usr/local/libexec/apache22/libphp4.so is getting installed.

Any clues as to what I am doing wrong?  I cant figure it out at the moment.

The error makes perfect sense - there is no file.

Apache2 has no idea what php is, so you need to re-compile php4 against the new apache2.



Hi there,

Okay I am not really understanding you here.  what are you suggesting I do
here?  I did the following

1) uninstalled php4 and apache2
2) rebuilt and installed apache2 fresh from /usr/ports
3) then rebuilt and installed php4 fresh from /usr/ports with apache module
created.

apache or apache2 ?

They are different modules and you need to explicitly say apache2.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Hi.
would like to give a big thanks for helping me with my php problems.
have resolved them, and just tested it, and works fine.
thanks for chris, john and paul with their help.
now have just uploaded my assignment.
and now it works fine, when i tested it.
typing in the correct username and password, and getting the message, i have logged in..., and reran the form, if it is not the correct username and password, a error message, a link back to the form, which it goes back there, setting focus on the first edit field.
thanks for all your great help.
cheers Marvin.

--- End Message ---
--- Begin Message ---
PHP General,

What I am trying to achieve is to output the path in which the current script is executing, without having the name of the file attached. I'm hoping to be able to do this without complicated code to truncate path names and whatnot.

Either of these two variables do what I want, except that they include the name of the file:

$_SERVER[PHP_SELF]
$_SERVER[SCRIPT_NAME]

For example, if create file called "test.php" and I echo the output of $_SERVER[PHP_SELF], I get:
/web_sites/gutteridge.info/web/test.php

But all I want is:
/web_sites/gutteridge.info/web

(It's important that the last forward slash not be there).

I would have thought that an existing global variable would exist to do this, but I can't find it in the php manual:
http://www.php.net/manual/en/reserved.variables.php

$_SERVER[DOCUMENT_ROOT] provides a path without the file name, but it's not the path I need. In my case, the output is:
/var/www

$_SERVER[PATH_TRANSLATED] also provides a different path, and also attaches the file name:
/var/www/web_sites/gutteridge.info/web/test.php

The bottom line is, how can I get the same path as $_SERVER[PHP_SELF] or $_SERVER[SCRIPT_NAME], but without including the file name?

Thank you for any advice.

--
Dave M G

--- End Message ---
--- Begin Message ---
Dave M G wrote:
PHP General,

What I am trying to achieve is to output the path in which the current script is executing, without having the name of the file attached. I'm hoping to be able to do this without complicated code to truncate path names and whatnot.

Either of these two variables do what I want, except that they include the name of the file:

$_SERVER[PHP_SELF]
$_SERVER[SCRIPT_NAME]

For example, if create file called "test.php" and I echo the output of $_SERVER[PHP_SELF], I get:
/web_sites/gutteridge.info/web/test.php

But all I want is:
/web_sites/gutteridge.info/web

(It's important that the last forward slash not be there).

I would have thought that an existing global variable would exist to do this, but I can't find it in the php manual:
http://www.php.net/manual/en/reserved.variables.php

$_SERVER[DOCUMENT_ROOT] provides a path without the file name, but it's not the path I need. In my case, the output is:
/var/www

$_SERVER[PATH_TRANSLATED] also provides a different path, and also attaches the file name:
/var/www/web_sites/gutteridge.info/web/test.php

The bottom line is, how can I get the same path as $_SERVER[PHP_SELF] or $_SERVER[SCRIPT_NAME], but without including the file name?

use dirname().

http://www.php.net/dirname

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Hello!

I packed PHP 4.4.3RC1 today, which you can find here:
http://downloads.php.net/derick/
Windows downloads can be found here:

Please test it carefully, and report any bugs in the bug system, but 
only if you have a short reproducable test case.

If everything goes well, we can release 4.4.3 somewhere in the middle 
of next week (around the 30th). If there are critical bugs found we will 
instead then release RC2.

regards,
Derick

-- 
Derick Rethans
http://derickrethans.nl | http://ez.no | http://xdebug.org

--- End Message ---
--- Begin Message ---
Not so sure if I've tried to work this out before in this list.
I'm trying to make an array name by a field/row value and assigning values
to it. But I'm having some problems getting it to work.
Is it possible to do this? And if, what am I doing wrong? Or is there any
other way to do it?

while($row=mysql_fetch_array($result)) {

        // Checking if variable/array is not declared
        if (!$$row[0]) {

                // Declaring an empty array by the value of sales person code
                $$row[0] = array();

                // Current sales person code
                $code = $row[0];

                // Putting the product name as a key and the price as a value 
in the array
                eval("\$code[\$row[1]] = \"$row[2]\";");

        }

}

Thanks

--- End Message ---
--- Begin Message ---
Jonas Rosling a écrit :
Not so sure if I've tried to work this out before in this list.
I'm trying to make an array name by a field/row value and assigning values
to it. But I'm having some problems getting it to work.
Is it possible to do this? And if, what am I doing wrong? Or is there any
other way to do it?

while($row=mysql_fetch_array($result)) {

        // Checking if variable/array is not declared
        if (!$$row[0]) {

what do you want to check with the code above ?
I don't think $$row[0]  will give you anything good.
as you're inside your while loop, $row should be declared,
but the content of $row[0] depends on your request.

you can check if $row[0] is set using "count $row";
but if you have an empty value in the first column, this will give you an empty string as result.

try a print_r($row);  after your "while".
                // Declaring an empty array by the value of sales person code
                $$row[0] = array();

I still don't understand why you're using $$row above.
                // Current sales person code
                $code = $row[0];

                // Putting the product name as a key and the price as a value 
in the array
                eval("\$code[\$row[1]] = \"$row[2]\";");
do you really want to erase the content of $code you just set above with the eval statement ?
                               $my_array = array();
$my_array[$1] = $2;
        }

}

Thanks

Could you please describe a bit more what you'd like to do/set, so we can give you a better help ?

N F

--- End Message ---
--- Begin Message ---
-----Ursprungligt meddelande-----
Från: nicolas figaro [mailto:[EMAIL PROTECTED]
Skickat: den 22 maj 2006 11:50
Till: PHP List
Ämne: Re: [PHP] Array name out of field value with data


Jonas Rosling a écrit :
> Not so sure if I've tried to work this out before in this list.
> I'm trying to make an array name by a field/row value and assigning values
> to it. But I'm having some problems getting it to work.
> Is it possible to do this? And if, what am I doing wrong? Or is there any
> other way to do it?
>
> while($row=mysql_fetch_array($result)) {
>
>       // Checking if variable/array is not declared
>       if (!$$row[0]) {
>
>
what do you want to check with the code above ?
I don't think $$row[0]  will give you anything good.
as you're inside your while loop, $row should be declared,
but the content of $row[0] depends on your request.

you can check if $row[0] is set using "count $row";
but if you have an empty value in the first column, this will give you
an empty string as result.

try a print_r($row);  after your "while".
>               // Declaring an empty array by the value of sales person code
>               $$row[0] = array();
>
>
I still don't understand why you're using $$row above.
>               // Current sales person code
>               $code = $row[0];
>
>               // Putting the product name as a key and the price as a value 
> in the
array
>               eval("\$code[\$row[1]] = \"$row[2]\";");
>
do you really want to erase the content of $code you just set above with
the eval statement ?
                                $my_array = array();
                                $my_array[$1] = $2;
>       }
>
> }
>
> Thanks
>
>
Could you please describe a bit more what you'd like to do/set, so we
can give you a better help ?

 N F

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


The thing is that I want to name an array by the value in $row[0], sales
person code. Once the array is declared it should not be declared again. The
field never contains an empty value.
After that I want to push in $row[1] as a key with $row[2] as a value, all
related to the array name/sales person code. So if an array is declared that
is equal as the value in the first field it should input a key and value.
For example the array "AT" can contain 10 "collections" of data.

Array ( [Product 1] => 1500 [Product 2] => 3000 [Product 3] => 500 ) etc,

Hope I have made it a bit more easier to understand now.

// Jonas

--- End Message ---
--- Begin Message ---
Dear all,
 I am using getRow() method ob DB_Common class to get a single row from a 
table. As per document 
http://pear.php.net/manual/en/package.database.db.db-common.getrow.php this 
method return a single dimension array. But when I am using it, it returns a 
two dimension array. I don't know why...!!!! Please help me.
 
 -- Nirmalya
 
                
---------------------------------
How low will we go? Check out Yahoo! Messenger’s low  PC-to-Phone call rates.

--- End Message ---
--- Begin Message ---
On 5/22/06, Nirmalya Lahiri <[EMAIL PROTECTED]> wrote:
Dear all,
 I am using getRow() method ob DB_Common class to get a single row from a 
table. As per document 
http://pear.php.net/manual/en/package.database.db.db-common.getrow.php this 
method return a single dimension array. But when I am using it, it returns a 
two dimension array. I don't know why...!!!! Please help me.

You should ask on the pear list - they know the code, we don't.

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message --- I have a site that is using a shared ssl certificate. When running on the site, the host is of the form <host.com>. When running in ssl mode, the domain is of the form <host>.<certhost>.com. ping shows that both resolve to the same ip address.

Is there a way to create a cookie in the unsecured area and have it available when going through the ssl certificate?

tia
---Michael
--
Fight software piracy!
Don't pirate MS Office - that's theft.
Instead, use ours - it's legal and free
     www.openoffice.org

--- End Message ---
--- Begin Message ---
Michael Satterwhite wrote:

I have a site that is using a shared ssl certificate. When running on the site, the host is of the form <host.com>. When running in ssl mode, the domain is of the form <host>.<certhost>.com. ping shows that both resolve to the same ip address.

Is there a way to create a cookie in the unsecured area and have it available when going through the ssl certificate?


Short answer: No

Long answer: Noooooooooooooooooooooooooooo

Seriously though, for security reasons you cannot set cookies from one domain for another domain. You'll need to come up with another way to pass a secure token or just leave them on the secure site.

-Stut

--- End Message ---
--- Begin Message ---
On 5/22/06, Michael Satterwhite <[EMAIL PROTECTED]> wrote:
I have a site that is using a shared ssl certificate. When running on
the site, the host is of the form <host.com>. When running in ssl mode,
the domain is of the form <host>.<certhost>.com. ping shows that both
resolve to the same ip address.

Is there a way to create a cookie in the unsecured area and have it
available when going through the ssl certificate?

Nope. They are different domains.

If they were on the same basic domain, you could (see
http://wp.netscape.com/newsref/std/cookie_spec.html specifically the
"domain" section) but completely different domains isn't an option.

PHP sessions would work though. Explicitly pass the session across and
it should work (well, I think!).

--
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
Anyone know any good why to group date in a recordset in any good way? As if
you categorize it in columns. Like:

Category 1
        Row1 -> Data    Data
        Row2 -> Data    Data
        Row3 -> Data    Data

Category 2
        Row1 -> Data    Date
        Row2 -> Data    Data
        Row3 -> Data    Data

etc.

Thanks in advance (as allways)

--- End Message ---
--- Begin Message ---
On 22/05/06, Jonas Rosling <[EMAIL PROTECTED]> wrote:

Anyone know any good why to group date in a recordset in any good way? As
if
you categorize it in columns. Like:

Category 1
        Row1 -> Data    Data
        Row2 -> Data    Data
        Row3 -> Data    Data

Category 2
        Row1 -> Data    Date
        Row2 -> Data    Data
        Row3 -> Data    Data

etc.

Thanks in advance (as allways)

What do you mean? Is this html tables, or php arrays, or what? Please be
more specific!




--
http://www.web-buddha.co.uk

dynamic web programming from Reigate, Surrey UK (php, mysql, xhtml, css)

look out for project karma, our new venture, coming soon!

--- End Message ---
--- Begin Message ---
Hi,
I've pretty much given up trying to convert a perl
script to php, I have come a long way with it though,
but there are a few bugs that i have been unable to
squash. I need an _exact_ copy of the perl script in
php, unable to manage that.

If you are good with PERL and PHP and would like to
give me a helping hand converting this, please tell me
and I will send you two files
The original perl version and my tried_to_convert php
version.

Both files are not very big (around 13k on average)

***I understand your time is valuable so if you want
either give me your paypal address or the address of
your favourite charity and I'll make a payment
there.***

Please note I am NOT a rich guy...unfortunatly :)

Interested? Write back with your address and I'll send
the files over.

Cheers,
Ryan

------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--- End Message ---
--- Begin Message ---
flock() with LOCK_NB not work under ,
nor does fopen() with 'x' mode,
my php is compiled as an apache module, and apache is running in prefork mpm.
php version is 5.1.2

my code is

<?php
$haslock=0;
if($lock=fopen('LOCK','w')){
  if(flock($lock,LOCK_EX|LOCK_NB))$has_lock=1;
}

if($has_lock){
 //do something which should always be only one process
}
?>

or

<?php
$has_lock=0;
$lock=fopen('LOCK','x');
if($lock)$has_lock=1;
if(has_lock){
 // do something
}

both of them wont work.
however cli mode works well.

any clue?

TIA.

--- End Message ---
--- Begin Message ---
BTW.
what i want is
if one http session cannot obtain the lock,
then it fails IMMEDIATELY,

On 5/22/06, n. g. <[EMAIL PROTECTED]> wrote:
flock() with LOCK_NB not work under ,
nor does fopen() with 'x' mode,
my php is compiled as an apache module, and apache is running in prefork
mpm.
php version is 5.1.2

my code is

<?php
$haslock=0;
if($lock=fopen('LOCK','w')){
   if(flock($lock,LOCK_EX|LOCK_NB))$has_lock=1;
}

if($has_lock){
  //do something which should always be only one process
}
?>

or

<?php
$has_lock=0;
$lock=fopen('LOCK','x');
if($lock)$has_lock=1;
if(has_lock){
  // do something
}

both of them wont work.
however cli mode works well.

any clue?

TIA.



--
Tomorrow will be a good day :-)

--- End Message ---
--- Begin Message ---
The easiest way I found to do this is using mktime().
If you don't care about the time for the date you can use this...

$yesterday = mktime(0,0,0,date("m"),date("d")-1,date("Y"));

This translates to yesterday morning after midnight.

If you want the present time, only 24 hours before, use this...

$yesterday =
mktime(date("H"),date("i"),date("s"),date("m"),date("d")-1,date("Y"));

To display the date use...

date( "m/d/Y", $yesterday );

Or you can put the mktime code in play of $yesterday in the above line
of
code.

Good luck,



Jef

-----Original Message-----
From: Scott Hurring [mailto:[EMAIL PROTECTED] 
Sent: Sunday, May 21, 2006 12:18 PM
To: Rabin Vincent; [email protected]
Subject: Re: [PHP] Date() finding yesterday

mktime also works: http://php.net/mktime:

date("Y-m-d", mktime( ... ))

On 5/21/06, Rabin Vincent <[EMAIL PROTECTED]> wrote:
>
> On 5/21/06, John Taylor-Johnston
> <[EMAIL PROTECTED]> wrote:
> > I cannot seem to get this right. How can I produce yesterday?
> >
> > $today = date("Y-m-d");
> > $yesterday = date("Y-m-") . date("d")-1;
> > $yesterday = date("Y-m-d")-1;
> > $yesterday = date("Y-m-"."d"-1);
> >
> > I've been looking at the manual :) ...
>
> Use php.net/strtotime:
>
> $yesterday = date('Y-m-d', strtotime('-1 day'));
>
> Rabin
>
> --
> http://rab.in
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Scott Hurring [scott dot hurring dot lists at gmail dot com]
http://hurring.com/

--- End Message ---

Reply via email to