php-general Digest 23 Jun 2004 04:17:03 -0000 Issue 2837

Topics (messages 188814 through 188841):

Re: error with PHP MySQL extension
        188814 by: John Nichel
        188815 by: Nguyen, Long P (Mission Systems)
        188816 by: R'twick Niceorgaw
        188818 by: Nguyen, Long P (Mission Systems)
        188820 by: John Nichel

Pear Image_Graph
        188817 by: Meredith-Wilks, Richard

.NFO files and .PNG images
        188819 by: r4BBiT

Re: I don't want to use include
        188821 by: Amit Arora

Re: Encryption Question SOLVED
        188822 by: Jay Blanchard

Re: MySql Close problem
        188823 by: Erik Gjertsen

Re: Firebird "reading data" error...
        188824 by: Marek Kilimajer

Compiling with pfpro (Payflow) with new SDK for Linux
        188825 by: Christopher Jones

Re: Encryption Question
        188826 by: Justin Patrin
        188827 by: Jay Blanchard
        188828 by: Justin Patrin
        188836 by: Kim Steinhaug

Help with eregi
        188829 by: Ryan Schefke
        188830 by: Robin Vickery
        188832 by: Tom Z. Meinlschmidt
        188833 by: Matt Matijevich
        188840 by: Curt Zirzow

Re: Help with PHP4.3.2 and XML
        188831 by: Eric L. Sammons

Image Uploader
        188834 by: Sean Vasey
        188835 by: Matt Matijevich
        188838 by: Marek Kilimajer

Re: is there any application ,      by using i can produce php exe files in windows ?
        188837 by: Kim Steinhaug

Re: Session problem
        188839 by: Curt Zirzow

Re: opening Adobe pdf's
        188841 by: Scott Taylor

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 --- Nguyen, Long P (Mission Systems) wrote:
This is where I am stuck at with this DRES installation, it's complaining about the 
mysql extension.  I tried ./configure --with-mysql=/usr/local/mysql; make; make 
install and still the same error:

--------------------------------------------------------------------------------
Checking PHP configuration settings

PHP version... success [4.2.2]
DOMXML extension... success [2.4.23]
MySQL extension failure [required-extension not installed]


recompile your PHP installation with --with-mysql option --------------------------------------------------------------------------------


You need to find out how php was originally installed on your system, and how your web server (Apache?) was installed. Depending on how your web server was installed, you will need to (re)install php in one of a few ways. So, how was your web server installed? RPM? Source? How was it configured? Does it support apxs?


--
John C. Nichel
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
I was task with this...  Unfortunately the person that installed it is not here 
anymore.  Is there a way to find out, like any commands or files to look for?  I do 
see _SERVER["SERVER_SOFTWARE"] Apache/2.0.40 (Red Hat Linux) show up on the test.php

Thanks for your help.



-----Original Message-----
From: John Nichel [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 22, 2004 10:33 AM
To: php-general Mailing List
Subject: Re: [PHP] error with PHP MySQL extension


Nguyen, Long P (Mission Systems) wrote:
> This is where I am stuck at with this DRES installation, it's complaining about the 
> mysql extension.  I tried ./configure --with-mysql=/usr/local/mysql; make; make 
> install and still the same error:
> 
> --------------------------------------------------------------------------------
> Checking PHP configuration settings
> 
> PHP version... success [4.2.2]
> DOMXML extension... success [2.4.23]
> MySQL extension failure [required-extension not installed] 
> 
> recompile your PHP installation with --with-mysql option 
> --------------------------------------------------------------------------------
> 

You need to find out how php was originally installed on your system, 
and how your web server (Apache?) was installed.  Depending on how your 
web server was installed, you will need to (re)install php in one of a 
few ways.  So, how was your web server installed?  RPM?  Source?  How 
was it configured?  Does it support apxs?

-- 
John C. Nichel
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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

--- End Message ---
--- Begin Message ---
Quoting "Nguyen, Long P (Mission Systems)" <[EMAIL PROTECTED]>:

> I was task with this...  Unfortunately the person that installed it is not
> here anymore.  Is there a way to find out, like any commands or files to look
> for?  I do see _SERVER["SERVER_SOFTWARE"] Apache/2.0.40 (Red Hat Linux) show
> up on the test.php
> 
> Thanks for your help.

What does phpinfo() say? It should tell you how it's configured (look for
configure section at the top). Also it should tell you wheather mysql extension
is installed or not.

