[PHP] Saving A Database Image to a File (Thumbnail Problems)

2001-11-29 Thread Mike Gifford

Hello All,

I'd really appreciate some help figuring out what's wrong with this 
code.  I can't seem to successfully save a MySQL JPG Image to a physical 
jpg file (well atleast not a valid one)

The critical pieces of the code look like this:

  // 1. Get Image from DB to String
  $sql = SELECT Image FROM Images WHERE ID='$ID';
  $res = dbi_query ( $sql );
  if ( $res ) {
   if($row = dbi_fetch_row( $res ))
   dbi_free_result ( $res );
   $Images = stripslashes($row[0]);
  }

  $File = ReThumbnail.jpg;

  // 2. Write string to File
  $fd = fopen($File, wb);
  fputs($fd,$Images,strlen($Images));
  fclose($fd);

  // 3. Create Thumbnail
  system(djpeg -pnm $File | pnmscale -xscale $xscale -yscale $yscale | 
  cjpeg  $File.tmb);

  // 4. Read New Thumbnail into a new string
  $fd = fopen( $File.tmb, rb);
  $tmb = addslashes(fread($fd,filesize($File.tmb)));
  fclose($fd);

  // 5. Update Database
  $sql = UPDATE Images SET Thumbnail='$tmb' WHERE ID=$ID;
  if(dbi_query($sql)) {
   echo ReThumbnailing Successful;
   exit;
  }

The problem seems to be in step 2 from what I can figure.

I know that the Image file in the database is valid and outputs the 
appropriate info to display the jpg..  However, the image that is saved 
to the hard drive doesn't seem to be valid.

Nor can I run the system command from the command line on the server:

[mike@madras caravan2001]$ djpeg -pnm ReThumbnail.jpg | pnmscale -xscale 
.1 -yscale .1 | cjpeg  ReThumbnail.jpg.tmb
Corrupt JPEG data: 67 extraneous bytes before marker 0xc2
Quantization table 0x01 was not defined
pnmscale: Command not found.
Empty input file

I'm not sure what those extra 67 bytes are about..  Is the Oxc2 marker 
the beginning or the end?  I couldn't figure this out either..

However, if step 2 isn't working, It's bungling up everything else...

I thought that this might be an issue of strlen balking over the binary 
file.  The documentation doesn't seem to think this would be a problem 
(with binary files)

 http://www.php.net/manual/en/function.strlen.php

I found an alternate resource here

 http://www.php.net/manual/en/function.mysql-field-len.php

and attempted to incorporate it with

 // Alternate way to determine strlen
 $result = mysql_query($sql);
 $ImageSize = mysql_field_len ($result, 0);
 // $ImageSize = strlen($Images);
 echo $ImageSize;


That didn't work either..  However I wqas able to get some more useful 
information about the validity of strlen


DB Result

-rwxrwxrwx1 mike www 17159 Nov 29 23:27 ReThumbnail.jpg
-rwxrwxrwx1 mike www 0 Nov 29 23:27 ReThumbnail.jpg.tmb

16777215
Temp Thumb File: ReThumbnail.jpg.tmb
Thumbnail:
ReThumbnailing Successful

[mike@madras caravan2001]$ djpeg -pnm ReThumbnail.jpg | pnmscale -xscale 
.1 -yscale .1 | cjpeg  ReThumbnail.jpg.tmb
Corrupt JPEG data: 67 extraneous bytes before marker 0xc2
Quantization table 0x01 was not defined
pnmscale: Command not found.
Empty input file



strlen Result

-rwxrwxrwx1 mike www 17159 Nov 29 23:24 ReThumbnail.jpg
-rwxrwxrwx1 mike www 0 Nov 29 23:24 ReThumbnail.jpg.tmb

17159
Temp Thumb File: ReThumbnail.jpg.tmb
Thumbnail:
ReThumbnailing Successful

[mike@madras caravan2001]$ djpeg -pnm ReThumbnail.jpg | pnmscale -xscale 
.1 -yscale .1 | cjpeg  ReThumbnail.jpg.tmb
Corrupt JPEG data: 67 extraneous bytes before marker 0xc2
Quantization table 0x01 was not defined
pnmscale: Command not found.
Empty input file


Any suggestions would be appreciated..

Really, all I'm trying to do is take a MySQL jpg image and shring it 10% 
and then save it again as another MySQL Image (a thumbnail)...

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://www.openconcept.ca
Offering everything your organization needs for an effective web site.
New PHP/MySQL Photogallery  Great Pictures http://genevilleneuve.com
In all things it is better to hope than to despair.Wolfgang von Goethe


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Saving A Database Image to a File (Thumbnail Problems)

2001-11-29 Thread Mike Gifford

Hi Martin,

I read somewhere else that this was required for binary files..  However 
it certainly doesn't seem to be..

As it turns out, when I took out the stripslashes($row[0]) from:

// 1. Get Image from DB to String
$sql = SELECT Image FROM Images WHERE ID='$ID';
$res = dbi_query ( $sql );
if ( $res ) {
 if($row = dbi_fetch_row( $res ))
 dbi_free_result ( $res );
 $Images = $row[0];
}

It mostly worked..

However I ran into another problem..  I think this is a difference 
between RedHat 6.x and 7.x..

pnmscale doesn't seem to exist in the 7.x release.

I ended up using the following instead:
system(djpeg -pnm -scale 1/8 $File | cjpeg  $File.tmb);

In anycase thanks for your help.

Mike

Martin Towell wrote:

 try changing this line
   fputs($fd,$Images,strlen($Images));
 to
   fputs($fd,$Images);
 as you don't need to specify the length. If you don't specify the 
 length, it'll write the entire string. see how that goes...
 
 -Original Message-
 From: Mike Gifford [mailto:[EMAIL PROTECTED]]
 Sent: Friday, November 30, 2001 3:47 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Saving A Database Image to a File (Thumbnail Problems)
 
 
 Hello All,
 
 I'd really appreciate some help figuring out what's wrong with this
 code.  I can't seem to successfully save a MySQL JPG Image to a physical
 jpg file (well atleast not a valid one)
 
 The critical pieces of the code look like this:
 
   // 1. Get Image from DB to String
   $sql = SELECT Image FROM Images WHERE ID='$ID';
   $res = dbi_query ( $sql );
   if ( $res ) {
if($row = dbi_fetch_row( $res ))
dbi_free_result ( $res );
$Images = stripslashes($row[0]);
   }
 
   $File = ReThumbnail.jpg;
 
   // 2. Write string to File
   $fd = fopen($File, wb);
   fputs($fd,$Images,strlen($Images));
   fclose($fd);
 
   // 3. Create Thumbnail
   system(djpeg -pnm $File | pnmscale -xscale $xscale -yscale $yscale |
   cjpeg  $File.tmb);
 
   // 4. Read New Thumbnail into a new string
   $fd = fopen( $File.tmb, rb);
   $tmb = addslashes(fread($fd,filesize($File.tmb)));
   fclose($fd);
 
   // 5. Update Database
   $sql = UPDATE Images SET Thumbnail='$tmb' WHERE ID=$ID;
   if(dbi_query($sql)) {
echo ReThumbnailing Successful;
exit;
   }
 
 The problem seems to be in step 2 from what I can figure.
 
 I know that the Image file in the database is valid and outputs the
 appropriate info to display the jpg..  However, the image that is saved
 to the hard drive doesn't seem to be valid.
 
 Nor can I run the system command from the command line on the server:
 
 [mike@madras caravan2001]$ djpeg -pnm ReThumbnail.jpg | pnmscale -xscale
 .1 -yscale .1 | cjpeg  ReThumbnail.jpg.tmb
 Corrupt JPEG data: 67 extraneous bytes before marker 0xc2
 Quantization table 0x01 was not defined
 pnmscale: Command not found.
 Empty input file
 
 I'm not sure what those extra 67 bytes are about..  Is the Oxc2 marker
 the beginning or the end?  I couldn't figure this out either..
 
 However, if step 2 isn't working, It's bungling up everything else...
 
 I thought that this might be an issue of strlen balking over the binary
 file.  The documentation doesn't seem to think this would be a problem
 (with binary files)
 
  http://www.php.net/manual/en/function.strlen.php
 
 I found an alternate resource here
 
  http://www.php.net/manual/en/function.mysql-field-len.php
 
 and attempted to incorporate it with
 
  // Alternate way to determine strlen
  $result = mysql_query($sql);
  $ImageSize = mysql_field_len ($result, 0);
  // $ImageSize = strlen($Images);
  echo $ImageSize;
 
 
 That didn't work either..  However I wqas able to get some more useful
 information about the validity of strlen
 
 
 DB Result
 
 -rwxrwxrwx1 mike www 17159 Nov 29 23:27 ReThumbnail.jpg
 -rwxrwxrwx1 mike www 0 Nov 29 23:27 ReThumbnail.jpg.tmb
 
 16777215
 Temp Thumb File: ReThumbnail.jpg.tmb
 Thumbnail:
 ReThumbnailing Successful
 
 [mike@madras caravan2001]$ djpeg -pnm ReThumbnail.jpg | pnmscale -xscale
 .1 -yscale .1 | cjpeg  ReThumbnail.jpg.tmb
 Corrupt JPEG data: 67 extraneous bytes before marker 0xc2
 Quantization table 0x01 was not defined
 pnmscale: Command not found.
 Empty input file
 
 
 
 strlen Result
 
 -rwxrwxrwx1 mike www 17159 Nov 29 23:24 ReThumbnail.jpg
 -rwxrwxrwx1 mike www 0 Nov 29 23:24 ReThumbnail.jpg.tmb
 
 17159
 Temp Thumb File: ReThumbnail.jpg.tmb
 Thumbnail:
 ReThumbnailing Successful
 
 [mike@madras caravan2001]$ djpeg -pnm ReThumbnail.jpg | pnmscale -xscale
 .1 -yscale .1 | cjpeg  ReThumbnail.jpg.tmb
 Corrupt JPEG data: 67 extraneous bytes before marker 0xc2
 Quantization table 0x01 was not defined
 pnmscale: Command not found.
 Empty input file
 
 
 Any suggestions would be appreciated..
 
 Really, all I'm trying to do is take a MySQL jpg image and shring it 10%
 and then save it again as another MySQL Image (a thumbnail)...
 
 Mike
 -- 
 Mike

[PHP] Re: JPG Images from database to filename.jpg

2001-11-16 Thread Mike Gifford

Hi George,

George Whiffen wrote:

 I'm confused. Is your problem serving up the images in your database to the web or 
writing them out
 to files on the server?


Sorry for the confusion..  It was in writing out the database images to 
files on the server.  This is where my problem lies..


 If it's serving images, I would expect you to have: 
 select myimage from db
 Header(Content-type: image/jpeg);
 echo $myrow[myimage];
 exit();


Yes..  This is consistent with what is done in the rest of the script 
and indeed what any of other tutorials describe..


 If it's writing from the db to a real file on your server, I would expect: 
 select myimage from db
 open myfile
 write $myrow[myimage];
 close myfile


I've tried something like this:

$connection = mysql_connect(host, user, pwd);
mysql_select_db(dbname);
$query = 'SELECT imagefiled FROM imagetabel WHERE id = '.$id;
$result = mysql_query($query);
$row = mysql_fetch_row($result);

$fd = fopen( $File.tmb, r+);
$tmb = addslashes(fwrite($fd, $row[0]));
fclose($fd);

However, I can't view the file that is saved (there is a file saved each 
time I do this, but can't tell if it is the appropriate file)..
   I assumed that I needed to include the header file..

The template also doesn't seem to work, but that is because of an error 
I'm getting an error when i run this on the server (the expression of 
what I am trying to do with the system() command below):

djpeg -pnm ReThumbnail.jpg | pnmscale -xscale .1 -yscale .1 | cjpeg  
ReThumbnail.jpg.tmb

Corrupt JPEG data: 67 extraneous bytes before marker 0xc2
Quantization table 0x01 was not defined
pnmscale: Command not found.
Empty input file

I don't know what this all means


 The Header is just for the web, to tell the browser or other client what kind of 
