php-general Digest 21 May 2006 11:59:47 -0000 Issue 4140

Topics (messages 236559 through 236569):

Re: Captcha v1.0 (http://www.php.meezerk.com/index.php?page=captcha)
        236559 by: chris smith
        236563 by: Beauford
        236564 by: chris smith

Date() finding yesterday
        236560 by: John Taylor-Johnston
        236562 by: Rabin Vincent

Beta3 of PHPEditIni now available
        236561 by: Jeremy O'Connor

selecting current month from a database
        236565 by: Paul Goepfert
        236567 by: Paul Novitski

Uploading Files
        236566 by: P. Guethlein
        236568 by: Rabin Vincent

IP to country DB and script
        236569 by: Ryan A

Administrivia:

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

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

To post to the list, e-mail:
        php-general@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
On 5/21/06, Beauford <[EMAIL PROTECTED]> wrote:
Hi,

I am trying to get a program, Captcha v1.0, working and not having much
luck. The program says I need PHP version 4.3.10 or later or PHP version 5
and GD Library version 2.0 or later with JPEG support.

I know I have PHP 5, but not sure about the GD Library. I was reading on one
page I was on that this is built in to PHP, but at this point I'm lost. When
I try to compile the latest version on my Slackware box I get nothing but
errors.

Any help would be appreciated.

Help with which bit?

gd - create a phpinfo page and it will show you the version if gd is available.

compile issues  - can't help without seeing the errors.

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

--- End Message ---
--- Begin Message ---
 
The following are the errors I am getting - quite lengthy.

Thanks


$ make
make  all-recursive
make[1]: Entering directory `/home/beauford/gd-2.0.33'
Making all in config
make[2]: Entering directory `/home/beauford/gd-2.0.33/config'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/beauford/gd-2.0.33/config'
Making all in test
make[2]: Entering directory `/home/beauford/gd-2.0.33/test'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/beauford/gd-2.0.33/test'
make[2]: Entering directory `/home/beauford/gd-2.0.33'
if /bin/sh ./libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.
-I/usr/include/freetype2   -g -O2 -MT gdft.lo -MD -MP -MF ".deps/gdft.Tpo"
-c -o gdft.lo gdft.c; \
then mv -f ".deps/gdft.Tpo" ".deps/gdft.Plo"; else rm -f ".deps/gdft.Tpo";
exit 1; fi
mkdir .libs
gcc -DHAVE_CONFIG_H -I. -I. -I. -I/usr/include/freetype2 -g -O2 -MT gdft.lo
-MD -MP -MF .deps/gdft.Tpo -c gdft.c  -fPIC -DPIC -o .libs/gdft.lo
gdft.c:1366:35: fontconfig/fontconfig.h: No such file or directory
gdft.c:1429: error: parse error before '*' token
gdft.c:1429: error: parse error before '*' token
gdft.c: In function `find_font':
gdft.c:1431: error: `FcResult' undeclared (first use in this function)
gdft.c:1431: error: (Each undeclared identifier is reported only once
gdft.c:1431: error: for each function it appears in.)
gdft.c:1431: error: parse error before "result"
gdft.c:1433: error: `pattern' undeclared (first use in this function)
gdft.c:1433: error: `FcMatchPattern' undeclared (first use in this function)
gdft.c:1434: error: `FcMatchFont' undeclared (first use in this function)
gdft.c:1437: error: `result' undeclared (first use in this function)
gdft.c:1437: warning: return makes pointer from integer without a cast
gdft.c: At top level:
gdft.c:1442: error: parse error before '*' token
gdft.c: In function `find_postscript_font':
gdft.c:1444: error: `FcPattern' undeclared (first use in this function)
gdft.c:1444: error: `font' undeclared (first use in this function)
gdft.c:1447: error: `fontpattern' undeclared (first use in this function)
gdft.c:1449: error: `fontname' undeclared (first use in this function)
gdft.c:1450: error: `FcChar8' undeclared (first use in this function)
gdft.c:1450: error: `family' undeclared (first use in this function)
gdft.c:1452: error: `pattern' undeclared (first use in this function)
gdft.c:1454: error: `FC_FAMILY' undeclared (first use in this function)
gdft.c:1454: error: `FcTypeString' undeclared (first use in this function)
gdft.c:1455: error: `FC_STYLE' undeclared (first use in this function)
gdft.c:1460: error: `FcResultMatch' undeclared (first use in this function)
gdft.c: In function `font_pattern':
gdft.c:1479: error: `FcPattern' undeclared (first use in this function)
gdft.c:1479: error: `font' undeclared (first use in this function)
gdft.c:1480: error: `FcChar8' undeclared (first use in this function)
gdft.c:1480: error: `file' undeclared (first use in this function)
gdft.c:1481: error: `pattern' undeclared (first use in this function)
gdft.c:1494: error: parse error before "FcChar8"
gdft.c:1501: error: `FC_FILE' undeclared (first use in this function)
gdft.c:1501: error: `FcResultMatch' undeclared (first use in this function)
make[2]: *** [gdft.lo] Error 1
make[2]: Leaving directory `/home/beauford/gd-2.0.33'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/beauford/gd-2.0.33'
make: *** [all] Error 2



-----Original Message-----
From: chris smith [mailto:[EMAIL PROTECTED] 
Sent: May 20, 2006 9:29 PM
To: Beauford
Cc: php-general@lists.php.net
Subject: Re: [PHP] Captcha v1.0
(http://www.php.meezerk.com/index.php?page=captcha)

On 5/21/06, Beauford <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am trying to get a program, Captcha v1.0, working and not having 
> much luck. The program says I need PHP version 4.3.10 or later or PHP 
> version 5 and GD Library version 2.0 or later with JPEG support.
>
> I know I have PHP 5, but not sure about the GD Library. I was reading 
> on one page I was on that this is built in to PHP, but at this point 
> I'm lost. When I try to compile the latest version on my Slackware box 
> I get nothing but errors.
>
> Any help would be appreciated.

Help with which bit?

gd - create a phpinfo page and it will show you the version if gd is
available.

compile issues  - can't help without seeing the errors.

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

--- End Message ---
--- Begin Message ---
On 5/21/06, Beauford <[EMAIL PROTECTED]> wrote:

The following are the errors I am getting - quite lengthy.

Thanks


$ make

....

gcc -DHAVE_CONFIG_H -I. -I. -I. -I/usr/include/freetype2 -g -O2 -MT gdft.lo
-MD -MP -MF .deps/gdft.Tpo -c gdft.c  -fPIC -DPIC -o .libs/gdft.lo
gdft.c:1366:35: fontconfig/fontconfig.h: No such file or directory

You're missing a devel package. Don't know where that one comes from
'coz I don't know what configure switches you are using.

If it's freetype for example, you need the freetype-dev or
freetype-devel package to compile against.

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

--- End Message ---
--- Begin Message ---
I cannot seem to get this right. How can I produce yesterday?

$today = date("Y-m-d");
$yesterday = date("Y-m-") . date("d")-1;
$yesterday = date("Y-m-d")-1;
$yesterday = date("Y-m-"."d"-1);

I've been looking at the manual :) ...

Thanks,
John

--- End Message ---
--- Begin Message ---
On 5/21/06, John Taylor-Johnston
<[EMAIL PROTECTED]> wrote:
I cannot seem to get this right. How can I produce yesterday?

$today = date("Y-m-d");
$yesterday = date("Y-m-") . date("d")-1;
$yesterday = date("Y-m-d")-1;
$yesterday = date("Y-m-"."d"-1);

I've been looking at the manual :) ...

Use php.net/strtotime:

$yesterday = date('Y-m-d', strtotime('-1 day'));

Rabin

--
http://rab.in

--- End Message ---
--- Begin Message ---
The latest version of PHPEditIni is now available (Beta3). If fixes a bug in
Linux/*nix. Use this script to edit
your PHP.INI files in a browser based GUI. Visit http://phpeditini.net .

--
The PHP EditIni Project
[EMAIL PROTECTED]

--- End Message ---
--- Begin Message ---
Hi all,

I know this might be trivial problem but I can't seem to figure it
out.  Here is my problem I have a drop down menu where I have the
months of year as menu items.  I want to be able to have the current
month be the selected month.  I have tried using the date function as
the way to set the current month as the selected value but it seems
that every value entered in the select box is set to selected.

Here is my code maybe someone can help me out

$month_query = mysql_query("SELECT m_id, months FROM Month");
        while ($r = mysql_fetch_array($month_query))
        {
                $v = $r["m_id"];
                $out = $r["months"];  
                echo("<option  selected=" . date("F") . 
"value=$v>$out</option>\n");
        }

Just incase you want to know

m_id = 1..12
months = January..December

How do I set only the current month to selected ?

Thanks,
Paul

--- End Message ---
--- Begin Message ---
At 11:45 PM 5/20/2006, Paul Goepfert wrote:
I have a drop down menu where I have the
months of year as menu items.  I want to be able to have the current
month be the selected month.  I have tried using the date function as
the way to set the current month as the selected value but it seems
that every value entered in the select box is set to selected.

Here is my code maybe someone can help me out

$month_query = mysql_query("SELECT m_id, months FROM Month");
        while ($r = mysql_fetch_array($month_query))
        {
                $v = $r["m_id"];
                $out = $r["months"];
echo("<option selected=" . date("F") . "value=$v>$out</option>\n");
        }

Just incase you want to know

m_id = 1..12
months = January..December

How do I set only the current month to selected ?


Paul,

The syntax for pre-selected options is:

HTML:  <option selected>            [1]
XHTML: <option selected="selected"> [2]

Options that are not pre-selected simply omit the selected attribute altogether.

Therefore you'll want code something like this:

        while ($r = mysql_fetch_array($month_query))
        {
                $v = $r["m_id"];        // numeric month
                $out = $r["months"];    // verbal month

                        // select option for current month
                        if ($v == date("n"))
                        {
                                $selected = 'selected="selected"';
                        }else{
                                $selected = '';
                        }

                echo "<option $selected value="$v">$out</option>\n";
        }

Notes:

- date("F") is the verbal month; date("n") is numeric [3]. Therefore you'll want to compare $v with date("n") or $out with date("F").

- Adhering to XHTML syntax, I've put the attribute values in quotes. [2]

- FYI, you can harmlessly include parentheses in the echo statement but echo is actually not a function and doesn't require parens [4].

Regards,
Paul
________________________

[1]
W3C HTML 4.01 Specification
17 Forms
17.6.1 Pre-selected options
http://www.w3.org/TR/html4/interact/forms.html#h-17.6.1

[2]
XHTML™ 1.0 The Extensible HyperText Markup Language (Second Edition)
4. Differences with HTML 4
4.4. Attribute values must always be quoted
http://www.w3.org/TR/xhtml1/#h-4.4

[3]
PHP Manual
VI. Function Reference
CLI. String Functions
echo
http://php.net/echo

[4]
PHP Manual
VI. Function Reference
XXII. Date and Time Functions
date
http://php.net/date

--- End Message ---
--- Begin Message --- I'm at one of those frustration levels.... can't seem to get a script working that will post and upload a file to the server. I"m working with the below. Can you help?

<?php
  $numoffile = 1;

  $file_dir  = "d:/upload/";
  if ($_FILES['myfiles']) {
  print_r ($_FILES);
    for ($i=0;$i<$numoffile;$i++) {
      if (trim($_FILES['myfiles']['name'][$i])!="") {
        $newfile = $file_dir.$_FILES['myfiles']['name'][$i];
        move_uploaded_file($_FILES['myfiles']['tmp_name'][$i], $newfile);
        $j++;
      }
    }
  }
  if (isset($j)&&$j>0) print "Your file(s) has been uploaded.<br>";

 echo '
<form enctype="multipart/form-data" action="__URL__" method="POST">
    <!-- MAX_FILE_SIZE must precede the file input field -->
    <input type="hidden" name="MAX_FILE_SIZE" value="30000" />
    <!-- Name of input element determines name in $_FILES array -->
    Send this file: <input name="myfiles" type="file" />
    <input type="submit" value="Send File" />
</form>';

?>
--- End Message ---
--- Begin Message ---
On 5/21/06, P. Guethlein <[EMAIL PROTECTED]> wrote:
I'm at one of those frustration levels....  can't seem to get a
script working that will post and upload a file to the server.  I"m
working with the below.  Can you help?

<?php
   $numoffile = 1;

   $file_dir  = "d:/upload/";
   if ($_FILES['myfiles']) {
   print_r ($_FILES);
     for ($i=0;$i<$numoffile;$i++) {
       if (trim($_FILES['myfiles']['name'][$i])!="") {
         $newfile = $file_dir.$_FILES['myfiles']['name'][$i];
         move_uploaded_file($_FILES['myfiles']['tmp_name'][$i], $newfile);
         $j++;
       }
     }
   }
   if (isset($j)&&$j>0) print "Your file(s) has been uploaded.<br>";

  echo '
<form enctype="multipart/form-data" action="__URL__" method="POST">
[snipped]

The form's action value should not be __URL__, it should be the
actual URL of the PHP file (eg. http://domain.com/upload.php).
You can also use the following line instead, which will put in the
URL to the current file:

<form enctype="multipart/form-data" action="<?php echo
$_SERVER['PHP_SELF']; ?>" method="POST">

Rabin

--- End Message ---
--- Begin Message ---
Hey,

Can anybody recommend a IP to country (or better still
IP->city) database and script? I have found some leads
via google but would like to know what you guys are
using or can recommend.

Or just the DB would do, I can write the script if I
have to.

Thanks!
Ryan

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

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

--- End Message ---

Reply via email to