If its a redhat linux machine, then most probably its installed with an rpm and
so "up2date php-mysql"  should install mysql extension. You need to restart
apache after this.

HTH
R'twick

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

--- End Message ---
--- Begin Message ---
I didn't see a phpinfo, I do see mysql as below in the Configure Command section.  So 
if I run "up2date php-mysql", it will update mysql extension?  Where do I run this 
from, like the path?  Sorry - I'm new to this.

System: Linux daffy.perf.redhat.com 2.4.18-11smp #1 SMP Thu Aug 15 06:41:59 EDT 2002 
i686 i686 i386 GNU/Linux 
Build Date: Sep 3 2002 05:25:09 
Configure Command: './configure' '--host=i686-pc-linux-gnu' 
'--build=i686-pc-linux-gnu' '--target=i386-redhat-linux-gnu' '--program-prefix=' 
'--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' 
'--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' 
'--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' 
'--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' 
'--prefix=/usr' '--with-config-file-path=/etc' '--enable-force-cgi-redirect' 
'--disable-debug' '--enable-pic' '--disable-rpath' '--enable-inline-optimization' 
'--with-bz2' '--with-db3' '--with-curl' '--with-dom=/usr' '--with-exec-dir=/usr/bin' 
'--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-gd' '--enable-gd-native-ttf' 
'--with-ttf' '--with-gdbm' '--with-gettext' '--with-ncurses' '--with-gmp' 
'--with-iconv' '--with-jpeg-dir=/usr'
'--with-openssl' '--with-png' '--with-pspell' '--with-regex=system' '--with-xml' 
'--with-expat-dir=/usr' '--with-zlib' '--with-layout=GNU' '--enable-bcmath' 
'--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode' 
'--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-discard-path' 
'--enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' 
'--without-oci8' '--with-pear=/usr/share/pear' '--with-imap=shared' '--with-imap-ssl' 
'--with-kerberos=/usr/kerberos' '--with-ldap=shared' '--with-mysql=shared,/usr' 
'--with-pgsql=shared' '--with-snmp=shared,/usr' '--with-snmp=shared' 
'--enable-ucd-snmp-hack' '--with-unixODBC=shared' '--enable-memory-limit' 
'--enable-bcmath' '--enable-shmop' '--enable-versioning' '--enable-calendar' 
'--enable-dbx' '--enable-dio' '--enable-mcal' '--with-apxs2=/usr/sbin/apxs' 


-----Original Message-----
From: R'twick Niceorgaw [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 22, 2004 10:04 AM
To: Nguyen, Long P (Mission Systems)
Cc: John Nichel; php-general Mailing List
Subject: RE: [PHP] error with PHP MySQL extension


Quoting "Nguyen, Long P (Mission Systems)" <[EMAIL PROTECTED]>:

> I was task with this...  Unfortunately the person that installed it is not
> here anymore.  Is there a way to find out, like any commands or files to look
> for?  I do see _SERVER["SERVER_SOFTWARE"] Apache/2.0.40 (Red Hat Linux) show
> up on the test.php
> 
> Thanks for your help.

What does phpinfo() say? It should tell you how it's configured (look for
configure section at the top). Also it should tell you wheather mysql extension
is installed or not.

If its a redhat linux machine, then most probably its installed with an rpm and
so "up2date php-mysql"  should install mysql extension. You need to restart
apache after this.

HTH
R'twick

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

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

--- End Message ---
--- Begin Message --- Nguyen, Long P (Mission Systems) wrote:
I didn't see a phpinfo, I do see mysql as below in the Configure Command section. So if I run "up2date php-mysql", it will update mysql extension? Where do I run this from, like the path? Sorry - I'm new to this.

At the command prompt (and as root), run this....

$> rpm -qa | grep httpd

If it responds with something like...

httpd-2.x

Then Apache was installed via RPM

You can then do this at the command prompt....

$> up2date php-mysql

And that will install the RPM for php/mysql. Restart Apache, and all should be fine and dandy.

--
John C. Nichel
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
I have been told of an image class called 'Image_Graph'.

Has anyone used it and/or do you have any example code I can follow.

thanks

Richard

--- End Message ---
--- Begin Message ---
hi,

i'm having troubles converting ascii extended symbols, for exaple one of them looks like that 'Ü' in win, but in unicode, or old ibm dos extended ascii its black box. most of ascii art using this and sign like that. what id like to do is create dynamic .png image with content of some ascii file. so far i have no luck, i spent whole night and i cant find a way to convert those symbols. iny ideas? please help ;)