file it is getting
 from your php script since it is not the expected type automatically supplied by the 
web-server
 (text/html).  Real physical files don't need a header.  The web servers 
automatically generate
 appropriate headers for real image files based on the file extension before they 
send them out over
 the web.


So, why can't I see this the 17159 bytes of this image then:
http://www.wtoaction.org/caravan2001/ReThumbnail.jpg

I was assuming that I couldn't see it because I didn't have the header. 
  I was just trying to use ImageJPEG to force in a header.  It would be 
far easier to just write the contents of an image from a database and 
insert them into a file..


 Does that make sense, or have I completely missed the point?


You got the point.. Thanks for your help..  Still not there yet though..

Mike


 Mike Gifford wrote:
 
Hello,

I've got a number of images in a database..  Ultimately what I would
like to do is be able to resize the image that is already in the
database and then insert that image into another field.

Uploading the files generally inserts these both at the same time,
however I need to create a number of new thumbprints based on a
different scale.

What I thought would be easiest would be to take the image, save it to
filename.jpg and then run the thumbnailing script on it.

I think that this would look like the following:

?php
// There's other DB stuff here, but this isn't important
$Images = stripslashes($row[0]);
$File = ReThumbnail.jpg;

// Create JPG image
ImageJPEG(imagecreatefromstring($Images), $File);

// Scale image
system(djpeg -pnm $File | pnmscale -xscale .1 -yscale .1 | cjpeg 
$File.tmb);

// Write thumbprint
$fd = fopen( $File.tmb, r+);
$tmb = addslashes(fread($fd, filesize($File.tmb)));
fclose($fd);

// Insert Thumbprint image into database
$sql = UPDATE Images SET Thumbnail='$tmb' WHERE ID=$ID;
// There's other DB Stuff here too...
?

I'm really quite stuch here..

How do you take a db image of a database and create a physical jpg file?
  I think I'm getting messed up by the header in:

Header(Content-type: image/jpeg);
echo $Images;

I can't figure out how to create the header.  There's lots of examples
of how to do the above, but I have yet to stumble across an example
which allows you to write the header into a file

Suggestions would be appreciated..

Mike




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: JPG Images from database to filename.jpg

2001-11-16 Thread Mike Gifford

Sorry if I wasn't very clear abou tthis..

I don't need to echo the contents to be viewed on the web..  I'm already 
doing that here:

http://www.wtoaction.org/caravan2001/

It's a matter of saving it to a file on the disk (from the database) so 
I can manipulate it with djpeg, pnmscale, cjpeg

Thanks for throwing in the mysql stuff I left out..

Mike

Johan Holst Nielsen wrote:

Header(Content-type: image/jpeg);
echo $Images;

I can't figure out how to create the header.  There's lots of examples
of how to do the above, but I have yet to stumble across an example
which allows you to write the header into a file

 
 You could make a PHP script that generate the picture?
 
 Like this:
 
 ?php
 /* Picture file need an ID!! */
 $connection = mysql_connect(host, user, pwd);
 mysql_select_db(dbname);
 $query = 'SELECT imagefiled FROM imagetabel WHERE id = '.$id;
 $result = mysql_query($query);
 if(mysql_num_rows($result)  0) {
//You got the image
header(Content-type: image/jpeg);
$row = mysql_fetch_row($result);
echo $row[0];
 }
 else {
//No image with that id!
 }
 mysql_close($connection);
 ?
 
 HTML file where the image is:
 
 html
 body
 img src=phpfile.php?id=23 border=0 alt=
 /body
 /html
 
 Dont know if you misunderstand you?
 
 Regards,
 Johan
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: JPG Images from database to filename.jpg

2001-11-16 Thread Mike Gifford

Hello,

Jtjohnston wrote:

 See these. Reduire.phps probably has what you want.
  http://www.collegesherbrooke.qc.ca/si/php/exemples/photos/reduire.phps

This is what I was looking for I think..  But it still gives me an 
error..  This one actually got inserted right into the database:

br bWarning/b: Data is not in a recognized format. in 
b/home/mike/wtoaction/public_html/caravan2001/edit_image_handler.php/b 
on line b65/bbr br bWarning/b: Supplied argument is not a 
valid Image resource in 
b/home/mike/wtoaction/public_html/caravan2001/edit_image_handler.php/b 
on line b34/bbr br bWarning/b: Supplied argument is not a 
valid Image resource in 
b/home/mike/wtoaction/public_html/caravan2001/edit_image_handler.php/b 
on line b40/bbr

This is these are the relenvant pieces of the code..

Any suggestions would be appreciated..

Mike

?php php_track_vars?
?php

include config.inc.php;
include $baseDIR/php-dbi.inc;
include $baseDIR/connect.inc;
include $baseDIR/misc.inc;

function ResizeImage( $srcImage, $srcWidth, $srcHeight, $xscale, $yscale) {
// http://www.collegesherbrooke.qc.ca/si/php/exemples/photos/reduire.phps
//obtain the original image Height and Width
// $srcWidth = ImageSX( $srcImage );
// $srcHeight = ImageSY( $srcImage );

// the following portion of code checks to see if
// the width  height or if width  height
// if so it adjust accordingly to make sure the image
// stays smaller then the $newWidth and $newHeight
// $ratioWidth = $srcWidth/$newWidth;
// $ratioHeight = $srcHeight/$newHeight;

// if( $ratioWidth  $ratioHeight){
// $destWidth = $srcWidth/$ratioHeight;
// $destHeight = $newHeight;
// }else{
// $destWidth = $newWidth;
// $destHeight = $srcHeight/$ratioWidth;
// }

$destWidth = $srcWidth * $xscale;
$destHeight = $srcHeight * $yscale;

$destImage = imagecreate($destWidth, $destHeight);
ImageCopyResized( $destImage, $srcImage, 0, 0, 0, 0, $destWidth, 
$destHeight, $srcWidth, $srcHeight );

//  (changer selon le genre)
ImageJPEG($destImage,,100);

//free the memory used for the images
ImageDestroy( $srcImage );
ImageDestroy( $destImage );
}

if(!isAdmin())
{
 die(Must be admin!);
}

if(!isset($ID)) { die(You must have an ID to proceed); }

if($ReThumbnail) {
ob_start();

$sql = SELECT Image FROM Images,Width,Height WHERE ID='$ID';
$res = dbi_query ( $sql );
if ( $res ) {
  if($row = dbi_fetch_row( $res ))
  dbi_free_result ( $res );
  $Images = stripslashes($row[0]);
  $Width = stripslashes($row[1]);
  $Height = stripslashes($row[2]);
}
// echo Image: br$Images;

$srcimage = imagecreatefromstring($Images);
ResizeImage( $srcImage, $Width, $Height, $xscale, $yscale);

//copy output buffer to string
$resizedImage = ob_get_contents();
//clear output buffer that was saved
ob_end_clean();
$tmb = addslashes($resizedImage);

$sql = UPDATE Images SET Thumbnail='$tmb' WHERE ID=$ID;
if(dbi_query($sql)) {
echo ReThumbnailing Successful;
exit;
} else {
$error = dbi_error ();
}
}


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: JPG Images from database to filename.jpg

2001-11-16 Thread Mike Gifford

Sorry, couple post-Post changes..

The initial query should have been:
 $sql = SELECT Image,Width,Height FROM Images WHERE ID='$ID';

The an echo of the UPDATE sql now looks like this:

UPDATE Images SET Thumbnail='
Warning: Supplied argument is not a valid Image resource in 
/home/mike/wtoaction/public_html/caravan2001/edit_image_handler.php on 
line 34
ÿØÿà\0JFIF\0\0\0\0\0\0ÿþ\0 Warning: Supplied argument is not a valid Image 
resource in 
/home/mike/wtoaction/public_html/caravan2001/edit_image_handler.php on 
line 40
' WHERE ID=95ReThumbnailing Successful



This is the essential part of the script which is displaying the data now:

$sql = SELECT Format,Image FROM Images WHERE ID=$ID;
$res = dbi_query ( $sql );
if ( $res )
{
   if( $row = dbi_fetch_row ( $res ) )
   {
 Header(Content-type: image/jpeg);
 echo $row[1];
   }
   dbi_free_result ( $res );
}

The image looks just fine here:
http://www.wtoaction.org/caravan2001/image.php?ID=95

I must be missing something really simple..

Mike


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] test

2001-11-15 Thread Mike Gifford

Sorry, I've been having troulbe sending messages to newsgroups..


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] JPG Images from database to filename.jpg

2001-11-15 Thread Mike Gifford

Hello,

I've got a number of images in a database..  Ultimately what I would 
like to do is be able to resize the image that is already in the 
database and then insert that image into another field.

Uploading the files generally inserts these both at the same time, 
however I need to create a number of new thumbprints based on a 
different scale.

What I thought would be easiest would be to take the image, save it to 
filename.jpg and then run the thumbnailing script on it.

I think that this would look like the following:

?php
// There's other DB stuff here, but this isn't important
$Images = stripslashes($row[0]);
$File = ReThumbnail.jpg;

// Create JPG image
ImageJPEG(imagecreatefromstring($Images), $File);

// Scale image
system(djpeg -pnm $File | pnmscale -xscale .1 -yscale .1 | cjpeg  
$File.tmb);

// Write thumbprint
$fd = fopen( $File.tmb, r+);
$tmb = addslashes(fread($fd, filesize($File.tmb)));
fclose($fd);

// Insert Thumbprint image into database
$sql = UPDATE Images SET Thumbnail='$tmb' WHERE ID=$ID;
// There's other DB Stuff here too...
?

I'm really quite stuch here..

How do you take a db image of a database and create a physical jpg file? 
  I think I'm getting messed up by the header in:

Header(Content-type: image/jpeg);
echo $Images;

I can't figure out how to create the header.  There's lots of examples 
of how to do the above, but I have yet to stumble across an example 
which allows you to write the header into a file

Suggestions would be appreciated..

Mike


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Uploading Photos to MySQL

2001-09-12 Thread Mike Gifford

Hi Sean,

Sean C. McCarthy wrote:
 If you mean http://www.webtechniques.com/archives/1998/02/lerdorf/ what
 inserts in the DB is just the image's name, but not the file itself.

I had trouble opening up the upload.php3 file in list six, so I couldn't verify 
by looking at the code.  Not sure if it was the javascript or what, but I 
couldn't open it.

 What is exactly the problem you are having with the class? Just a couple
 days ago I had a problem uploading files into a MySQL DB because the
 addslashes function. As I have seen in this code it also uses it. Your
 problem is with getting corrupt data from the DB?

Add slashes are included as the file is added to the array:
$this-daten[image] = addslashes(fread(fopen($userfile, r), 
filesize($userfile)));

Some content almost gets inserted.  However it only gets as far as:
Content-Type: image/jpeg ÿØÿà

The image filed is just a blob

 If it is this use base64_encode and base64_decode. This is a tip Chris
 (only know his name) gave me as no solution for addslashes was given...
 Thanks again Chris!!

Ok..  This is getting better..