--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/

--- End Message ---
--- Begin Message ---
You may want to use the exec() function.

Please refer www.php.net/exec for more information

Regards,

Amit
www.digitalamit.com

Qt wrote:

Dear Sirs,

When I use include, my script is waiting included script results. But I just
want to run another local script without wait result.

Which command I should to use?


Best Regards

--- End Message ---
--- Begin Message ---
[snip]
I am encrypting some data on one server and now I am attempting to decrypt on another 
server using mcrypt_encrypt and mycrypt_decrypt (using same key and initialzation 
vector). It is almost working but I seem to still have a little problem, that data is 
missing the last character which still seems to be encrypted. I am putting the data in 
the database with addslashes, and retrieving with stripslashes, but I get things like 
this;

45221141¤Þ,]¹9Ñ
77777775ÿåZ|z

while($arrEncInfo = mysql_fetch_array($dbGetSub)){
        $stripDataA = stripslashes($arrEncInfo['dataA']);
        $stripIV = stripslashes($arrEncInfo['iv']);
        $dataA = mcrypt_decrypt($encAlg, $encKey, $stripDataA, $encMode, $stripIV);
        echo $dataA . "\n";
}       

Has anyone seen this? Could there be a difference between the PHP installs? Both are 
version 4.3.7.
[/snip]

I found the problem on the field in question. I had left the column in the database 
the same length as it was prior to encrypting the data. This, as it turns out, is a 
BAD THING [tm]. Make sure that database columns are large enough to hold the whole of 
the encrypted data.

--- End Message ---
--- Begin Message ---
I suppose it was mysql_close that was a problem but I am not secure. I am
new in this.
I have tryed to made registration page. I  wish to that you can use one nic
name ony one time.


I hav use the following code:

<body>
<?php include("header.inc");
if (isset($_POST['submit'])) { // Handle the form
 require_once ("mysql_connect.php");

 // Create a funtion for escaping the data.
 function escape_data ($data) {
  global $dbc; // Ned the conection
  if (ini_get('magic_quotes_gpc')) {
   $data = stripslashes($data);
   }
 return mysql_real_escape_string($data, $dbc);
 } // End of function
 $message = NULL; //Create an empty new variable


 if (empty($_POST['name'])) {
 $name = FALSE;
 $message = '<p> You forgot to enter your name</p>';
 } else {
 $name = escape_data($_POST['name']);

 if (empty($_POST['email'])) {
 $email = FALSE;
 $message = '<p> You forgot to enter your email</p>';
 } else {
 $email = escape_data($_POST['email']);

 if (empty($_POST['username'])) {
 $username = FALSE;
 $message = '<p> You forgot to enter your username</p>';
 } else {
 $username = escape_data($_POST['username']);

 if (empty($_POST['password1'])) {
 $password1 = FALSE;
 $message = '<p> You forgot to enter your password</p>';
 } else {
  if ($_POST['password1'] == $_POST['password2']) {
  $password1 = escape_data($_POST['password1']);
  } else {
   $password = FALSE;
   $message = '<p> your password did not math</p>';
  }
 }

 if ($name && $email && $username && $password) // If everything's ok.

 $query = "SELECT usrid FROM users WHERE username='$username'";
 $result = @mysql_query ($query); //Run the query
  if (mysql_num_rows($result) == 0) { // Make the query
  $query = "INSERT INTO users (username, name, email, password,
registration_date) VALUES
  ('$username', '$name', '$email', '$password', NOW() )";
  $result = @mysql_query ($query);
   if ($result) { // IF it ran OK

    // Send an email, if desired
    echo '<p><b>You have been registered!</b></P>';
    include("./footer.inc");
    exit();
   } else { // If it did not ron OK.
    $message = '<p>You cout not be registered due to a system error. We
apologize for any inconvenience</p>';
   }
  } else {
  $message = '<p>That username is alredy taken.</p>';
  }


 mysql_close();


 } else {
  $message = '<p>Please try again.</p>';
 }
} // End of the main   submit conditional.

 // Print the error message if ther is one
 if (isset($message)) {
  echo '<font color="red">', $message, '</font>';
 )

 ?>


<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset><legend>Enter your information in the form below:</legend>

<p><b>Name</b> <input type="text" name="name" size="15" maxlength="15"
 value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" /></p>

<p><b>Email Adress</b> <input type="text" name="email" size="40"
maxlength="40"
 value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></p>

<p><b>User Name</b> <input type="text" name="username" size="10"
maxlength="20"
 value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>"
/></p>

 <p><b>Password</b> <input type="password" name="password1" size="20"
maxlength="20" /></p>

 <p><b>Confirm Password</b> <input type="password" name="password2"
size="20" maxlength="20" /></p>

 <div align="center"><input type="submit" name="Submit" value="Register"
/></div>

</fieldset>
</form>
 <?php
 include("./footer.inc");
 ?>

</body>
</html>


but it dont work. If I take away al after mysql close to form_action it com
the folloving error:Parse error: parse error on line 114 (it is on the end
of the script). But when I set it back aganst the error massages coms on the
line of mysql_close. Are ther someone that understand what I means??

Thanks for any proposal
Erik Gjertsen

--- End Message ---
--- Begin Message ---
Connection timeout?

André Cupini wrote --- napísal::
Hi people,
...first, sorry my poor english ;)
I have a system that access firebird database in a remote machine. In development, works fine (with Firebird 1.0). But now, the database location is a real machine where the system are put up (with Firebird 1.5) and when i realize a query, in the functions ibase_fetch_*, i have a strange problem (maybe a bug?). When in return, are more then 2 result of "double precision" type, i get the following errors:
*ibase_fetch_object(): Error reading data from the connection. *(In the ibase_fetch_object line)
** And in the bottom of page (in last line of of code): *Warning: Unknown(): Error reading data from the connection. in Unknown on line 0 *(I n ever see nothing like this... /unknown/??? /line 0/????)
** When i switch the servers, the code works fine again.
Anybody can help-me?
Thanks

--- End Message ---
--- Begin Message ---
Hello,

I think there has to be some compile issues with PHP and the newer Payflow SDKs
from VeriSign [Linux]. There is no longer a Beta SDK apparently for any of the platforms.
I have consistenly received the following error: "the pfpro extension requires
version 2 or 3 of the SDK." I have attempted to find a workaround by altering the
configure script, but have been unable to do so. I think some work on this would
be appropriate as the information on php.net is out of date regarding a Beta SDK.


Any help you could give to me would be much appreciated.

Best regards,
Christopher Jones

--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:

Good morning gurus!

I am encrypting some data on one server and now I am attempting to decrypt on another 
server using mcrypt_encrypt and mycrypt_decrypt (using same key and initialzation 
vector). It is almost working but I seem to still have a little problem, that data is 
missing the last character which still seems to be encrypted. I am putting the data in 
the database with addslashes, and retrieving with stripslashes, but I get things like 
this;

45221141¤Þ,]¹9Ñ
77777775ÿåZ|z

while($arrEncInfo = mysql_fetch_array($dbGetSub)){
        $stripDataA = stripslashes($arrEncInfo['dataA']);
        $stripIV = stripslashes($arrEncInfo['iv']);
        $dataA = mcrypt_decrypt($encAlg, $encKey, $stripDataA, $encMode, $stripIV);
        echo $dataA . "\n";
}       

Has anyone seen this? Could there be a difference between the PHP installs? Both are 
version 4.3.7.

Thanks!

Jay

You should probably use mysql_escape_string or mysql_real_escape_string instead of addslashes and stripslashes. IMHO addslashes and stripslashes are pretty much useless.


--
paperCrane <Justin Patrin>

--- End Message ---
--- Begin Message ---
[snip]
You should probably use mysql_escape_string or mysql_real_escape_string 
instead of addslashes and stripslashes. IMHO addslashes and stripslashes

are pretty much useless.
[/snip]

That is an interesting take, why so?

--- End Message ---
--- Begin Message ---
Jay Blanchard wrote:

[snip]
You should probably use mysql_escape_string or mysql_real_escape_string instead of addslashes and stripslashes. IMHO addslashes and stripslashes


are pretty much useless.
[/snip]

That is an interesting take, why so?

Because it can easily cause more problems than it fixes. Actually, it's also a part of my dislike for the magic_quotes system...


At the very least, mysql_(real_)escape_string should be always used for mysql code instead of addslashes as it *will* do the right thing.

--
paperCrane <Justin Patrin>

--- End Message ---
--- Begin Message ---
Do you really need to use stripslashes when retrieving the data?
Wouldnt stripslashes only affect magic quotes or already added slashes,
I mean when you addslashes to the SQL the slashes are indeed removed
when inserted in the table.