http://php.net/manual/en/function.base64-encode.php
$this-daten[image] = addslashes(base64_encode(
fread(fopen($userfile, r), filesize($userfile;

gives me quite a lot more information.  Even looks like when I upload different 
images, that it is different information (unlike previous attempts)

Unfortunately, it still isn't producing the graphic that I'm looking for... 
Hmm..

I get raw code easily enough:
http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=16
http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=17
http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=18

Which is generated by:
mysql_connect($DBHOST, $DBUSER, $DBPASS);
mysql_select_db($DATABASE);
$resultset = mysql_query($query);
$query = SELECT image FROM ztpv_images WHERE imageID = $imageID;
$resultset = mysql_query($query);
print(stripslashes(base64_decode(mysql_result($resultset, 0, Image;

So I couldn't either view the file here..  or within a SRC=.  See:
http://pgs.ca/WLP/profiles/test.html

Also thanks for providing the direct URL for :Rasmus' classic Photo Album is still 
online with source code.
Google:
Rasmus Lerdorf and Photo Album


The google reference was a bit indirect (but it got to the same place too). 
Thanks Richard for this.  Although I did have problems actually viewing the script.

Mike


- Original Message -
From: Mike Gifford [EMAIL PROTECTED]
Newsgroups: php.general
To: [EMAIL PROTECTED]
Sent: Tuesday, September 11, 2001 2:45 PM
Subject: Uploading Photos to MySQL


Hello,

Has anyone developed another class for uploading images to a MySQL

database?

I downlaoded upload_db.zip from:
http://circle.ch/scripts/

as it was a phplib based and it looks like it should do what is required.
However it doesn't seem to be working.

Does anyone else have any good pointers to scripts to store jpg/png files

in

MySQL using PHP?

Thanks.

Mike
--
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
In all things it is better to hope than to despair.Wolfgang von Goethe


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

 



-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Regarding Sept 11, http://www.fgcquaker.org/statement091101.html
In all things it is better to hope than to despair.Wolfgang von Goethe


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: Uploading Photos to MySQL

2001-09-12 Thread Mike Gifford

Hi Sean,

Sorry for the delay with this..  Been a rather busy month..  However your help 
on this project has been very useful..

Sean C. McCarthy wrote:
  Mike Gifford wrote:
 Sean C. McCarthy wrote:
 If you mean http://www.webtechniques.com/archives/1998/02/lerdorf/ what
 inserts in the DB is just the image's name, but not the file itself.
 I had trouble opening up the upload.php3 file in list six, so I couldn't verify
 by looking at the code.  Not sure if it was the javascript or what, but I
 couldn't open it.
  I'll send you the code at a separate message, but just look at the
  tables definitions. There are no blob columns.

It is good to look at this code (not sure if Mozilla under Linux didn't like
the javascript, but glad others could see it).

You are right in that there are no blob files in it..  However, i wasn't
starting from that file.  Rather from a phplib class that was posted right here:
http://circle.ch/scripts/

 What is exactly the problem you are having with the class? Just a couple
 days ago I had a problem uploading files into a MySQL DB because the
 addslashes function. As I have seen in this code it also uses it. Your
 problem is with getting corrupt data from the DB?
 Add slashes are included as the file is added to the array:
 $this-daten[image] = addslashes(fread(fopen($userfile, r),
 filesize($userfile)));
 Some content almost gets inserted.  However it only gets as far as:
 Content-Type: image/jpeg ÿØÿà
 The image filed is just a blob
  Correct! I tried the same but with PDF files. The problem I had was that
  stripslashes and stripcslashes were not working as the manual said. When
  I had one \ addslashes() gave me \\ (comfirmed at the DB) but
  stripslashes() gave me a big nothing striping everything.

I shouldn't need to use this command should I?
http://php.net/manual/en/function.addcslashes.php

I've used stripslashes before effectively in other pieces of code..

 If it is this use base64_encode and base64_decode. This is a tip Chris
 (only know his name) gave me as no solution for addslashes was given...
 Thanks again Chris!!
 Ok..  This is getting better..
 http://php.net/manual/en/function.base64-encode.php
 $this-daten[image] = addslashes(base64_encode(fread(fopen($userfile, 
r), filesize($userfile;
  Just
  $this-daten[image] =
   base64_encode(fread(fopen($userfile, r), filesize($userfile)));

Ok..  I've modified this..

  The special chars in RFC2045 are from
  http://www.ietf.org/rfc/rfc2045.txt?number=2045 :
   tspecials :=  ( / ) /  /  / @ /
 , / ; / : / \ / 
 / / [ / ] / ? / =
 ; Must be in quoted-string,
 ; to use within parameter values
  Ok _ is not there... but anyway you are not going to make searches
  with  ... like 'something_' 

Must admit that I've been thrown by this one..  I've got no idea what's up with 
this..

 gives me quite a lot more information.  Even looks like when I upload different
 images, that it is different information (unlike previous attempts)
 Unfortunately, it still isn't producing the graphic that I'm looking for...
 Hmm..
 I get raw code easily enough:
 http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=16
 http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=17
 http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=18
 Which is generated by:
 mysql_connect($DBHOST, $DBUSER, $DBPASS);
 mysql_select_db($DATABASE);
 $resultset = mysql_query($query);
 $query = SELECT image FROM ztpv_images WHERE imageID = $imageID;
 $resultset = mysql_query($query);
 print(stripslashes(base64_decode(mysql_result($resultset, 0, Image;
 So I couldn't either view the file here..  or within a SRC=.  See:
 http://pgs.ca/WLP/profiles/test.html
  Have you forgot to add:
  header (Content-Type: image/jpeg);

You are right..  I had commented this out because I was getting an error that 
the header was already loaded..  I figured since I saw that in the database as 
well that it had been inserted and was now redundant.

  just before the print? If you have the type will be text/plain (or
  text/html or something). Add it just before anything gets outputed.

So you want the new code to look like this (for what is now 
http://pgs.ca/WLP/profiles/getimage-simple.php3):

mysql_connect($DBHOST, $DBUSER, $DBPASS);
mysql_select_db($DATABASE);
$resultset = mysql_query($query);   
header(Content-type:  image/jpeg);
$query = SELECT image FROM ztpv_images WHERE imageID = $imageID;
$resultset = mysql_query($query);
print(base64_decode(mysql_result($resultset, 0, Image)));


Hadn't done the following before:

  doing a wget -s I got the replies from your scripts like:
  Content-Type: text/html
  Content-Type: image/jpeg
  
  No idea about this...

Seems like taking out the add/remove slashes has elminated it from here:

[mike@office admin]$ wget -s 
http://pgs.ca/WLP/profiles/getimage-simple.php3?imageID=20
--01:47

[PHP] Uploading Photos to MySQL

2001-09-11 Thread Mike Gifford

Hello,

Has anyone developed another class for uploading images to a MySQL database?

I downlaoded upload_db.zip from:
http://circle.ch/scripts/

as it was a phplib based and it looks like it should do what is required. 
However it doesn't seem to be working.

Does anyone else have any good pointers to scripts to store jpg/png files in 
MySQL using PHP?

Thanks.

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
In all things it is better to hope than to despair.Wolfgang von Goethe


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Regular Expressions - A relatively simple search...

2001-09-09 Thread Mike Gifford

Thanks robin, this is very useful!

Robin Vickery wrote:
 [EMAIL PROTECTED] (Mike Gifford) writes:
 
 
Hello,

I'm trying to replace a couple of lines of code:

  $dotpos = 1 - (strlen($userfile_name) - strpos($userfile_name, '.'));
  $extension = substr($userfile_name, $dotpos);

with a simpler regular expression:
  $extension = eregi_replace( /.*, , $userfile_name);

However it isn't working..

What I'd like to do is to find the extension of a file name and place
that in a variable.  So in '/home/mike/test.txt', I want to have the
statement return 'txt'

 
 you don't need a regular expression for that...
 
 $extension = strrchr(basename($userfile_name), '.');
 
   -robin
 



-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: Regular Expressions - A relatively simple search...

2001-09-09 Thread Mike Gifford

Thanks..

_lallous wrote:
 ?
 $str = /home/mike/test.txt;
 if (preg_match(/[^\.]+$/, $str, $matches))
   $ext = $matches[0];
 else
   $ext = no extension;
 echo extension=$ext;
 ?
 
 Mike Gifford [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 
Hello,

I'm trying to replace a couple of lines of code:

$dotpos = 1 - (strlen($userfile_name) - strpos($userfile_name, '.'));
$extension = substr($userfile_name, $dotpos);

with a simpler regular expression:
$extension = eregi_replace( /.*, , $userfile_name);

However it isn't working..

What I'd like to do is to find the extension of a file name and place that

 in a variable.  So in
 
'/home/mike/test.txt', I want to have the statement return 'txt'

Any help would be appreciated..

Mike
--
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


 
 



-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Regular Expressions - A relatively simple search...

2001-09-06 Thread Mike Gifford

Hello,

I'm trying to replace a couple of lines of code:

$dotpos = 1 - (strlen($userfile_name) - strpos($userfile_name, '.'));
$extension = substr($userfile_name, $dotpos);

with a simpler regular expression:
$extension = eregi_replace( /.*, , $userfile_name);

However it isn't working..

What I'd like to do is to find the extension of a file name and place that in a 
variable.  So in 
'/home/mike/test.txt', I want to have the statement return 'txt'

Any help would be appreciated..

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Decent Web Calendar With Moderated Public Postings

2001-08-30 Thread Mike Gifford

Hello,

I'd like to find a good web calendar which will allow the general public to enter 
suggested events 
into a web calendar.  I would want these suggested events to be moderated so that they 
can be verified.

Does anyone know of a package that would allow this type of moderated public posting?  
I looked at 
Webcalendar:
http://webcalendar.sourceforge.net/

Which looks great for a number of things, but it doesn't seem to allow moderated 
anonymous posting.

Suggestions would be appreciated.

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Add Slashes - Server Adds Them Automatically - Advice Requested!

2001-08-30 Thread Mike Gifford

Hmm..  Forms always produced slashed data than I wouldn't have gotten a MySQL error on 
the ' in 
O'Neil..  But perhaps it is something on my server..

Andrey Hristov wrote:
 I think that always from a form the script gets slashed data.
 
 Andrey Hristov
 IcyGEN Corporation
 http://www.icygen.com
 99%
 
 - Original Message - 
 From: Mike Gifford [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, August 29, 2001 6:58 PM
 Subject: [PHP] Add Slashes - Server Adds Them Automatically - Advice Requested!
 
 
 
Hello,

I've created a little opensource script:
http://openconcept.ca/guide-petition.phtml

Which uses addslashes() to help clean up data inserted from a web form.

This is fine, except that it appears that you can set up php, so that addslashes are 
automatically 
added:

one small thing i noticed was the addSlashes issue. it seems like php is
sometimes installed (such as on my machine) in such a way that addSlashes
AUTOMATICALLY happens and therefore MANUAL addSlashes adds a SECOND,
superfluous forward slash.

eg
Patrick the skier kuharic
comes out in invitea friend emails by your system as
Patrick \the skier\  kuharic

Has anyone else experienced this?  Any suggestions for work arounds?

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



 



-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Decent Web Calendar With Moderated Public Postings

2001-08-30 Thread Mike Gifford

Rasmus Lerdorf wrote:
 Well, the one on php.net is very simple, but it meets those basic
 requirements.  http://www.php.net/cal.php

This looks like it would probably work!

 You can grab the source for it out of cvs.  See http://cvs.php.net

I couldn't get it from here, but I think I was able to grab the source files for all 
of the related 
files..

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Decent Web Calendar With Moderated Public Postings

2001-08-30 Thread Mike Gifford

Hello Ramus,

Rasmus Lerdorf wrote:
 Well, the one on php.net is very simple, but it meets those basic
 requirements.  http://www.php.net/cal.php
 You can grab the source for it out of cvs.  See http://cvs.php.net

Ok..  I've got the source..  However, pulling the calendar out of php.net is a bit 
trickier than it 
seems.

I'm getting some results:
http://pgs.ca/calendar/cal.php

But it certainly wasn't built to allow other folks to easily incorporate this calendar 
into their sites.

I suppose that they have had to conseal some things for the sake of security.  
However, it is 
proving to be a real nussance..  This has likely got all that I need for an event 
calendar.. 
However, I can't add events (big pain).

It is just a bloody nussance to untangle.

I think I now have the authorization figured out..  The trouble I think is in this 
line of code (and 
it's sister Reject_Selected which follows shortly after:

 if(isset($HTTP_POST_VARS['Approve_Selected_x']) || 
isset($HTTP_POST_VARS['Approve_Selected']) || 
isset($HTTP_POST_VARS['Approve_Selected_y'])) {
 foreach($entries as $entry=$val) {
 $result = mysql_query(update phpcal set approved=1, 
app_by='$user' where 
id=$entry);
 if(!$result) echo mysql_error();
 }
 }

This doesn't seem to be doing anything and I can not echo any results from:
echo $HTTP_POST_VARS['Approve_Selected_y';

What the heck am I doing wrong here?

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Add Slashes - Server Adds Them Automatically - Advice Requested!

2001-08-29 Thread Mike Gifford

Hello,

I've created a little opensource script:
http://openconcept.ca/guide-petition.phtml

Which uses addslashes() to help clean up data inserted from a web form.

This is fine, except that it appears that you can set up php, so that addslashes are 
automatically 
added:

one small thing i noticed was the addSlashes issue. it seems like php is
sometimes installed (such as on my machine) in such a way that addSlashes
AUTOMATICALLY happens and therefore MANUAL addSlashes adds a SECOND,
superfluous forward slash.

eg
Patrick the skier kuharic
comes out in invitea friend emails by your system as
Patrick \the skier\  kuharic

Has anyone else experienced this?  Any suggestions for work arounds?

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Using a query to selecting between two dates

2001-07-30 Thread Mike Gifford

I ended up using your simpler version, which came out like this:

$contentquery3 = mysql_query(SELECT *, YEAR(date) AS year, YEAR(NOW()) AS now 
FROM $articlestable WHERE articleSectionID = '$id' AND YEAR(date) = YEAR(NOW()) 
ORDER BY date DESC) or mysql_die();

Thanks.

Mike

Don Read wrote:

 On 29-Jul-2001 Mike Gifford wrote:
 
Hello,

I've got a number of press releases that I'd like to be able to order by
year. 
I'd like everything from this now to a year ago (ie. July 29th, 2000) to be 
ordered together and then allow folks to scroll back to the previous year
July 
30, 2000 to July 29th, 1999, etc.


 
 Sounds like a confusing interface to me.
 
 how about selecting by numerical year ?
 
 if (! isset($wantyear))
   $wantyear=date('Y');
 
 SELECT ... WHERE YEAR(date)='$wantyear' ...
 
 If you insist on now() - 1 year, look into DATE_SUB(NOW(), INTERVAL 1 YEAR)
 
 Regards,
 



-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Author.class - Does it exist?

2001-07-23 Thread Mike Gifford

Hello,

Does anyone know if there's a GPL author class out there?

There are online book stores  bibliographies all need to manage author names in 
a similar way (I would think), and I'd just like to not recreate the wheel if I 
don't have to.

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: One2Many Logic Problem - phpMySQL bibliography

2001-07-23 Thread Mike Gifford

Hello Steve,

Thanks for the response.  I tried to reply to this earlier, but seems like 
Mozilla ate it.  :(

Steve Brett wrote:

 wouldn't the structure of the database be determined by the fact you have a
 many to many relationship ?
 i.e. the two tables would decompose into three with a 'link' table defining
 the many to may part ?

Sorry if I wasn't clear about this.  You are right there is a linking table to 
manage the relationship.  I can create a query which will find duplicate 
author's for each book listed in this linking table.

However, I don't know how to effectively use this data to affect how information 
is extracted from the database in the second query.

CREATE TABLE WLPprofile (
profileID mediumint(9) NOT NULL,
languageID varchar(5),
addressID mediumint(9),
firstName varchar(255),
middleName varchar(255),
lastName varchar(255),
organization varchar(255),
nationality varchar(255),
professionID smallint(3),
bio text,
status varchar(5),
PRIMARY KEY (profileID)
);

CREATE TABLE WLPbib (
bibID mediumint(9) NOT NULL,
languageID varchar(5),
publisherID mediumint(9),
categoryID smallint(6),
type varchar(55),
title varchar(255),
pageNumber varchar(55),
source_bibID varchar(55),
publicationDate varchar(5),
dateAdded date,
publishedLanguage varchar(5),
URL varchar(100),
status varchar(5),
PRIMARY KEY (bibID)
);

CREATE TABLE WLPbib2profile (
bibID mediumint(9),
profileID mediumint(9)
);

Thanks.

Mike

 Mike Gifford [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 
 Hello,
 
 I'm not sure if anyone else as the need for a php/MySQL based
 
 bibliography, but
 
 the application that I am developing (which is basically a module for
 
 phpSlash)
 
 is coming along fairly well.  If anyone is interested in seeing the code I
 
 can
 
 bundle it up and send it out to them (still a long way from finished
 
 mind).  The
 
 draft version of it is up and running here:
 http://openconcept.ca/WLP/biblio/index.php3
 
 I'm running into a couple problems though that I don't have the logic
 
 language
 
 for and I was hoping folks here could help me (as you have done in the
 
 past).
 
 The problem is that I've set up a many to many table to ensure that I can
 
 have
 
 an author be listed as writing many books and a book be written by many
 
 authors.
 
 However in listing the books as a bibliography (as the URL above), I want
 
 to be
 
 able to list multiple authors, and do so in a different format for the
 
 first
 
 author than for all subsequent ones.
 
 I'm hoping to be able to produce output like this:
 Young, D. and N. Dixon. Helping Leaders Take Effective Action: A Program
 Evaluation. Greensboro, North Carolina: Center for Creative Leadership,
 1996.
 
 
 So, I think the first challenge should be to calculate which books have
 
 multiple
 
 authors by doing something like this (It's using phplib structures,
 
 sorry):
 
 $q2  = SELECT * FROM WLPbib2profile ORDER BY bibID;
 $this-db-query($q2);  // Performs above query
 while ($this-db-next_record()) {
 if ($this-db-Record[bibID] != $last_bibID) {
 echo br . $this-db-Record[bibID] .  :  .
 
 $this-db-Record[profileID];
 
 } else { // Multiple Authors
 echo ,  .  $this-db-Record[profileID];
 $multiple_profileID .= array ($this-db-Record[bibID] =
 $this-db-Record[profileID]);
 $multiple_profileID .= array($this-db-Record[bibID] =
 yes);
 }
 $last_bibID = $this-db-Record[bibID];
 }
 }
 
 With this I can then use the value $multiple_profileID to determine if
 
 this
 
 record has duplicates or not and use something like this to include both
 
 authors
 
 and not repeat the bibliography item:
 
 if ($multiple_profileID[$bibID]==yes) {
 while (list($key, $val) = each($multiple_profileID)) {
 $written_by =  $key .  :  . $val . br;
 if ($this-db-Record[firstName]) {
 $written_by .= stripslashes($this-db-Record[firstName]) .  ;
 }
 if($this-db-Record[lastName]) {
 $written_by .=  stripslashes($this-db-Record[lastName]);
 }
 }
 } else {
 
 if($this-db-Record[lastName]) {
 $written_by .=  stripslashes($this-db-Record[lastName]) . , ;
 }
 if ($this-db-Record[firstName]) {
 $written_by .= stripslashes($this-db-Record[firstName]);
 }
 }
 
 But this seems really awkward (at the best of times) and (worst of all) it
 
 isn't
 
 working.
 
 I've got another related problem in that I've set up the following fields
 
 in one
 
 table:
 firstName
 lastName
 organization
 
 and I need to be able to order them by a combination of lastName 
 
 organization.
 
   I could list the organization field simply as the lastName, but that
 
 seems
 
 like it would be confusing the data types...  Must be a way around this..
 
 I
 
 suspect it is limited by my logic  not PHP's.
 
 Any ideas would be appreciated.
 
 Mike
 

[PHP] $this-db-Record[WLPcountry.name]

2001-07-22 Thread Mike Gifford

Hello,

I'm using phplib to add functionality to my bibliography app.  However I'm not 
sure how to deal with selected data from different tables with the same field name.

The example I provided in the signature was:
$this-db-Record[WLPcountry.name]

Which needs to be differentiated from:
$this-db-Record[WLPpublisher.name]

Ive added the table name (WLPpublisher  WLPcountry) as a prefix assuming that 
this will carry over.  Seems to wrok in some instances but not others.

Any suggestions would be useful...

The table is as follows:

SELECT
WLPbib.bibID,
WLPbib.title,
WLPbib.publicationDate,
WLPbib.URL,
WLPpublisher.name,
WLPaddress.city,
WLPaddress.state,
WLPaddress.countryID,
WLPcountry.name,
WLPprofile.firstName,
WLPprofile.middleName,
WLPprofile.lastName,
WLPprofile.organization
FROM
WLPbib
LEFT JOIN WLPpublisher USING(publisherID),
WLPaddress
LEFT JOIN WLPcountry USING(countryID),
WLPprofile
LEFT JOIN WLPbib2profile USING(profileID)
WHERE
WLPpublisher.addressID = WLPaddress.addressID AND
WLPbib2profile.bibID = WLPbib.bibID

I'm making progress on this app.  Thanks to the assistance of a lot of good folks.

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] $this-db-Record[WLPcountry.name]

2001-07-22 Thread Mike Gifford

That did the trick Philip!  Thanks for your help.

Mike

Philip Murray wrote:

 - Original Message -
 From: Mike Gifford [EMAIL PROTECTED]
 
Hello,

I'm using phplib to add functionality to my bibliography app.  However I'm

 not
 
sure how to deal with selected data from different tables with the same

 field name.
 
The example I provided in the signature was:
$this-db-Record[WLPcountry.name]


   Which needs to be differentiated from:
 
$this-db-Record[WLPpublisher.name]

Any suggestions would be useful...


 
 You can use the AS keyword to rename the fields to whatever you want, for
 example:
 
  SELECT
  WLPbib.bibID,
  WLPbib.title,
  WLPbib.publicationDate,
  WLPbib.URL,
  WLPpublisher.name AS publisher_name,
  WLPaddress.city,
  WLPaddress.state,
  WLPaddress.countryID,
  WLPcountry.name AS country_name,
  WLPprofile.firstName,
  WLPprofile.middleName,
  WLPprofile.lastName,
  WLPprofile.organization
  FROM
  WLPbib
 
 
 So then, you'd have:
 
 $this-db-Record[country_name]
 
 and
 
 $this-db-Record[publisher_name]
 
 Hope this helps!
 
 Cheers
  -  -- -  -   -
 Philip Murray - [EMAIL PROTECTED]
 http://www.open2view.com - Open2View.com
 - -  -- -   -
 
 



-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] One2Many Logic Problem - phpMySQL bibliography

2001-07-22 Thread Mike Gifford

Hello,

I'm not sure if anyone else as the need for a php/MySQL based bibliography, but 
the application that I am developing (which is basically a module for phpSlash) 
is coming along fairly well.  If anyone is interested in seeing the code I can 
bundle it up and send it out to them (still a long way from finished mind).  The 
draft version of it is up and running here:
http://openconcept.ca/WLP/biblio/index.php3

I'm running into a couple problems though that I don't have the logic language 
for and I was hoping folks here could help me (as you have done in the past).

The problem is that I've set up a many to many table to ensure that I can have 
an author be listed as writing many books and a book be written by many authors.

However in listing the books as a bibliography (as the URL above), I want to be 
able to list multiple authors, and do so in a different format for the first 
author than for all subsequent ones.

I'm hoping to be able to produce output like this:
Young, D. and N. Dixon. Helping Leaders Take Effective Action: A Program 
Evaluation. Greensboro, North Carolina: Center for Creative Leadership,
1996.


So, I think the first challenge should be to calculate which books have multiple 
authors by doing something like this (It's using phplib structures, sorry):

$q2  = SELECT * FROM WLPbib2profile ORDER BY bibID;   
$this-db-query($q2);  // Performs above query
while ($this-db-next_record()) {
if ($this-db-Record[bibID] != $last_bibID) {
echo br . $this-db-Record[bibID] .  :  .  
$this-db-Record[profileID];
} else { // Multiple Authors
echo ,  .  $this-db-Record[profileID];
$multiple_profileID .= array ($this-db-Record[bibID] =
$this-db-Record[profileID]);
$multiple_profileID .= array($this-db-Record[bibID] =
yes);
}
$last_bibID = $this-db-Record[bibID];
}
}

With this I can then use the value $multiple_profileID to determine if this 
record has duplicates or not and use something like this to include both authors 
and not repeat the bibliography item:

if ($multiple_profileID[$bibID]==yes) {
while (list($key, $val) = each($multiple_profileID)) {
$written_by =  $key .  :  . $val . br;
if ($this-db-Record[firstName]) {
$written_by .= stripslashes($this-db-Record[firstName]) .  ;
}
if($this-db-Record[lastName]) {
$written_by .=  stripslashes($this-db-Record[lastName]);
}
}
} else {

if($this-db-Record[lastName]) {
$written_by .=  
stripslashes($this-db-Record[lastName]) . , ;
}
if ($this-db-Record[firstName]) {
$written_by .= 
stripslashes($this-db-Record[firstName]);
}
}

But this seems really awkward (at the best of times) and (worst of all) it isn't 
working.

I've got another related problem in that I've set up the following fields in one 
table:
firstName
lastName
organization

and I need to be able to order them by a combination of lastName  organization. 
  I could list the organization field simply as the lastName, but that seems 
like it would be confusing the data types...  Must be a way around this..  I 
suspect it is limited by my logic  not PHP's.

Any ideas would be appreciated.

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Adding to an array within while loop

2001-07-13 Thread Mike Gifford

Hello,

I'm trying to get around a database problem that I'm having in which multiple 
authors are producing (almost - the authors are listed as different) duplicate 
returns within a bibliography.

What I've done is query the database and produce a list of duplicates using 
something like this (this is written using phplib):

while ($this-db-next_record()) {
if ($this-db-Record[bibID] != $last_bibID) {
echo br . $this-db-Record[bibID] .  :  .  
$this-db-Record[profileID];
} else { // Multiple Authors
echo ,  .  $this-db-Record[profileID];
$multiple_profileID = array ($this-db-Record[bibID] = 
$this-db-Record[profileID]);
}
 $last_bibID = $this-db-Record[bibID];
}

Now this produces results like this:
1 : 1
2 : 2, 3
3 : 4
4 : 5
5 : 6, 7

where the first number corresponds to the book and the second the author(s).

If there are multiple authors I would like the values for bibID and profileID to 
be inserted into an array. This is outlined above.

I'd like to use something like this to produce the values of all of the authors 
(profileID) associated with the respective book.

if ($multiple_profileID[$this-db-Record[bibID]]) {
while (list($key, $val) = each($multiple_profileID)) {
echo   $key .  :  . $val . br;
}
}

I would hope that the result would be

2 : 2
2 : 3
5 : 6
5 : 7

I can then pull out the author's name using the profileID.

If someone has an idea of a better way to do this I'd be happy to hear it.

I can send code  tables for those who might be interested.

Thanks!

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Joining a number of tables in a MySQL query

2001-07-11 Thread Mike Gifford

Hello,

I'm trying to relate four tables within a single query and am running into 
difficulties.  Heck, I don't even know if it is possible.  Most of the 
explainations I see are for two tables, not four...

So I'm trying to do something like this:

SELECT  address.city,
address.state,
 bib.publisher,
 bib.title,
 bib.publicationDate,
 profile.firstName,
 profile.lastName,
 profile.organization,
 country.languageName
FROMWLPbib bib
JOIN ON  WLPprofile profile USING (profileID)
JOIN ON WLPaddress address USING (publisherID)
JOIN ON WLPcountry country USING (countryID)

I don't know how to express the following relationship in the query above:
   The tables WLPbib  WLPprofile share the value profileID
   WLPbib and WLPaddress share the value publisherID
   WLPaddress and WLPcountry share the value countryID

I also used JOIN ON, but didn't know if any of these others would be more 
appropriate:

Cross Join
select c.name, o.cid from orders o, clients c where o.cid = acm-042;

equijoin
select p.os, c.name from orders o, pcs p, clients c where p.pid=o.pid and o.pid 
= 1 and o.cid=c.cid;

non-equijoin
SELECT p.os, o.pid from orders o, pcs p where o.pid  p.pid;

Left Join
select * from orders left join pcs on orders.pid = pcs.pid;
select * from orders left join pcs on pcs.pid = 3 and orders.pid = pcs.pid;

Using Option
SELECT * from clients join on orders where clients.cid = orders.cid;
SELECT * from clients join on orders using (cid);
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Duplication Results When LEFT JOIN is Used Between Multiple Tables

2001-07-11 Thread Mike Gifford

Hello,

I'm making some headway on joining three MySQL tables.  (Thanks to responses 
from this list early this morning)

However, when I run this query:

mysql_query(SELECT
 WLPbib.bibID,
  WLPbib.title,
  WLPbib.publisher,
  WLPbib.publicationDate,
  WLPaddress.city,
  WLPaddress.state,
  WLPprofile.firstName,
  WLPprofile.lastName,
  WLPprofile.organization,
  WLPcountry.languageName
  FROM   WLPbib
  LEFT JOIN WLPprofile ON WLPprofile.profileID = WLPbib.profileID
  LEFT JOIN WLPaddress ON WLPaddress.publisherID = WLPbib.publisherID
  LEFT JOIN WLPcountry ON WLPcountry.countryID = WLPaddress.countryID);

I now get results in triplicate.  ie. I'm getting three copies of the same 
title, firstName, organization, etc

I somehow suspected that this should be the result with LEFT JOIN, but I'm not 
sure how to return a query without duplication.

This is far better than what I had this morning (which was no response from the 
server).

Thanks.  I'm new to joining tables...

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Duplication Results When LEFT JOIN is Used Between Multiple Tables

2001-07-11 Thread Mike Gifford

Hi Max,

Maxim Maletsky wrote:

 not to give you the solution, but there's something you can simplify in your
 query:
 USING(field)


I like the idea of using USING...  however I've run into some problems.


 mysql_query(SELECT
WLPbib.bibID,
   WLPbib.title,
   WLPbib.publisher,
   WLPbib.publicationDate,
   WLPaddress.city,
   WLPaddress.state,
   WLPprofile.firstName,
   WLPprofile.lastName,
   WLPprofile.organization,
   WLPcountry.languageName
   FROM WLPbib
   LEFT JOIN WLPprofile USING(profileID)
   LEFT JOIN WLPaddress USING(publisherID)
   LEFT JOIN WLPcountry USING(countryID));

 simplier, right?


Simpler yes, however it produces this error:
MySQL Error: 1054 (Unknown column 'WLPprofile.publisherID' in 'on clause')

Because although WLPbib is linked to WLPprofile  WLPaddress it is not linked to 
WLPcountry.  WLPaddress needs to be linked to WLPcountry.

How does one specify that?


 as of your problem, let me think, I had the same problem couple month ago.
 I'll look int omy codes.


I hear ya..  Somewhere, within which project lies the answer (likely)..  Now 
which one?  :)

Thanks for looking into it.

Mike


 -Original Message-
 From: Mike Gifford [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, July 12, 2001 1:04 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Duplication Results When LEFT JOIN is Used Between
 Multiple Tables
 
 
 Hello,
 
 I'm making some headway on joining three MySQL tables.  (Thanks to responses
 from this list early this morning)
 
 However, when I run this query:
 
 mysql_query(SELECT
WLPbib.bibID,
   WLPbib.title,
   WLPbib.publisher,
   WLPbib.publicationDate,
   WLPaddress.city,
   WLPaddress.state,
   WLPprofile.firstName,
   WLPprofile.lastName,
   WLPprofile.organization,
   WLPcountry.languageName
   FROM WLPbib
   LEFT JOIN WLPprofile ON WLPprofile.profileID = WLPbib.profileID
   LEFT JOIN WLPaddress ON WLPaddress.publisherID =
 WLPbib.publisherID
   LEFT JOIN WLPcountry ON WLPcountry.countryID =
 WLPaddress.countryID);
 
 I now get results in triplicate.  ie. I'm getting three copies of the same
 title, firstName, organization, etc
 
 I somehow suspected that this should be the result with LEFT JOIN, but I'm
 not
 sure how to return a query without duplication.
 
 This is far better than what I had this morning (which was no response from
 the
 server).
 
 Thanks.  I'm new to joining tables...
 
 Mike
 --
 Mike Gifford, OpenConcept Consulting, http://openconcept.ca
 Offering everything your organization needs for an effective web site.
 Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
 It is a miracle that curiosity survives formal education. - A Einstein
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 
 



-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Duplication Results When LEFT JOIN is Used Between MultipleTables

2001-07-11 Thread Mike Gifford

I added DISTINCT to the code (as per below):

Kamil Choma wrote:

 Mike Gifford wrote:
However, when I run this query:
mysql_query(SELECT DISTINCT
 WLPbib.bibID,
  WLPbib.title,
  WLPbib.publisher,
  WLPbib.publicationDate,
  WLPaddress.city,
  WLPaddress.state,
  WLPprofile.firstName,
  WLPprofile.lastName,
  WLPprofile.organization,
  WLPcountry.languageName
  FROM   WLPbib
  LEFT JOIN WLPprofile ON WLPprofile.profileID = WLPbib.profileID
  LEFT JOIN WLPaddress ON WLPaddress.publisherID = WLPbib.publisherID
  LEFT JOIN WLPcountry ON WLPcountry.countryID = WLPaddress.countryID);

I now get results in triplicate.  ie. I'm getting three copies of the same
title, firstName, organization, etc

 Maybe SLECT DISTINCT ... could help you.

However not everything needs to be distinct.  Just the bibID number actually.

The results this produces though are no different than without it.

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Bibliography Profiles Directory - Looking for Existing GPL Apps

2001-07-06 Thread Mike Gifford

Sorry for being so vague in my last message.

Let's say you want to hilight 100 people (say best atheletes, coders, what have 
you).  You want a brief profile of this person.  Name, location, languages, 
picture, areas of interest, etc..

Something so that you can get a sense of who these folks are.

Mike

Chris Anderson wrote:

 profiles?
 - Original Message -
 From: Mike Gifford [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, July 06, 2001 2:06 AM
 Subject: [PHP] Bibliography  Profiles Directory - Looking for Existing GPL
 Apps
 
 
 
Hello,

I'm looking to see if someone out there has already developed a php/mysql
bibilography.  I haven't been able to find one online.

I'm also looking for a profiles directory.  Rather vague definition here,

 sorry.
 
Ultimately it will be i18n compliant..

Mike
--
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


 



-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Creating Internationally Accessible Web Apps - i18n

2001-07-05 Thread Mike Gifford

Hello,

I'm posting here (rather than on i18n) because I was having problems with the 
other newsgroup (and well because I always get the best answers to my php 
questions by posting here).

I've got a couple web apps that I'd like to standardize so that they are more 
multilingual and was wondering if anyone has developed guidelines, etc for doing so.

I've had more experience with english/french sites than with arabic, manderin, 
and I'm not sure what issues are likely to arise.

Please let me know if there are any apps which are good models to base new apps 
on and if there are any standards which would be useful to mold existing apps into.

I'm also keen on knowing how folks have constructed MySQL tables to allow for 
multilingual content.

Thanks!

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Bibliography Profiles Directory - Looking for Existing GPL Apps

2001-07-05 Thread Mike Gifford

Hello,

I'm looking to see if someone out there has already developed a php/mysql 
bibilography.  I haven't been able to find one online.

I'm also looking for a profiles directory.  Rather vague definition here, sorry.

Ultimately it will be i18n compliant..

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Abolish Nuclear Weapons Now!: http://pgs.ca/petition/
It is a miracle that curiosity survives formal education. - A Einstein


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Inserting the date into MySQL via PHP

2001-05-23 Thread Mike Gifford

Hello,

This is a really simple (looking) problem, but I can't seem to find the solution 
in the documentation.  I want to insert today's date into a MySQL Date field.

My first attempt was to use the following:

$insert = mysql_query(insert into dbrss (Feed, Title, URL, Abstract, Old) 
VALUES ('$Feed','$Title','$URL',NOW(),',$db);

The relevant table was created with the following:

CREATE TABLE dbrss (
ID int(7) NOT NULL auto_increment,
Feed varchar(50) NOT NULL,
Title varchar(255) NOT NULL,
URL varchar(255) NOT NULL,
Abstract varchar(255),
superRSS varchar(50),
Type varchar(50),
Old date,
Source varchar(100),
SourceURL varchar(100),
PRIMARY KEY (ID)
);

I also tried to insert a date generated by:
$Date = date(Y-m-d);

using the following variation:

$insert = mysql_query(insert into dbrss (Feed, Title, URL, Abstract, Old) 
VALUES ('$Feed','$Title','$URL','$Date',',$db);

Any help would be appreciated.

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Featured Client: http://halifaxinitiative.org
A good life is one inspired by love and guided by knowledge - B. Russell


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Inserting the date into MySQL via PHP

2001-05-23 Thread Mike Gifford

Hello Michael,

You hit the nail on the head...  Not sure how I missed that...

In anycase, thank you.

Mike

[EMAIL PROTECTED] wrote:

 please forgive me if your typo concerns only your posting, but you didn't close your 
VALUES parenthesis.
 Then, the order of the data in the second parenthesis doesn't match that in the 
first one (which it has to).
 So the correct way to do it would be:
 
 $insert = mysql_query(insert into dbrss (Feed, Title, URL, Abstract, Old) VALUES 
 ('$Feed','$Title','$URL','$Abstract',NOW()),$db);
 
 Hope this helps.
 Greetings,
 Michael.
 
 
Hello,

This is a really simple (looking) problem, but I can't seem to find the solution 
in the documentation.  I want to insert today's date into a MySQL Date field.

My first attempt was to use the following:

$insert = mysql_query(insert into dbrss (Feed, Title, URL, Abstract, Old) 
VALUES ('$Feed','$Title','$URL',NOW(),',$db);

The relevant table was created with the following:

CREATE TABLE dbrss (
ID int(7) NOT NULL auto_increment,
Feed varchar(50) NOT NULL,
Title varchar(255) NOT NULL,
URL varchar(255) NOT NULL,
Abstract varchar(255),
superRSS varchar(50),
Type varchar(50),
Old date,
Source varchar(100),
SourceURL varchar(100),
PRIMARY KEY (ID)
);

I also tried to insert a date generated by:
$Date = date(Y-m-d);

using the following variation:

$insert = mysql_query(insert into dbrss (Feed, Title, URL, Abstract, Old) 
VALUES ('$Feed','$Title','$URL','$Date',',$db);

Any help would be appreciated.

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Featured Client: http://halifaxinitiative.org
A good life is one inspired by love and guided by knowledge - B. Russell


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

 
 
 #
 # Michael Heumann
 # SI Chile - Software e Informatica Limitada
 # Arlegui 440, Of. 403, Viña del Mar, Chile
 # Fonofax: (56)(32) 710833
 # Email: [EMAIL PROTECTED]
 # Web: http://www.softwareinformatica.cl
 #
 
 



-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Featured Client: http://halifaxinitiative.org
A good life is one inspired by love and guided by knowledge - B. Russell


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP XML Parsing

2001-05-22 Thread Mike Gifford

Hello Fabian,

This was very helpful.  Thanks for letting me know about this little glitch.

It almost resolves the problem that I was having.  Now I no longer get xml 
errors.  However, I'm not able to output the XML either.

Any suggestions would be appreciated.  The updated code is available here:
http://www.airdiv-cupe.org/portal/newsfeed_new_parser.php

And I've included the full script in the email (at the very bottom of this message).

Thanks.


Mike

Fabian Raygosa wrote:

 for xml you have to escape certain characters in the file, one is the
 ampersand ...
 - Original Message -
 From: Mike Gifford [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, May 18, 2001 12:24 PM
 Subject: [PHP] PHP  XML Parsing
 
 
 
 Hello,
 
 In looking for a good script to parse XML files I stumbled across the
 
 following
 
 tutorial (which looks very good):
 http://www.wirelessdevnet.com/channels/wap/features/xmlcast_php.html
 
 I have set this script up here:
 http://www.airdiv-cupe.org/portal/newsfeed_new_parser.php
 
 and I keep getting the following error (even after making a number of
 
 changes):
 
 XML error: not well-formed at line 16
 
 And I'm not sure how to troubleshoot this problem.
 
 I'm assuming that it is referring to line 16 on the XML file, in this
 
 case:
 
 http://cupe.ca/xml/cupenews.rdf
 
 My parsing definitions are as follows
$itemTitleKey = ^rdf^item^title;
$itemLinkKey = ^rdf^item^link;
$itemDescKey = ^rdf^item^description;
 
 Any help would be appreciated.
 
 Mike
 --
 Mike Gifford, OpenConcept Consulting, http://openconcept.ca
 Offering everything your organization needs for an effective web site.
 Featured Client: http://halifaxinitiative.org
 A good life is one inspired by love and guided by knowledge - B. Russell
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]

?php

class xitem {
   var $xTitle;
   var $xLink;
   var $xDescription;
  // function xitem() {
  // }
}

// general vars
$sTitle = Airline Division Newsfeeds;
$sLink = http://airdiv.cupe.ca/portal/;;
$sDescription = A Portal for the Airline Division of CUPE;
$arItems = array();
$itemCount = 0;

// * Start User-Defined Vars 
// rss url goes here
$uFile =http://cupe.ca/xml/cupenews.rdf;;
// descriptions (true or false) goes here
$bDesc = ; // If it exists this should be 'true'
// font goes here
$uFont = Verdana, Arial, Helvetica, sans-serif;
$uFontSize = 2;
// * End User-Defined Vars **

function startElement($parser, $name, $attrs) {
   global $curTag;   $curTag .= ^$name;
}

function endElement($parser, $name) {
   global $curTag;   $caret_pos = strrpos($curTag,'^');
   $curTag = substr($curTag,0,$caret_pos);
}

function characterData($parser, $data) {
global $curTag; // get the Channel information first
   global $sTitle, $sLink, $sDescription;
//  $titleKey = ^RSS^CHANNEL^TITLE;
//  $linkKey = ^RSS^CHANNEL^LINK;
//  $descKey = ^RSS^CHANNEL^DESCRIPTION;
   $titlekey = ^rdf:RDF^channel^title;
   $linkkey = ^rdf:RDF^channel^link;
   $desckey = ^rdf:RDF^channel^description;
   if ($curTag == $titleKey) {
 $sTitle = $data;
 echo  $sTitle;
   }
   elseif ($curTag == $linkKey) {
 $sLink = $data;
  echo  $sLink;
   }
   elseif ($curTag == $descKey) {
 $sDescription = $data;
   }   // now get the items
   global $arItems, $itemCount;
//  $itemTitleKey = ^RSS^CHANNEL^ITEM^TITLE;
//  $itemLinkKey = ^RSS^CHANNEL^ITEM^LINK;
//  $itemDescKey = ^RSS^CHANNEL^ITEM^DESCRIPTION;
   $itemtitlekey = ^rdf:RDF^item^title;
   $itemlinkkey = ^rdf:RDF^item^link;
   $itemdesckey = ^rdf:RDF^item^description;
if ($curTag == $itemTitleKey) {
 // make new xitem
 $arItems[$itemCount] = new xitem(); // set new item object's 
properties
 $arItems[$itemCount]-xTitle = $data;
 echo $data;
   }
   elseif ($curTag == $itemLinkKey) {
 $arItems[$itemCount]-xLink = $data;
 echo $data;
   }
   elseif ($curTag == $itemDescKey) {
 $arItems[$itemCount]-xDescription = $data;
 // increment item counter
 $itemCount++;
 echo $data;
   }

} // main loop

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, startElement, endElement);
xml_set_character_data_handler($xml_parser, characterData);
if (!($fp = fopen($uFile,r))) {
   die (could not open RSS for input);
}
while ($data = fread($fp, 4096)) {
$data=eregi_replace( , amp;,$data);
echo $data;
   if (!xml_parse($xml_parser, $data, feof($fp))) {
 die(sprintf(XML error: %s at line %d, 
xml_error_string(xml_get_error_code($xml_parser)), 
xml_get_current_line_number($xml_parser)));
   }
}
xml_parser_free($xml_parser); // write out the items
?
html
head
title?php echo ($sTitle); ?/title
meta name = description content = ?php echo ($sDescription); ?
/head
body bgcolor = #FF
font face = ?php

Re: [PHP] PHP XML Parsing

2001-05-22 Thread Mike Gifford

Hello Peter,

Peter Dudley wrote:

 The problem is in your link URL, where you pass CGI parameters.  When XML
 sees the  character, it assumes it's a special character thing such as
 amp; or quot;, so it's expecting a semicolon.

replacing it with amp; fixed the XML error.  Thanks!
 
 linkhttp://cupe.ca/news/cupenews/showitem.asp?ID=2823cl=1/link
 Just yesterday I discovered a program called XML Spy which you can get on a
 30-day eval from www.tucows.com.  This was what pointed out the error to me
 in your file.

Interesting..  So to be consistent with proper XML formatting, should the server 
hosting the XML file convert the  into amp; ?

 When I was using XSL last year for the first time, I had a devil of a time
 figuring out how to get URLs, particularly with query strings attached,
 through the XML parsers.  Try using the %codes in your URLs instead of  and
 other special characters; that should help, if I remember correctly.
 (Similarly, building HREF tags using XSL stylesheets seemed pretty awkward,
 but I'm sure I was missing some crucial tidbit of information.)

I certainly feel like I'm missing something...  Although I'm a bit at odds as to how 
to troubleshoot this new file.

I no longer get the errors, but I'm not getting the results I'm looking for either.

The updated script is running here:
http://www.airdiv-cupe.org/portal/newsfeed_new_parser.php

I've also attached the full script (since I've made some changes to it).

Any additional help would be appreciated.

Mike

 Mike Gifford [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 
 Hello,
 
 In looking for a good script to parse XML files I stumbled across the
 
 following
 
 tutorial (which looks very good):
 http://www.wirelessdevnet.com/channels/wap/features/xmlcast_php.html
 
 I have set this script up here:
 http://www.airdiv-cupe.org/portal/newsfeed_new_parser.php
 
 and I keep getting the following error (even after making a number of
 
 changes):
 
 XML error: not well-formed at line 16
 
 And I'm not sure how to troubleshoot this problem.
 
 I'm assuming that it is referring to line 16 on the XML file, in this
 
 case:
 
 http://cupe.ca/xml/cupenews.rdf
 
 My parsing definitions are as follows
$itemTitleKey = ^rdf^item^title;
$itemLinkKey = ^rdf^item^link;
$itemDescKey = ^rdf^item^description;
 
 Any help would be appreciated.
 
 Mike


?php

class xitem {
   var $xTitle;
   var $xLink;
   var $xDescription;
  // function xitem() {
  // }
}

// general vars
$sTitle = Airline Division Newsfeeds;
$sLink = http://airdiv.cupe.ca/portal/;;
$sDescription = A Portal for the Airline Division of CUPE;
$arItems = array();
$itemCount = 0;

// * Start User-Defined Vars 
// rss url goes here
$uFile =http://cupe.ca/xml/cupenews.rdf;;
// descriptions (true or false) goes here
$bDesc = ; // If it exists this should be 'true'
// font goes here
$uFont = Verdana, Arial, Helvetica, sans-serif;
$uFontSize = 2;
// * End User-Defined Vars **

function startElement($parser, $name, $attrs) {
   global $curTag;   $curTag .= ^$name;
}

function endElement($parser, $name) {
   global $curTag;   $caret_pos = strrpos($curTag,'^');
   $curTag = substr($curTag,0,$caret_pos);
}

function characterData($parser, $data) {
global $curTag; // get the Channel information first
   global $sTitle, $sLink, $sDescription;
//  $titleKey = ^RSS^CHANNEL^TITLE;
//  $linkKey = ^RSS^CHANNEL^LINK;
//  $descKey = ^RSS^CHANNEL^DESCRIPTION;
   $titlekey = ^rdf:RDF^channel^title;
   $linkkey = ^rdf:RDF^channel^link;
   $desckey = ^rdf:RDF^channel^description;
   if ($curTag == $titleKey) {
 $sTitle = $data;
 echo  $sTitle;
   }
   elseif ($curTag == $linkKey) {
 $sLink = $data;
  echo  $sLink;
   }
   elseif ($curTag == $descKey) {
 $sDescription = $data;
   }   // now get the items
   global $arItems, $itemCount;
//  $itemTitleKey = ^RSS^CHANNEL^ITEM^TITLE;
//  $itemLinkKey = ^RSS^CHANNEL^ITEM^LINK;
//  $itemDescKey = ^RSS^CHANNEL^ITEM^DESCRIPTION;
   $itemtitlekey = ^rdf:RDF^item^title;
   $itemlinkkey = ^rdf:RDF^item^link;
   $itemdesckey = ^rdf:RDF^item^description;
if ($curTag == $itemTitleKey) {
 // make new xitem
 $arItems[$itemCount] = new xitem(); // set new item object's 
properties
 $arItems[$itemCount]-xTitle = $data;
 echo $data;
   }
   elseif ($curTag == $itemLinkKey) {
 $arItems[$itemCount]-xLink = $data;
 echo $data;
   }
   elseif ($curTag == $itemDescKey) {
 $arItems[$itemCount]-xDescription = $data;
 // increment item counter
 $itemCount++;
 echo $data;
   }

} // main loop

$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, startElement, endElement);
xml_set_character_data_handler($xml_parser, characterData);
if (!($fp = fopen($uFile,r))) {
   die (could not open RSS for input);
}
while ($data = fread($fp, 4096)) {
$data=eregi_replace( , amp;,$data);
ec

[PHP] PHP XML Parsing

2001-05-18 Thread Mike Gifford

Hello,

In looking for a good script to parse XML files I stumbled across the following 
tutorial (which looks very good):
http://www.wirelessdevnet.com/channels/wap/features/xmlcast_php.html

I have set this script up here:
http://www.airdiv-cupe.org/portal/newsfeed_new_parser.php

and I keep getting the following error (even after making a number of changes):
XML error: not well-formed at line 16

And I'm not sure how to troubleshoot this problem.

I'm assuming that it is referring to line 16 on the XML file, in this case:
http://cupe.ca/xml/cupenews.rdf

My parsing definitions are as follows
   $itemTitleKey = ^rdf^item^title;
   $itemLinkKey = ^rdf^item^link;
   $itemDescKey = ^rdf^item^description;

Any help would be appreciated.

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Featured Client: http://halifaxinitiative.org
A good life is one inspired by love and guided by knowledge - B. Russell


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Managing Multiple Conditions in a MySQL Query

2001-05-02 Thread Mike Gifford

Thanks Tomasz,

I believe that this will work just fine!  :)

Mike

Tomasz Abramowicz wrote:

 ?
 
 echo pRecent Signatures\nbremUL;
 $query = SELECT FirstName,LastName,CityState FROM phPetition WHERE
 Public='yes' AND Verified='yes' ORDER BY ID DESC LIMIT 0,5;
 $result =  mysql_query( $query )
 or die(never expect your query to work: $query);
 
 while ( $row = mysql_fetch_array( $result ) ) {
 
 echo LI . stripslashes($row[FirstName]) .   .
 stripslashes($row[LastName]) .  from  . stripslashes($row[CityState]);
 
 }



-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Featured Client: http://rabble.ca - News For the Rest of Us!
Courage my friends, 'tis not too late to make a better world - T. Douglas


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Managing Multiple Conditions in a MySQL Query

2001-05-01 Thread Mike Gifford

Hello,

I'd like to verify two conditions are true in the results that I pull out of my 
MySQL database.  In this case I wanted Verified and Public both to be listed as 
'yes' in the DB before they were displayed. The code I tried to use is as follows:

?php
echo pRecent Signatures\nbremUL;
$individuals_query = mysql_query(SELECT FirstName,LastName,CityState FROM 
phPetition WHERE Public='yes',Verified='yes' ORDER BY ID DESC LIMIT 0,5);
while ($individuals_array = mysql_fetch_array($individuals_query)) {
echo LI . stripslashes($individuals_array[FirstName]) .   . 
stripslashes($individuals_array[LastName]) .  from  . 
stripslashes($individuals_array[CityState]);
}

However, it gave me the following error:

Warning: Supplied argument is not a valid MySQL result resource in 
/usr/local/rabble/petition/index.php3 on line 89

How do I get around this?

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Featured Client: http://rabble.ca - News For the Rest of Us!
Courage my friends, 'tis not too late to make a better world - T. Douglas


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Win Apache/PHP config triping up virtual directory

2001-04-27 Thread Mike Gifford

Hello,

I have been working to develop the Back-end CMS on Sourceforge:
https://sourceforge.net/projects/back-end/

I'm running into a bit of a difficulty though folks trying to run the 
code in a windows environment.

To get around the problem with search engines tripping over the ?'s the 
latest code is now using virtual directories to pass the category and 
article ID.  It looks better and provides a shorter URL as well!

Unfortunately, it is harder for folks to understand.  Especially when 
they are trying to install this at home on a local windows machine 
rather than on a linux server

I suspect that either Apache or PHP hasn't been configured correctly as 
this works on the windows servers:
http://127.0.0.1/main_file.php?/Articles/4/
but this does not:
http://127.0.0.1/main_file.php/Articles/4/

The latter has no problems like this on a number of other servers.

I set up this test script to output the various variables that would be 
called on in this script:
http://www.openconcept.on.ca/htdocs/main_file_test.php/Articles/4

In the servers that are providing the errors, neither the Category 
variables or the Article ID's show up.

Does anyone have any suggestions?

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Featured Client: http://rabble.ca - News For the Rest of Us!
If a book doesn't make us better, then what on earth is it for? - Alice 
Walker


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Building an array from a URL

2001-04-05 Thread Mike Gifford

Hi Joe,

this would be useful if I wanted to write to a URL, but I need to read from it. 
Perhaps I wasn't clear in this.

Mike

Joe Stump wrote:
 Ok - say you have this:
 $foo = array(
 0 = 'joe',
 1 = 'stump',
 2 = 'there');
 
 while(list($key,$val) = each($foo))
   $args[] = 'array['.$key.']='.$val;
 
 $url = 'http://www.server.com/script.html';
 $url .= '?'.implode('',$args);
 
 header("Location: $url");
 exit;
 
 That has worked for me before and will most likely work again.
 
 --Joe
 
 On Wed, Apr 04, 2001 at 09:42:20PM -0400, Mike Gifford wrote:
  Hi Joe,
 
  I don't doubt that at all..  However, my strings aren now looking like this.
 
  
http://openconcept.ca/rabble/superRSS.phtml?Title%5B1000%5D=RBC+Dominion+Securities+investigates+URL%5B1000%5D=http%3A%2F%2Fcbc.ca%2Fcgi-bin%2Ftemplates%2Fview.cgi%3F%2Fnews%2F2001%2F04%2F04%2Frbcds_010404Abstract%5B1000%5D=RBC+Dominion+Securities+said+Wednesday+morning+it+is+launching+an++investigation+of+some+suspicious+trading.+%0D%0ATitle%5B1184%5D=Indigenous+Peoples+Critical+of+The+Human+Genome+ProjectURL%5B1184%5D=http%3A%2F%2Fwww.wtowatch.org%2Fwtowatch%2Fnews%2Findex.cfm%3FID%3D2113Abstract%5B1184%5D=aanew_superRSS=new_superRSS
 
  I've got the $Title[1000]=, but it looks like Title%5B1000%5D=
 
  Also, I'm having trouble extracting arrays from arrays..  I just want to insert
  the new values (for articleID 1000, etc.) into a table..
 
  Any suggestions?
 
  Mike
 
  Joe Stump wrote:
   It works for me in production.
  
   On Wed, Apr 04, 2001 at 08:56:53PM -0400, Mike Gifford wrote:
I tried this, but it converted [ and ] to url friendly codes.  Does this still
work?
   
Mike
   
Joe Stump wrote:
 FYI you can send data like this on the url:

 
http://www.foo.com/script.php?test[joe]=stumptest[harry]=bartest[jane]=scott

 Then $test will be an array that translates to this in PHP:

 ?

   $test = array(
 joe = 'stump',
 harry = 'bar',
 jane = 'scott');

 ?

 --Joe

 On Wed, Apr 04, 2001 at 12:00:48PM -0400, Mike Gifford wrote:
  Hello,
 
  I'm trying to build an array out of data submitted from a URL.
 
  Essentially, I want to pull certain records out of a database which have 
been
  selected on another form.
 
  The URL presently looks like this:

superRSS.phtml?150=1150superRSS166=1166superRSS168=1168superRSS175=1188
 
  I'd like to take these independent variables and merge them into a single 
array:
$array_superRSS = implode (":", $superRSS[]);
 
  So I can then pipe these values directly into another function:
 
  while ($array_superRSS) {
display_superRSS($array_superRSS[]);
  }
 
  Obviously I'm missing a step or two here, but would really appreciate 
someone
  filling in some of the gaps.
 
  Thanks!
 
  Mike
  --
  Mike Gifford, OpenConcept Consulting, http://openconcept.ca
  Offering everything your organization needs for an effective web site.
  Featured Client: http://www.aboriginalrightscoalition.ca/
  If a book doesn't make us better, then what on earth is it for? - Alice 
Walker
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]

 
/**\
  *Joe Stump - PHP/SQL/HTML Developer 
 *
  * http://www.care2.com - http://www.miester.org - http://gtk.php-coder.net  
 *
  * "Better to double your money on mediocrity than lose it all on a dream."  
 *
 
\******/
   
--
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Featured Client: http://www.aboriginalrightscoalition.ca/
If a book doesn't make us better, then what on earth is it for? - Alice Walker
  
   /**\
*Joe Stump - PHP/SQL/HTML Developer  *
* http://www.care2.com - http://www.miester.org - http://gtk.php-coder.net   *
* "Better to double your money on mediocrity than lose it all on a dream."   *
   \******/
 
  --
  Mike Gifford, OpenConcept Consulting, http://openconcept.ca
  Offering everything your organization needs for an effective web site.
  Featured Client: http://www.aboriginalrigh

[PHP] Building an array from a URL

2001-04-04 Thread Mike Gifford

Hello,

I'm trying to build an array out of data submitted from a URL.  

Essentially, I want to pull certain records out of a database which have been
selected on another form.  

The URL presently looks like this:
superRSS.phtml?150=1150superRSS166=1166superRSS168=1168superRSS175=1188

I'd like to take these independent variables and merge them into a single array:
$array_superRSS = implode (":", $superRSS[]);

So I can then pipe these values directly into another function:

while ($array_superRSS) {
display_superRSS($array_superRSS[]);
}

Obviously I'm missing a step or two here, but would really appreciate someone
filling in some of the gaps.

Thanks!

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Featured Client: http://www.aboriginalrightscoalition.ca/
If a book doesn't make us better, then what on earth is it for? - Alice Walker

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Building an array from a URL

2001-04-04 Thread Mike Gifford

I tried this, but it converted [ and ] to url friendly codes.  Does this still
work?

Mike

Joe Stump wrote:
 FYI you can send data like this on the url:
 
 http://www.foo.com/script.php?test[joe]=stumptest[harry]=bartest[jane]=scott
 
 Then $test will be an array that translates to this in PHP:
 
 ?
 
   $test = array(
 joe = 'stump',
 harry = 'bar',
 jane = 'scott');
 
 ?
 
 --Joe
 
 On Wed, Apr 04, 2001 at 12:00:48PM -0400, Mike Gifford wrote:
  Hello,
 
  I'm trying to build an array out of data submitted from a URL.
 
  Essentially, I want to pull certain records out of a database which have been
  selected on another form.
 
  The URL presently looks like this:
superRSS.phtml?150=1150superRSS166=1166superRSS168=1168superRSS175=1188
 
  I'd like to take these independent variables and merge them into a single array:
$array_superRSS = implode (":", $superRSS[]);
 
  So I can then pipe these values directly into another function:
 
  while ($array_superRSS) {
display_superRSS($array_superRSS[]);
  }
 
  Obviously I'm missing a step or two here, but would really appreciate someone
  filling in some of the gaps.
 
  Thanks!
 
  Mike
  --
  Mike Gifford, OpenConcept Consulting, http://openconcept.ca
  Offering everything your organization needs for an effective web site.
  Featured Client: http://www.aboriginalrightscoalition.ca/
  If a book doesn't make us better, then what on earth is it for? - Alice Walker
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 /**\
  *Joe Stump - PHP/SQL/HTML Developer  *
  * http://www.care2.com - http://www.miester.org - http://gtk.php-coder.net   *
  * "Better to double your money on mediocrity than lose it all on a dream."   *
 \******/

-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Featured Client: http://www.aboriginalrightscoalition.ca/
If a book doesn't make us better, then what on earth is it for? - Alice Walker

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Building an array from a URL

2001-04-04 Thread Mike Gifford

Hi Joe,

I don't doubt that at all..  However, my strings aren now looking like this.

http://openconcept.ca/rabble/superRSS.phtml?Title%5B1000%5D=RBC+Dominion+Securities+investigates+URL%5B1000%5D=http%3A%2F%2Fcbc.ca%2Fcgi-bin%2Ftemplates%2Fview.cgi%3F%2Fnews%2F2001%2F04%2F04%2Frbcds_010404Abstract%5B1000%5D=RBC+Dominion+Securities+said+Wednesday+morning+it+is+launching+an++investigation+of+some+suspicious+trading.+%0D%0ATitle%5B1184%5D=Indigenous+Peoples+Critical+of+The+Human+Genome+ProjectURL%5B1184%5D=http%3A%2F%2Fwww.wtowatch.org%2Fwtowatch%2Fnews%2Findex.cfm%3FID%3D2113Abstract%5B1184%5D=aanew_superRSS=new_superRSS

I've got the $Title[1000]=, but it looks like Title%5B1000%5D=

Also, I'm having trouble extracting arrays from arrays..  I just want to insert
the new values (for articleID 1000, etc.) into a table..

Any suggestions?

Mike

Joe Stump wrote:
 It works for me in production.
 
 On Wed, Apr 04, 2001 at 08:56:53PM -0400, Mike Gifford wrote:
  I tried this, but it converted [ and ] to url friendly codes.  Does this still
  work?
 
  Mike
 
  Joe Stump wrote:
   FYI you can send data like this on the url:
  
   http://www.foo.com/script.php?test[joe]=stumptest[harry]=bartest[jane]=scott
  
   Then $test will be an array that translates to this in PHP:
  
   ?
  
 $test = array(
   joe = 'stump',
   harry = 'bar',
   jane = 'scott');
  
   ?
  
   --Joe
  
   On Wed, Apr 04, 2001 at 12:00:48PM -0400, Mike Gifford wrote:
Hello,
   
I'm trying to build an array out of data submitted from a URL.
   
Essentially, I want to pull certain records out of a database which have been
selected on another form.
   
The URL presently looks like this:
  
superRSS.phtml?150=1150superRSS166=1166superRSS168=1168superRSS175=1188
   
I'd like to take these independent variables and merge them into a single 
array:
  $array_superRSS = implode (":", $superRSS[]);
   
So I can then pipe these values directly into another function:
   
while ($array_superRSS) {
  display_superRSS($array_superRSS[]);
}
   
Obviously I'm missing a step or two here, but would really appreciate someone
filling in some of the gaps.
   
Thanks!
   
Mike
    --
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Featured Client: http://www.aboriginalrightscoalition.ca/
If a book doesn't make us better, then what on earth is it for? - Alice Walker
   
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]
  
   /**\
*Joe Stump - PHP/SQL/HTML Developer  *
* http://www.care2.com - http://www.miester.org - http://gtk.php-coder.net   *
* "Better to double your money on mediocrity than lose it all on a dream."   *
   \**/
 
  --
  Mike Gifford, OpenConcept Consulting, http://openconcept.ca
  Offering everything your organization needs for an effective web site.
  Featured Client: http://www.aboriginalrightscoalition.ca/
  If a book doesn't make us better, then what on earth is it for? - Alice Walker
 
 /**\
  *Joe Stump - PHP/SQL/HTML Developer  *
  * http://www.care2.com - http://www.miester.org - http://gtk.php-coder.net   *
  * "Better to double your money on mediocrity than lose it all on a dream."   *
 \**********/

-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Featured Client: http://www.aboriginalrightscoalition.ca/
If a book doesn't make us better, then what on earth is it for? - Alice Walker

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Building an array from a URL

2001-04-04 Thread Mike Gifford

Hell Knut,

"Knut H. Hassel Nielsen" wrote:
 Did you try to see if $HTTP_GET_VARS can help you ?

It's useful for pulling down the URL variables into an array, however I'd now
like to go to the next step of pulling out data of an array of arrays...

All of the files here are in a database.  
http://openconcept.ca/rabble/newsfeeds.phtml

Select a number of them and it brings you here:
http://openconcept.ca/rabble/superRSS.phtml?superRSS173=1170superRSS177=1189

Pulls in the right data and everything.

However, I'd now like to write this data to a database (after making minor
adjustments):

http://openconcept.ca/rabble/superRSS.phtml?Title%5B1170%5D=ANTI-FTAA+TOUR+TO+THE+NORTHEASTERN+UNITED+STATESURL%5B1170%5D=http%3A%2F%2FProtest.Net%2Fview.cgi%3Fview%3D2052Abstract%5B1170%5D=ddTitle%5B1189%5D=Rich+World%27s+Trade+Ministers+Discuss+New+Trade+RoundURL%5B1189%5D=http%3A%2F%2Fwww.wtowatch.org%2Fwtowatch%2Fnews%2Findex.cfm%3FID%3D2108Abstract%5B1189%5D=ddnew_superRSS=new_superRSS

However I now have an array of arrays to seperate and it doesn't seem to be
working like the first one did.

 Its an array of every variable posted by GET (the way you described)

It was a GET  not POST indeed.
 
 Else :
 Split the different key/values with the delimiter '' and thereafter split the
 elements in the array by '='

How do I pull in this data if not as an array?

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Featured Client: http://www.aboriginalrightscoalition.ca/
If a book doesn't make us better, then what on earth is it for? - Alice Walker

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Parsing XML CDF format in PHP3 - Stumbling over ?

2001-03-29 Thread Mike Gifford

Hello,

For some reason I am now having real difficulties removing and parsing some XML
files.  I think that if I can just strip out the ?  ? that I should be able
to parse the XML (.CDF) file.  This should do it:
$pagetext = eregi_replace('?','',$pagetext);
$pagetext = eregi_replace('?','',$pagetext);

I've attached the whole CDF file at the bottom of this message.  However, I
think that the following should strip out the offending part as well:
$pagetext = eregi_replace('.*/TITLE','',$pagetext);

Unfortunately, for some reason it just isn't working for me.  I have other
scripts working just fine using similar code (on the same page).  However, this
just isn't working for me today.  

Any suggestions on what I'm overlooking would be great.

Mike

?xml version="1.0"?
CHANNEL HREF="http://cbc.ca/business/"
TITLE CBC News /TITLE
ITEM
HREF="http://cbc.ca/cgi-bin/templates/view.cgi?/news/2001/03/29/stocksopen_010329"
 TITLETSE at lowest close in 16 months/TITLE
 ABSTRACT
More negative news from the technology sector helped drive the TSE 300  to its
lowest close in 16 months Thursday. And the tech-heavy Nasdaq  closed at its
lowest level since November 1998. 
 /ABSTRACT
/ITEM
ITEM
HREF="http://cbc.ca/cgi-bin/templates/view.cgi?/news/2001/03/29/OSCfakescam_010329"
 TITLEOSC sets up fake Web site to show online investing dangers /TITLE
 ABSTRACT
A phoney Internet site that promised investors high returns with low  risk drew
thousands of visitors during an investigation run by the  Ontario Securities
Commission. 
 /ABSTRACT
/ITEM
ITEM
HREF="http://cbc.ca/cgi-bin/templates/view.cgi?/news/2001/03/28/cdnx010328"
 TITLECanadian Venture Exchange approves TSE takeover plan/TITLE
 ABSTRACT
The boards of directors of both the Toronto Stock Exchange and the  Canadian
Venture Exchange (CDNX) have both voted in principle to approve  the takeover of
the CDNX by the TSE. 
 /ABSTRACT
/ITEM
/CHANNEL

-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Featured Client: http://www.aboriginalrightscoalition.ca/
If a book doesn't make us better, then what on earth is it for? - Alice Walker

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Email validation

2001-03-20 Thread Mike Gifford

Hello Again,

Can anyone tell me what the best form of Email validation there is?  It needs to
be quick  as open to - and . as possible.

I've seen the following:

?
if (eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$",
$Email)) {
$error = 1;
$error_html .= "This email address is invalid: " . $Email;
echo  $error_html;
}
?


But this one looks quite impressive too:

?
   function checkaddress($mail) {
   if ( !ereg( "^([0-9,a-z,A-Z]+) ([.,_]
([0-9,a-z,A-Z]+))*[@] ([0-9,a-z,A-Z]+)([.,_,-]([0-9,a-z,A-Z]
   +))*[.]([0-9,a-z,A-Z]){2}([0-9,a-z,A-Z])?$", $mail ) ) {
   return false;
   }
   else
   {
   return true;
   }
   } 
?

Not sure which is the best.

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Latest Featured Site: http://www.lornenystrom.org/
No problem can be solved with the same thinking that created it - A.Einstein

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP/MySQL Control Structures - if (mysql_query())

2001-03-20 Thread Mike Gifford

Hi David,

I counted the number of rows using mysql_numrows(), but I've been told that
count() is way faster.  Unfortunately, I can't seem to get count working..  Any
ideas?

?php 
echo mysql_numrows(mysql_query("select * FROM phPetition",$db)); 

// This should be faster, but doesn't seem to work
// echo count(mysql_query("select * FROM phPetition",$db)); 
?

David Robley wrote:
 $same_Email_query is a pointer to a result set from the query and will
 always be true if the query succeeded - where succeeded means something
 like 'returned 0 or more matching rows'
 What you need to do is check how many matching rows are returned by your
 query; if there are zero rows, the value doesn't exist in the database.

Great advice.  This worked, therefore eliminating duplicates:

$same_Email_query = mysql_numrows(mysql_query("SELECT Email FROM phPetition
WHERE Email='" . $Email  . "'"));
if($same_Email_query!=0){
  $error = 1;
  $error_html .= "This email \"" . $Email . "\" has already been used to sign
the petition.brbr\n";
}   

 Shouldn't $individuals_array[ be $sameIP_array[ ? Consider using extract;
 if nothing else it makes code easier to read :-)

This was a neat little solution with the extract code.  I found that it started
to mess up my existing scripts so I threw it in a function to keep the variables
from getting mixed up.

?
function recent_signatures () {
$individuals_query = mysql_query("SELECT * FROM phPetition ORDER BY ID DESC
LIMIT 0,5");
while ($individuals_array = mysql_fetch_array($individuals_query)) {
echo "LI" . stripslashes($individuals_array["FirstName"]) . " " .
stripslashes($individuals_array["LastName"]) . " from " .
stripslashes($individuals_array["CityState"]);
$last_email=$individuals_array["Email"];
}

$sameIP_query = mysql_query("SELECT FirstName,LastName,CityState,IPAddress FROM
phPetition WHERE IPAddress='" . getenv('REMOTE_ADDR')  . "' ORDER BY LastName");
  
  if (mysql_numrows($sameIP_query) != 0) {
  
  echo "pThe following individuals have signed this petition from the same IP:
" . getenv('REMOTE_ADDR') . "br";
while ($sameIP_array = mysql_fetch_array($sameIP_query)) {
extract ($sameIP_array);
echo "LI" . stripslashes($FirstName) . " " . stripslashes($LastName) . "
from " . stripslashes($CityState);
// echo "LI" . stripslashes($sameIP_array["FirstName"]) . " " .
stripslashes($sameIP_array["LastName"]) . " from " .
stripslashes($sameIP_array["CityState"]);
  }
}
}
recent_signatures ();
?


Thanks Again.

Mike
-- 
Mike Gifford, OpenConcept Consulting, http://openconcept.ca
Offering everything your organization needs for an effective web site.
Latest Featured Site: http://www.lornenystrom.org/
No problem can be solved with the same thinking that created it - A.Einstein

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]