--
--
Kim Steinhaug
----------------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
----------------------------------------------------------------------
www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
----------------------------------------------------------------------

"Justin Patrin" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Jay Blanchard wrote:
>
> > Good morning gurus!
> >
> > I am encrypting some data on one server and now I am attempting to
decrypt on another server using mcrypt_encrypt and mycrypt_decrypt (using
same key and initialzation vector). It is almost working but I seem to still
have a little problem, that data is missing the last character which still
seems to be encrypted. I am putting the data in the database with
addslashes, and retrieving with stripslashes, but I get things like this;
> >
> > 45221141¤Þ,]¹9Ñ
> > 77777775ÿåZ|z
> >
> > while($arrEncInfo = mysql_fetch_array($dbGetSub)){
> > $stripDataA = stripslashes($arrEncInfo['dataA']);
> > $stripIV = stripslashes($arrEncInfo['iv']);
> > $dataA = mcrypt_decrypt($encAlg, $encKey, $stripDataA, $encMode,
$stripIV);
> > echo $dataA . "\n";
> > }
> >
> > Has anyone seen this? Could there be a difference between the PHP
installs? Both are version 4.3.7.
> >
> > Thanks!
> >
> > Jay
>
> You should probably use mysql_escape_string or mysql_real_escape_string
> instead of addslashes and stripslashes. IMHO addslashes and stripslashes
> are pretty much useless.
>
> --
> paperCrane <Justin Patrin>

--- End Message ---
--- Begin Message ---
Could someone please help me with an eregi statement.

 

I have a string that can vary as such:

 

client1/album/album_121-2132_IMG.JPG

client2/album/album_121-2132_IMG.JPG

client59/album/album_121-2132_IMG.JPG

client499887/album/album_121-2132_IMG.JPG

 

I want to select whatever comes after the last forward slash, like
album_121-2132_IMG.JPG

 

Thanks,

Ryan


--- End Message ---
--- Begin Message ---
On Tue, 22 Jun 2004 14:57:28 -0400, Ryan Schefke <[EMAIL PROTECTED]> wrote:
> 
> Could someone please help me with an eregi statement.
> 
> I have a string that can vary as such:
> 
> client1/album/album_121-2132_IMG.JPG
> 
> client2/album/album_121-2132_IMG.JPG
> 
> client59/album/album_121-2132_IMG.JPG
> 
> client499887/album/album_121-2132_IMG.JPG
> 
> I want to select whatever comes after the last forward slash, like
> album_121-2132_IMG.JPG

preg_match('#client[[:digit:]]+/album/(album_[[:digit:]]{3}-[[:digit:]]{4}_IMG\.JPG)#i',
$string, $matches);

--- End Message ---
--- Begin Message ---
On Tue, Jun 22, 2004 at 10:08:37PM +0300 Robin Vickery [EMAIL PROTECTED] wrote:
> On Tue, 22 Jun 2004 14:57:28 -0400, Ryan Schefke <[EMAIL PROTECTED]> wrote:
> > 
> > Could someone please help me with an eregi statement.
> > 
> > I have a string that can vary as such:
> > 
> > client1/album/album_121-2132_IMG.JPG
> > 
> > client2/album/album_121-2132_IMG.JPG
> > 
> > client59/album/album_121-2132_IMG.JPG
> > 
> > client499887/album/album_121-2132_IMG.JPG
> > 
> > I want to select whatever comes after the last forward slash, like
> > album_121-2132_IMG.JPG
> 
> preg_match('#client[[:digit:]]+/album/(album_[[:digit:]]{3}-[[:digit:]]{4}_IMG\.JPG)#i',
> $string, $matches);
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

too complex.

eregi("\/([a-z0-9_-]*\.jpg)$", $string, $arg) is good enough :)

/tom

-- 
===============================================================================
Tomas Meinlschmidt, SBN3, MCT, MCP, MCP+I, MCSE, NetApp Filer & NetCache
gPG fp: CB78 76D9 210F 256A ADF4 0B02 BECA D462 66AB 6F56 / $ID: 66AB6F56
GCS d-(?) s: a- C++ ULHISC*++++$ P+++>++++ L+++$>++++ E--- W+++$ N++(+) !o
    !K w(---) !O !M V PS+ PE Y+ PGP++ t+@ !5 X? R tv b+ !DI D+ G e>+++
    h---- r+++ z+++@
===============================================================================

--- End Message ---
--- Begin Message ---
[snip]
client1/album/album_121-2132_IMG.JPG

client2/album/album_121-2132_IMG.JPG

client59/album/album_121-2132_IMG.JPG

client499887/album/album_121-2132_IMG.JPG

 

I want to select whatever comes after the last forward slash, like
album_121-2132_IMG.JPG
[/snip]

you could try without regular expressions

$string = 'client1/album/album_121-2132_IMG.JPG';
$arr = explode('/',$string);
print $arr[count($arr) - 1];

--- End Message ---
--- Begin Message ---
* Thus wrote Tom Z. Meinlschmidt:
> On Tue, Jun 22, 2004 at 10:08:37PM +0300 Robin Vickery [EMAIL PROTECTED] wrote:
> > On Tue, 22 Jun 2004 14:57:28 -0400, Ryan Schefke <[EMAIL PROTECTED]> wrote:
> > > 
> > > Could someone please help me with an eregi statement.
> > > 
> > > I have a string that can vary as such:
> > > 
> > > client1/album/album_121-2132_IMG.JPG
> > > 
> > > ...
> > > 
> > > I want to select whatever comes after the last forward slash, like
> > > album_121-2132_IMG.JPG
> > 
> > preg_match('#client[[:digit:]]+/album/(album_[[:digit:]]{3}-[[:digit:]]{4}_IMG\.JPG)#i',
> > $string, $matches);
> 
> too complex.
> 
> eregi("\/([a-z0-9_-]*\.jpg)$", $string, $arg) is good enough :)

Still too complex.

basename('client1/album/album_121-2132_IMG.JPG');

Curt
-- 
Feels like he's filling Mr Holmes shoes right now :)

--- End Message ---
--- Begin Message ---
>===== Original Message From "Eric L. Sammons" <[EMAIL PROTECTED]> =====
I am in the process of writing a PHP program.  It is really quite simple, I
have a form that I complete, the information is then to be saved into a simple
XML file.  When I do this in Java the XML file would appear simply as follows:

<?xml version="1.0" encoding="UTF-8"?>
<Server Name="pxtest01">
  <Serical_Number>000000000</Serical_Number>
  <Asset_Tag>00000</Asset_Tag>
  <Model>DL380</Model>
  <Location>8th Floor</Location>
  <Cabinet>2</Cabinet>
  <Application_Group>Customer</Application_Group>
  <Purpose>Upgrade</Purpose>
</server>

However, when attempting this in PHP I seem only able to get the following:

<?xml version="1.0"?> <Server
Name="pxtest01"><Serial_Number></Serial_Number></server>

The code I use to get this much follows:
<?php

         $doc = domxml_new_doc("1.0");
         $root = $doc->add_root("Server");
         $root->set_attribute("Name", "pxtest01");
         $el = $doc->create_element("Serial_Number");
         $root->append_child($el);
        $text = $doc->create_text_node($el["000000"]);
        $el->append_child($text);
         print  htmlentities($doc->dump_mem());
?>

My question is a simple one I am sure; however, I have been unable to find the
answer...  How do I add a value or content to an element.  For example:
<Serial_Number>0000000</Serial_Number>

While I am at it, is there an easy way to get the DOM to dump in a nicer more
readible format?

Thank you!

--- End Message ---
--- Begin Message ---
I am trying to create an image uploader however, the code I have created doesn't seem 
to upload the images. If anyone sees any ways that I can get this to work or if you 
know any better ways, please let me know.

<?php

/*======================================================================*\
|| #################################################################### ||
|| #                The PHP Store Uploader Beta 1.00                  # ||
|| # ---------------------------------------------------------------- # ||
|| #         Copyright ©2004 Sean Vasey . All Rights Reserved.        # ||
|| #   This script may not be redistributed without written consent.  # ||
|| # ------------------------ The PHP Store ------------------------- # ||
|| #                      http://thephpstore.com                      # ||
|| #################################################################### ||
\*======================================================================*/

// user defined variables
$uploadpath = "/home/midweste/www/www/uploader/uploads"; // absolute path to 
destination folder
$serverpath = "http://midwesternwebs.com/uploader/uploads";; // server path to uploads 
folder with no trailing slash (ex. http://thephpstore.com/uploads)
$sizelimit = "yes"; // do you want a size limit on the upload? (yes or no)
$size = "102400"; // if size limit, what is it? (in bytes)
$uploads = "1"; // number of uploads (changing this is not recommended)

// variables
$imagesize = getimagesize($image);

// begin checks and upload if successful
        if ($_REQUEST['submitted']) // if hidden field, submitted, is obtained on 
request, begin processing
        {
                // image mime types
                $gif = "image/gif"; // gif mime type
                $jpg = "image/pjpeg"; // jpg mime type
                $jpeg = "image/jpeg"; // jpeg mime type
                $png = "image/png"; // png mime type
                $xpng = "image/x-png"; // png mime type for internet explorer
                $bmp = "image/bmp"; // bmp mime type
                $tiff = "image/tiff"; // tiff mime type

                /*              NOTE:   
                                You can also add more mime types to those listed above 
however
                                you will also be required to make some more 
adjustments to the
                                processing portion of the script where it checks if 
the submitted
                                image matches the listed mime types.
                                More directions are included in the install.txt and 
readme.txt files.
                                Please consult them for more details.
                */
                
                $result = ""; // make sure there is no result at this point
                $rand = rand(1, 99999); // random number to at at end of filename
                
                for ($i = 0; $i < $uploads; $i++)
                {
                        if (($img[$i] == "$gif") or ($img[$i] == "$jpeg") or ($img[$i] 
== "$jpg") or ($img[$i] == "$png") or ($img[$i] == "$xpng")
                         or ($img[$i] == "$bmp") or ($img[$i] == "$tiff"))
                        {
                                if ($img[$i] == "$gif") // if gif file type
                                {
                                        $image[$i] = $image[$i] . "-" . "$rand" . 
".gif";
                                }
                                
                                if (($img[$i] == "$jpg") or ($img[$i] == "$jpeg")) // 
if jpeg file type
                                {
                                        $image[$i] = $image[$i] . "-" . "$rand" . 
".jpg";
                                }
                                
                                if (($img[$i] == "$png") or ($img[$i] == "$xpng")) // 
if png file type
                                {
                                        $image[$i] = $image[$i] . "-" . "$rand" . 
".png";
                                }
                                
                                if ($img[$i] == "$tiff") // if tiff file type
                                {
                                        $image[$i] = $image[$i] . "-" . "$rand" . 
".tiff";
                                }
                                
                                if ($img[$i] == "$bmp") // if bmp file type
                                {
                                        $image[$i] = $image[$i] . "-" . "$rand" . 
".bmp";
                                }
                        }
                }
                
                for ($i = 0; $i < $uploads; $i++)
                {
                        // check if a file was selected for upload
                        if (!$image[$i])
                        {
                                $result .= "You did not select an image for 
upload!<br>";
                        }
                        
                        if ($image[$i]) // if an image was selected, make sure it 
meets requirements
                        {
                                // check if file already resides on server
                                if (file_exists("$uploadpath/$image[$i]"))
                                {
                                        $result .= "The image you attempted to upload 
already resides on the server. Please rename your image before continuing!<br>";
                                }
                                
                                // check if the image was too large
                                if ($sizelimit == "yes" && $imagesize > $size)
                                {
                                        $result .= "The image you attempted to upload 
was too large. Please try another image!<br>";
                                }
                        }
                        else
                        {
                                // check if file is an image one last time
                                if (($img[$i] == "$gif") or ($img[$i] == "$jpeg") or 
($img[$i] == "$jpg") or ($img[$i] == "$png") or ($img[$i] == "$xpng")
                                 or ($img[$i] == "$bmp") or ($img[$i] == "$tiff"))
                                {
                                        @copy($image[$i], "$uploadpath/$image[$i]") or 
$result .= "$image[$i] could not be copied to the server. Please try again!";
                                        
                                        if (file_exists("$uploadpath/$image[$i]"))
                                        {
                                                $result .= "Your image was 
successfully uploaded to <a href=\"$serverpath/$image[$i]\" 
target=\"_blank\">$serverpath/$image[$i]</a><br>";
                                        }
                                        else
                                        {
                                                $result .= "The file you attempted to 
upload was not an image!<br>";
                                        }
                                }
                        }
                }
        }

        echo($result);
?>

--- End Message ---
--- Begin Message ---
[snip]
I am trying to create an image uploader however, the code I have
created doesn't seem to upload the images. If anyone sees any ways that
I can get this to work or if you know any better ways, please let me
know.
[/snip]

that is quit a bit of code.  Are you getting any specific errors?

have you looked at http://pear.php.net/package/HTTP_Upload ?

--- End Message ---
--- Begin Message --- Sean Vasey wrote --- napísal::
// variables
$imagesize = getimagesize($image);


// some code removed

                if ($img[$i] == "$gif") // if gif file type
                {
                        $image[$i] = $image[$i] . "-" . "$rand" . ".gif";
                }
                                

So is $image a filename or an array?

> // begin checks and upload if successful
> if ($_REQUEST['submitted']) // if hidden field, submitted, is obtained on request, begin processing
> {


Are register_globals on or off?


@copy($image[$i], "$uploadpath/$image[$i]") or $result .= "$image[$i] could not be copied to the server. Please try again!";

Always use move_uploaded_file() instead of copy(). copy() will not work if safe mode is on. And remove @ while debugging.


                                        
                if (file_exists("$uploadpath/$image[$i]"))

Do you really want to save the file with the assigned random name?

Please, read http://sk2.php.net/manual/en/features.file-upload.php
--- End Message ---
--- Begin Message ---
That is thrue, but there are some experiments with compiling the scripts
into
self running exe's. There are a nice tutorial available somewhere made by
probably the only one who has managed to do this, :) Anywho, I remember
one can use his precompiled files to create ones own EXE setups.

Still, the problem at the time I experimented with it was that you get an
extra DOS window which lies on the taskbar. This was a year ago, maby things
have happened since then.

--
--
Kim Steinhaug
----------------------------------------------------------------------
There are 10 types of people when it comes to binary numbers:
those who understand them, and those who don't.
----------------------------------------------------------------------
www.steinhaug.com - www.easywebshop.no - www.webkitpro.com
----------------------------------------------------------------------

"Marek Kilimajer" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Kim Steinhaug wrote --- napísal::
> > Well,
> >
> > You could have a look at this one, http://gtk.php.net/
> > Though I never had the lucury of getting anywhere with it, it
> > has the possibility to create standalone EXE. There is (Atleast the last
> > time i checked) still a problem with the EXE opening an extra command
prompt
> > window, which makes it look abit "unprofessional" if your thinking of
> > applying
> > somthing for your business customer.
> >
>
> That extension does not create exe files, they are normal php scripts
> that use gtk functions.
>
> The "window issue" can be solved, there is some kind of wrapper available.

--- End Message ---
--- Begin Message ---
* Thus wrote Nadim Attari:
> 
> > I have a problem with sessions.  If someone closes their internet explorer
> > window without logging off the session remains open.  When you try to go
> > back to the site IE hangs until I manually remove the sess_xxxx files from
> > the /tmp directory.  Any insights on this one??
> >
> > VR/Tim
> 
> http://www.php.net/setcookie
> (find 'expire' in this manual)

Actually you want:
  http://php.net/session

Under cookie_lifetime.


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

--- End Message ---
--- Begin Message ---

Thus Curt Zirzow & I wrote:


header("Content-Type: " . $type); header("Accept-Ranges: bytes");



Becareful sending this header.  The client can get confused and
send special headers requesting a partial file, while also
expecting different results than the whole file.


Which header?  The "Accept-Ranges" header?  Should I just not include it?



header("Content-Length: ".filesize($file));
header("Content-Disposition: attachment; filename=".basename($file).";"); //readfile($file); $fp = fopen($file, 'rb');
$buffer = fread($fp, filesize($file));



You'll be much better off if you use fpassthru here. This fread
could kill you're machine's memory.

Curt



I switched my code to look like this:



/*old code:
fp = fopen($file, 'rb');
$buffer = fread($fp, filesize($file));
fclose($fp);
print $buffer;
exit();                 
*/


$fp = fopen($file, 'rb'); $buffer = fpassthru($fp); fclose($fp); exit();


Yet in IE if I choose to 'open' the file instead of saving it, it asks me that question twice. I'm wondering if that will cause an error on an older version of i.e. or any other browser.


On php.net, it gave this code:
|// open the file in a binary mode
$name = ".\public\dev\img\ok.png";
$fp = fopen($name, 'rb');

// send the right headers
header("Content-Type: image/png");
header("Content-Length: " . filesize($name));

// dump the picture and stop the script
fpassthru($fp);
exit;|



basically the same code, but without an fclose(); could this be doing it?

Best Regards, and thank you so much for the help,

Scott Taylor
--- End Message ---

Reply via email to