php-general Digest 2 Jun 2002 00:39:52 -0000 Issue 1380
Topics (messages 100216 through 100264):
Re: Variables - Using The Contents Of A Varibale Name Built Dynamically
100216 by: Michael Davey
problems with installing freetype2
100217 by: andy
Re: Affiliate PHP program project - Please help
100218 by: John Holmes
Re: Apache, html, php and global variables
100219 by: Peter Goggin
100220 by: John Holmes
Re: MS SQL Problem
100221 by: Sqlcoders.com Programming Dept
A small question - Mysql_insert_id
100222 by: r
100223 by: Julie Meloni
100224 by: r
100225 by: Stuart Dallas
100226 by: Julie Meloni
XML to ARRAY
100227 by: Christopher J. Crane
Julie-> A small question - Mysql_insert_id
100228 by: r
value passing from html form to php variable.
100229 by: Wei Wang
100230 by: Stuart Dallas
100232 by: Wei Wang
100233 by: Philip Olson
100234 by: Philip Olson
100235 by: Stuart Dallas
100236 by: Wei Wang
100237 by: Wei Wang
100238 by: Stuart Dallas
100239 by: Wei Wang
100240 by: Wei Wang
100241 by: Stuart Dallas
100242 by: Stuart Dallas
100243 by: Wei Wang
100245 by: Stuart Dallas
reg exp problems
100231 by: Andrew Brampton
100244 by: Jason Wong
100249 by: Andrew Brampton
100250 by: Michael Sims
Possible to convert from Hex string to integer?
100246 by: Michael Davey
100247 by: Rasmus Lerdorf
100248 by: Stuart Dallas
100251 by: Michael Davey
Re: Speed comparison of PHP vs. PERL (not conclusive)
100252 by: Mark Charette
100255 by: Jason Wong
help me....S.O.S...my php doesn't ascend
100253 by: omora.arauco.cl
Re: Is PHP used by U.S. Government? By U.S. DoD?
100254 by: Christopher J. Crane
pcntl functions for task manager - comments?
100256 by: Clay Loveless
displaying client IP address
100257 by: Hugo Gallo
100258 by: Gerard Samuel
Nathan->Re: [PHP] Julie-> A small question - Mysql_insert_id
100259 by: r
100263 by: David Freeman
New to PHP- Form Validation Logic/Design Question
100260 by: lfindle.mindspring.com
100262 by: David Freeman
Problems with Multi-Uploads (AGAIN)
100261 by: Nick Patsaros
Newman Says: Only one value from a msSQL field.
100264 by: Philip J. Newman
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
You could give the button the same name in each form - only the fields in
between the <form</form> tags is actually submitted, then put a hidden field
in the form that uniquely identifies the data being submitted.
Just a thought... it is what I usually do...
Mikey
"Jason Teagle" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I have found an alternate way of achieving what I want, but I'm wondering
if
> there was an easier way. I have a PHP file that builds a Web page that
> includes forms. The forms are built dynamically based on the contents of a
> file, and thus there may be one or two or more forms on the page at any
> time. This means that I have controls named $btnChoice1 (first form),
> $btnChoice2 (second form), etc. (radio buttons). All of these forms are of
a
> similar format, and so lead to the same PHP page in their action - a
> parameter is passed in the URL to identify which form it came from.
>
> When the form passes to its action file, another PHP file, there are two
> ways to get form data: $_POST["control_name"] or $control_name. The
problem
> is, the control name I need has to be built dynamically based on which
form
> it came from. So I need this:
>
> $btnName = "btnChoice" . $form_number ;
>
> But now I have the tricky bit - $_POST[$btnName] doesn't work because it
> requires nested substitution of variables, and similarly I can't echo
> $btnName because that will of course use "btnChoice2" instead of the
> _contents_ of the control named btnChoice2.
>
> Is it possible to 'dereference' (whatever the term is) the variable name
> twice? I tried
>
> $$btnName
>
> in the stupid hope that it would first interpret that to
>
> $btnChoice2
>
> and then interpret that to the contents of the control, but of course it
> failed.
>
> I ended up using foreach on $_POST to pull out control names and their
> contents, and comparing the control name to my built-up name - but I was
> wondering if there's a more elegant way of doing what I wanted?
>
> Promise my next question to the group will be short {:v)
>
>
> --
> --------------------------------------------
> _ _
> o o Jason Teagle
> < [EMAIL PROTECTED]
> v
> --------------------------------------------
>
>
--- End Message ---
--- Begin Message ---
Hi there,
I have problems to find out if the installation of freetype 2 has been
successfull. It seems that only freetype 1 is running, since I can not use
some commands.
something went wrong, but there have been no complains during installation.
Thanx for any help,
andy
--- End Message ---
--- Begin Message ---
UPDATE table SET click = click + 1 WHERE month = MONTH(NOW()) AND year =
YEAR(NOW()) AND id = 775
Don't need to use PHP at all...
---John Holmes...
> -----Original Message-----
> From: r [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, June 01, 2002 6:13 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Affiliate PHP program project - Please help
>
> Hi PPL,
>
> I'm doing an affiliate program for a small company in PHP, but am
stuck a
> bit in the logic or thinking process....
>
> I have a table with IdNo,clicks,month,year
>
> the affiliates will get a link like this
> http://mysite.com/affiliates/aff.php?IdNo=775
>
> every time I get a click from 775 in the table I am updating the table
> with
> something like clicks=clicks+1 where month=6 and year=2002 and
IdNo=775
>
> My question is how do I get the current month/year from php or do I
have
> to
> query the database before every update to get month() and month(day)?
>
> will I have to use something like
> (for month) $mon=date(m);
> (for year ) $yer=date(Y);
>
> plus the main reason I am writing is to ask you gurus if I have the
right
> idea to make this work or is it done in some other way? Maybe you have
> done
> a similar program and and can give me some valuble info/insight or
wise
> words? ;-)
>
> OT- do you have any idea on how to contral the cursor in a form with
10
> textfields? is it possible without javascript?
>
> Thanks in advance for ANY help on this,
> Have a great day,
> -Ryan.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I am not clear what you mean by this. I have set session_start() on in the
php script that logs onto the database initially. i then call a test php
script from a button on the menu frame. This is the output it gives:
Test php variables
Warning: Cannot send session cookie - headers already sent by (output
started at c:\usr\www\my-domain\maintenance.php:4) in
c:\usr\www\my-domain\maintenance.php on line 5
Warning: Cannot send session cache limiter - headers already sent (output
started at c:\usr\www\my-domain\maintenance.php:4) in
c:\usr\www\my-domain\maintenance.php on line 5
Warning: open(/tmp\sess_593732809e269f91e78e7406d4a22808, O_RDWR) failed: No
such file or directory (2) in c:\usr\www\my-domain\maintenance.php on line 5
Test of global variables
DBA USER:
DBA Password;
Warning: open(/tmp\sess_593732809e269f91e78e7406d4a22808, O_RDWR) failed: No
such file or directory (2) in Unknown on line 0
Warning: Failed to write session data (files). Please verify that the
current setting of session.save_path is correct (/tmp) in Unknown on line 0
The script is:
<HTML>
<BODY>
Test php variables<BR>
<?php
session_start();
printf ("Test of global variables<BR>");
printf ("DBA USER: ",$_SESSION_VARS["dbauser"],"<BR>");
printf ("<BR>");
printf ("DBA Password; ",$_SESSION_VARS["dbapassword"],"<BR>");
?>
</BODY>
</HTML>
Is there a problem with how I am using sessiot_start, or is there a php
config problem?
Regards
Peter Goggin
----- Original Message -----
From: "John Holmes" <[EMAIL PROTECTED]>
To: "'Peter Goggin'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, June 01, 2002 2:04 PM
Subject: RE: [PHP] Apache, html, php and global variables
> You still have to connect to a database every time a script is run,
> whether it's loaded in a frame or run by itself. If you start a session
> and save the username and password in it, then you can use that login
> and password on every other page that you call session_start() on.
>
> ---John Holmes...
>
> > -----Original Message-----
> > From: Peter Goggin [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, May 31, 2002 11:12 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [PHP] Apache, html, php and global variables
> >
> > I am not certain how this helps me, since it appears the data is only
> > carried to pages called directly from where it is set. The page where
> the
> > user logs onto the database does not link to other pages. This is done
> > from
> > the top frame of the form. The top frame of the inital page contains
> the
> > menu, one option of which is to log onto the data base to start a
> session.
> > The user will then select another page from the top form.
> >
> > This new page is displayed in the bottom frame of the intial page, and
> > there
> > may be futher links within this page on the bottom fram.Generally
> however
> > main navigation is from the top frame which remains in place through
> out.
> > What I wabt to do is to have the login information available at all
> times
> > once the user is logged in, nomattar how the current page is called.
> >
> > Is this possible?
> >
> > If so how is this done?
> >
> >
> > ----- Original Message -----
> > From: "Stuart Dallas" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Saturday, June 01, 2002 11:56 AM
> > Subject: Re: [PHP] Apache, html, php and global variables
> >
> >
> > > On Saturday, June 1, 2002 at 2:42:40 AM, you wrote:
> > > > Is there any way of caryying the login information from one web
> page
> > to
> > the
> > > > next in global variables so that the username and password entered
> in
> > the
> > > > login screen is available to all other web pages in the site or do
> I
> > have to
> > > > ask the user to re-enter this information at every screen?
> > >
> > > Sessions: http://www.php.net/session
> > >
> > > --
> > > Stuart
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Sessions use cookies, which use headers, which have to be sent before
any output. <html> is output. So, put session_start() before that.
<?
Session_start();
...
?>
<html>
<body>
...
Where are you putting dbauser and dbapassword into the session?
Your sessions still aren't going to work because the session.save_path
isn't set correctly in your PHP.ini. Set it to a directory on your
computer that the web server has access to write to.
---John Holmes...
> -----Original Message-----
> From: Peter Goggin [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, June 01, 2002 9:54 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [PHP] Apache, html, php and global variables
>
> I am not clear what you mean by this. I have set session_start() on in
the
> php script that logs onto the database initially. i then call a test
php
> script from a button on the menu frame. This is the output it gives:
>
> Test php variables
>
> Warning: Cannot send session cookie - headers already sent by (output
> started at c:\usr\www\my-domain\maintenance.php:4) in
> c:\usr\www\my-domain\maintenance.php on line 5
>
> Warning: Cannot send session cache limiter - headers already sent
(output
> started at c:\usr\www\my-domain\maintenance.php:4) in
> c:\usr\www\my-domain\maintenance.php on line 5
>
> Warning: open(/tmp\sess_593732809e269f91e78e7406d4a22808, O_RDWR)
failed:
> No
> such file or directory (2) in c:\usr\www\my-domain\maintenance.php on
line
> 5
> Test of global variables
> DBA USER:
> DBA Password;
> Warning: open(/tmp\sess_593732809e269f91e78e7406d4a22808, O_RDWR)
failed:
> No
> such file or directory (2) in Unknown on line 0
>
> Warning: Failed to write session data (files). Please verify that the
> current setting of session.save_path is correct (/tmp) in Unknown on
line
> 0
>
>
> The script is:
> <HTML>
> <BODY>
> Test php variables<BR>
> <?php
> session_start();
> printf ("Test of global variables<BR>");
> printf ("DBA USER: ",$_SESSION_VARS["dbauser"],"<BR>");
> printf ("<BR>");
> printf ("DBA Password; ",$_SESSION_VARS["dbapassword"],"<BR>");
> ?>
> </BODY>
> </HTML>
>
> Is there a problem with how I am using sessiot_start, or is there a
php
> config problem?
>
> Regards
>
> Peter Goggin
>
> ----- Original Message -----
> From: "John Holmes" <[EMAIL PROTECTED]>
> To: "'Peter Goggin'" <[EMAIL PROTECTED]>; <php-
> [EMAIL PROTECTED]>
> Sent: Saturday, June 01, 2002 2:04 PM
> Subject: RE: [PHP] Apache, html, php and global variables
>
>
> > You still have to connect to a database every time a script is run,
> > whether it's loaded in a frame or run by itself. If you start a
session
> > and save the username and password in it, then you can use that
login
> > and password on every other page that you call session_start() on.
> >
> > ---John Holmes...
> >
> > > -----Original Message-----
> > > From: Peter Goggin [mailto:[EMAIL PROTECTED]]
> > > Sent: Friday, May 31, 2002 11:12 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [PHP] Apache, html, php and global variables
> > >
> > > I am not certain how this helps me, since it appears the data is
only
> > > carried to pages called directly from where it is set. The page
where
> > the
> > > user logs onto the database does not link to other pages. This is
done
> > > from
> > > the top frame of the form. The top frame of the inital page
contains
> > the
> > > menu, one option of which is to log onto the data base to start a
> > session.
> > > The user will then select another page from the top form.
> > >
> > > This new page is displayed in the bottom frame of the intial page,
and
> > > there
> > > may be futher links within this page on the bottom fram.Generally
> > however
> > > main navigation is from the top frame which remains in place
through
> > out.
> > > What I wabt to do is to have the login information available at
all
> > times
> > > once the user is logged in, nomattar how the current page is
called.
> > >
> > > Is this possible?
> > >
> > > If so how is this done?
> > >
> > >
> > > ----- Original Message -----
> > > From: "Stuart Dallas" <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Saturday, June 01, 2002 11:56 AM
> > > Subject: Re: [PHP] Apache, html, php and global variables
> > >
> > >
> > > > On Saturday, June 1, 2002 at 2:42:40 AM, you wrote:
> > > > > Is there any way of caryying the login information from one
web
> > page
> > > to
> > > the
> > > > > next in global variables so that the username and password
entered
> > in
> > > the
> > > > > login screen is available to all other web pages in the site
or do
> > I
> > > have to
> > > > > ask the user to re-enter this information at every screen?
> > > >
> > > > Sessions: http://www.php.net/session
> > > >
> > > > --
> > > > Stuart
> > > >
> > > >
> > > > --
> > > > PHP General Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > > >
> > > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi there,
I remember reading of a config setting in php.ini which lowered the
time PHP waits before clearing up/closing the socket out.
If it's a linux system you might want to try running netstat to see
the open net connections. If you see lots of open connections when
you reload the page a few times to your sql server then you know you
need to shorten the appropiate timeouts. If you dont see lots of open
connections then it's something unrelated to the actual virtual
circuits opened.
HTH,
Dw.
- ----- Original Message -----
From: "Justin Felker" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: May 31 2002 11:21 PM
Subject: Re: [PHP] MS SQL Problem
> Thanks for the reply. Actually, I am using both mssql_free_query
> and mssql_close along with mssql_pconnect. It still happens
> however. I can post the code if you are unsure. Does it have a
> history of threading issues as it only seems to happen when
> several requests are sent all at once or at least in very fast
> succession.
>
> Justin
>
>
> At 06:56 PM 5/31/2002 -0700, you wrote:
> >Hiya,
> >were you using the appropriate free_query & close functions to
> >free up the memory & more importantly the socket used to talk to
> >the sql server?
> >
> >You might want to try using the _pconnect function if it's
> >available instead of the usual _connect statement.
> >
> >I'd guess that PHP ran out of sockets to make outbound connections
> >with. Also, I believe that MSSQL is setup to only have around 1000
> >max connections open unless you alter the value in the config.
> >
> >HTH,
> >Dw
> >
> >
> >Sqlcoders.com Dynamic data driven web solutions
> >----- Original Message -----
> >From: "Justin Felker" <[EMAIL PROTECTED]>
> >To: <[EMAIL PROTECTED]>
> >Sent: May 31 2002 08:46 AM
> >Subject: [PHP] MS SQL Problem
> >
> >
> > > Last night, I ran into a problem when using the MS SQL support
> > > in PHP
> >under
> > > Apache/PHP module/MS SQL 2000. Everything worked well enough.
> > > I was able to connect to the server, query data, and a number
> > > of other things. However, I found that if I ran my test page
> > > (it connects to, queries and displays 20 rows of data, then
> > > disconnects) over and over very quickly (hold CTRL+R down
> > > basically) PHP would eventually (after about 6 seconds) fail to
> > > connect to the MS SQL server. In fact, the web server would
> > > have to be completely restarted before it could connect again.
> > >
> > > Has anyone run into this? I mean, if there is no solution to
> > > this and is the cause of basically shaky MS SQL support, then
> > > the SQL server would be made useless for sites with even a
> > > modest amount of traffic (several requests per second). Is
> > > this a known problem? If so, could anyone help me out?
> > >
> > > Thanks!
> > >
> > > Justin
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
> >
> >--
> >PHP General Mailing List (http://www.php.net/)
> >To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
-----BEGIN PGP SIGNATURE-----
Version: PGP Personal Privacy 6.5.8
iQA/AwUBPPljiNf2pW/GxlpVEQLy9wCg3tHovxdcVNthQvHyGY0brheJOqsAn28o
yFtm2vp4juq7zFZcQy8G9Qfp
=2jJv
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
Hi,
I am inserting a row into a table with this structure
id (auto increment)
name (varchar)
hits (int)
I am using
insert into mytable values(NULL,'Ryan',90);
Then according to the manual I have to use (to quote)
"printf ("Last inserted record has id %d\n", mysql_insert_id());"
will this return the row number or the "id" fields value..?
If it returns the row number how do I get the ID number?
The id started at 1500.
Cheers,
-Ryan.
--- End Message ---
--- Begin Message ---
r> I am inserting a row into a table with this structure
r> id (auto increment)
...
Assuming you mean ID int not null primary key auto_increment (or
something like that).
r> Then according to the manual I have to use (to quote)
r> "printf ("Last inserted record has id %d\n", mysql_insert_id());"
r> will this return the row number or the "id" fields value..?
FYI, you could:
a) try it and see
b) see what the manual has to say:
http://www.php.net/manual/en/function.mysql-insert-id.php
The answer is "Gets the id generated from the previous INSERT
operation".
- Julie
--> Julie Meloni
--> [EMAIL PROTECTED]
--> www.thickbook.com
Find "Sams Teach Yourself MySQL in 24 Hours" at
http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20
--- End Message ---
--- Begin Message ---
Hey Julie,
Thanks for replying,
Actually the ID field is not null,primary and auto_increment.
Thanks for the URL but in my message I did quote the line from that same url
(http://www.php.net/manual/en/function.mysql-insert-id.php)
I just need to get the ID of the just inserted record.
Any ideas?
Cheers,
-Ryan.
> r> I am inserting a row into a table with this structure
> r> id (auto increment)
> ...
>
> Assuming you mean ID int not null primary key auto_increment (or
> something like that).
>
> r> Then according to the manual I have to use (to quote)
> r> "printf ("Last inserted record has id %d\n", mysql_insert_id());"
>
> r> will this return the row number or the "id" fields value..?
>
> FYI, you could:
> a) try it and see
> b) see what the manual has to say:
http://www.php.net/manual/en/function.mysql-insert-id.php
>
> The answer is "Gets the id generated from the previous INSERT
> operation".
>
>
> - Julie
>
> --> Julie Meloni
> --> [EMAIL PROTECTED]
> --> www.thickbook.com
>
> Find "Sams Teach Yourself MySQL in 24 Hours" at
> http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20
>
--- End Message ---
--- Begin Message ---
On Sunday, June 2, 2002 at 4:07:31 AM, you wrote:
> will this return the row number or the "id" fields value..?
> If it returns the row number how do I get the ID number?
> The id started at 1500.
>From the manual page for mysql_insert_id()...
"mysql_insert_id() returns the ID generated for an AUTO_INCREMENT column by the
previous INSERT query"
In other words, it returns the "id" fields value.
Don't take this the wrong way, but you clearly didn't look this up in the
manual. This list is to help with real problems, not manual lookups.
--
Stuart
--- End Message ---
--- Begin Message ---
r> Actually the ID field is not null,primary and auto_increment.
Well, it has to be of a TYPE as well...
r> Thanks for the URL but in my message I did quote the line from that same url
r> (http://www.php.net/manual/en/function.mysql-insert-id.php)
r> I just need to get the ID of the just inserted record.
I'm just going to assume you're f*cking with all of us and leave it at
that.
- Julie
--> Julie Meloni
--> [EMAIL PROTECTED]
--> www.thickbook.com
Find "Sams Teach Yourself MySQL in 24 Hours" at
http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20
--- End Message ---
--- Begin Message ---
Here is a piece of code, that is close to doing what I want it to.
The end result I would like to have is an array that is simple to work with.
If the XML tag was <issue-name>RED HAT</issue-name>, I would like something
like the following:
$Tags['issue-name']. So I could print it out. Something like, print
"$Tags['issue-name']<br>\n";
I was able to get a numerical representation of the array like, $Tags[5] and
the value of that tag was "RED HAT", but then I would have to know what the
position of the data I am looking for in the array. I would prefer to know
the tag name and the array and get to the data that way. I know there is a
way to do this, but I just can't figure it out. There is a lot of
information on Parsing the XML file but not getting into a useful array, or
at least that I have found easily to understand.
if(!isset($Sym)) { $Sym = 'IKN'; }
$URI = 'http://quotes.nasdaq.com/quote.dll?page=xml&mode=stock&symbol=';
$simple = implode( '', file("$URI$Sym"));
$p = xml_parser_create();
xml_parse_into_struct($p,$simple,$vals,$index);
xml_parser_free($p);
file://echo "Index array\n";
file://print_r($index);
file://echo "\nVals array\n";
file://print_r($vals);
--- End Message ---
--- Begin Message ---
Hey Julie,
Sorry, am not "f*cking" with you or anybody,
just new to databases in PHP, I'm from a java servlet background and we
dont have this kind of function there.
I'm sorry if I offended you or made you think that I was pulling your leg,
its just that after 7 hours of programming the manual looks mighty confusing
even if the explanation is simple....computers look confusing now....;-)
Am a newbie in PHP and a pure virgin in database programming using PHP,
hope you understand.
Sorry again and have a great day,
-Ryan
> r> Actually the ID field is not null,primary and auto_increment.
>
> Well, it has to be of a TYPE as well...
>
> r> Thanks for the URL but in my message I did quote the line from that
same url
> r> (http://www.php.net/manual/en/function.mysql-insert-id.php)
>
> r> I just need to get the ID of the just inserted record.
>
> I'm just going to assume you're f*cking with all of us and leave it at
> that.
>
>
> - Julie
>
> --> Julie Meloni
> --> [EMAIL PROTECTED]
> --> www.thickbook.com
>
> Find "Sams Teach Yourself MySQL in 24 Hours" at
> http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20
>
--- End Message ---
--- Begin Message ---
I am not sure if this is the right place to ask this naive question.
I got a simple form addform.html and add.php look like the following.
But everytime I got empty value from firstname and lastname. It seems like
the input value in the html page was not passed on to the php variable $firstname in
add.php. Anyone give me a hand on this naive question?
Great thanks.
Wei
addform.html
<html>
<body>
<form action="add.php" method="post">
First Name : <input type="text" name="firstname" size="40" length="40" value=""><BR>
Surname : <input type="text" name="surname" size="40" length="40" value=""><BR>
<input type="submit" name="submit" value="Submit">
<input type="reset" name="reset" value="Clear It">
</form>
</body>
</html>
add.php
<html>
<body>
<?php
$db = pg_connect("dbname=friends");
$query = "INSERT INTO friends (id, firstname, surname) values
(nextval('friends_id_seq'), '$firstname', '$surname')";
$result = pg_exec($db, $query);
if (!$result) {
printf ("ERROR");
$errormessage = pg_errormessage($db);
echo $errormessage;
exit;
}
printf ("These values were inserted into the database - %s %s", $firstname, $surname);
pg_close();
?>
</body>
</html>
--- End Message ---
--- Begin Message ---
On Saturday, June 1, 2002 at 4:51:20 PM, you wrote:
> I got a simple form addform.html and add.php look like the following.
> But everytime I got empty value from firstname and lastname. It seems like
> the input value in the html page was not passed on to the php variable
> $firstname in add.php. Anyone give me a hand on this naive question?
You probably have register_globals turned Off in your php.ini file. If you do
then you can either turn it on or use the recommended method of accessing
POSTed variable: $_POST['firstname'].
--
Stuart
--- End Message ---
--- Begin Message ---
Do you mind telling me where this php.ini is?
And I tried the second attempt like this:
$query = "INSERT INTO friends (id, firstname, surname) values
(nextval('friends_id_seq'), $_POST['firstname'], $_POST['surname'])";
which returns error:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or
T_VARIABLE or T_NUM_STRING in /local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on
line 5
Oy Sat, 1 Jun 2002 16:57:00 +0100
[EMAIL PROTECTED] (Stuart Dallas) wrote:
> On Saturday, June 1, 2002 at 4:51:20 PM, you wrote:
> > I got a simple form addform.html and add.php look like the following.
> > But everytime I got empty value from firstname and lastname. It seems like
> > the input value in the html page was not passed on to the php variable
> > $firstname in add.php. Anyone give me a hand on this naive question?
>
> You probably have register_globals turned Off in your php.ini file. If you do
> then you can either turn it on or use the recommended method of accessing
> POSTed variable: $_POST['firstname'].
>
> --
> Stuart
>
--- End Message ---
--- Begin Message ---
Some thoughts:
a) Why is $firstname empty?
It's empty because the PHP directive register_globals = off.
So, PHP will not create $firstname automatically. This is
most likely the cause.
b) How do I access $firstname with register_globals = off then?
Many ways. Regardless of register_globals setting, the
information is available in many ways, like:
// Worked since PHP 3
print $HTTP_POST_VARS['firstname'];
// Worked since PHP 4.1.0
print $_POST['firstname'];
Or, you can create $firstname (or something similar) with
either extract() or import_request_variables(). Like:
import_request_variables('gpc', 'r_');
print $r_firstname;
extract($_POST);
print $firstname;
c) What is register_globals?
A controversial PHP directive. As of PHP 4.2.0, this directive
defaults to off. Before this, it was on. So, many books, articles,
tutorials, etc. rely on it on, which makes life interesting
in the PHP world today.
http://www.php.net/manual/en/security.registerglobals.php
There are many predefined variables, such as $_GET, too.
http://www.php.net/manual/en/language.variables.predefined.php
Regards,
Philip Olson
On Sat, 1 Jun 2002, Wei Wang wrote:
> I am not sure if this is the right place to ask this naive question.
>
> I got a simple form addform.html and add.php look like the following.
> But everytime I got empty value from firstname and lastname. It seems like
> the input value in the html page was not passed on to the php variable $firstname in
>add.php. Anyone give me a hand on this naive question?
>
> Great thanks.
>
>
> Wei
>
>
> addform.html
>
> <html>
> <body>
> <form action="add.php" method="post">
> First Name : <input type="text" name="firstname" size="40" length="40" value=""><BR>
> Surname : <input type="text" name="surname" size="40" length="40" value=""><BR>
> <input type="submit" name="submit" value="Submit">
> <input type="reset" name="reset" value="Clear It">
> </form>
> </body>
> </html>
>
>
> add.php
>
> <html>
> <body>
> <?php
> $db = pg_connect("dbname=friends");
> $query = "INSERT INTO friends (id, firstname, surname) values
>(nextval('friends_id_seq'), '$firstname', '$surname')";
> $result = pg_exec($db, $query);
> if (!$result) {
> printf ("ERROR");
> $errormessage = pg_errormessage($db);
> echo $errormessage;
> exit;
> }
> printf ("These values were inserted into the database - %s %s", $firstname,
>$surname);
> pg_close();
> ?>
> </body>
> </html>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
> $query = "INSERT INTO friends (id, firstname, surname) values
>(nextval('friends_id_seq'),
> $_POST['firstname'], $_POST['surname'])";
>
> which returns error:
> Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING
>or
> T_VARIABLE or T_NUM_STRING in
> /local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 5
When using arrays in strings, things are done a little differently:
print "a $arr[key] string";
print "a {$arr['key']} string";
print "a " . $arr['key'] . " string";
Be sure to always surround keys with quotes outside of strings
otherwise PHP looks for a CONSTANT named key first, instead.
define ('a','b');
$arr = array('a' => 'apple', 'b' => 'banana');
print $arr[a]; // banana
print "$arr[a]"; // apple
print $arr['a']; // apple
Regards,
Philip Olson
--- End Message ---
--- Begin Message ---
On Saturday, June 1, 2002 at 5:00:18 PM, you wrote:
> Do you mind telling me where this php.ini is?
Create a php script containing just <?php phpinfo(); ?>. That page will tell
you where your php.ini is (or should be).
> And I tried the second attempt like this:
> $query = "INSERT INTO friends (id, firstname, surname) values
>(nextval('friends_id_seq'), $_POST['firstname'], $_POST['surname'])";
> which returns error:
> Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING
>or T_VARIABLE or T_NUM_STRING in
>/local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 5
Try this...
$query = "INSERT INTO friends (id, firstname, surname) values
(nextval('friends_id_seq'), ".$_POST['firstname'].", ".$_POST['surname'].")";
--
Stuart
--- End Message ---
--- Begin Message ---
>
> Create a php script containing just <?php phpinfo(); ?>. That page will tell
> you where your php.ini is (or should be).
>
it told me it's in php/lib, but it's not there.
>
> Try this...
>
> $query = "INSERT INTO friends (id, firstname, surname) values
> (nextval('friends_id_seq'), ".$_POST['firstname'].", ".$_POST['surname'].")";
When I input "Wei" for firstname and Wang for surname in the form and submit,
I got error:
Warning: pg_exec() query failed: ERROR: Attribute 'andras' not found in
/local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 6
ERRORERROR: Attribute 'andras' not found
ps. Philip, Great thanks for your detailed help. I still couldn't figure out how
to access $firstname. And I couldn't find php.ini, which should be the most
straightforward way to solve this.
>
> --
> Stuart
>
--- End Message ---
--- Begin Message ---
Sorry. When I input "Andras" as firstname in the form, ...
On Sat, 1 Jun 2002 17:22:02 +0100
[EMAIL PROTECTED] (Wei Wang) wrote:
> >
> > Create a php script containing just <?php phpinfo(); ?>. That page will tell
> > you where your php.ini is (or should be).
> >
> it told me it's in php/lib, but it's not there.
> >
> > Try this...
> >
> > $query = "INSERT INTO friends (id, firstname, surname) values
> > (nextval('friends_id_seq'), ".$_POST['firstname'].", ".$_POST['surname'].")";
>
> When I input "Wei" for firstname and Wang for surname in the form and submit,
> I got error:
>
> Warning: pg_exec() query failed: ERROR: Attribute 'andras' not found in
>/local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 6
> ERRORERROR: Attribute 'andras' not found
>
>
> ps. Philip, Great thanks for your detailed help. I still couldn't figure out how
> to access $firstname. And I couldn't find php.ini, which should be the most
> straightforward way to solve this.
>
> >
> > --
> > Stuart
> >
--- End Message ---
--- Begin Message ---
On Saturday, June 1, 2002 at 5:22:02 PM, you wrote:
>> Create a php script containing just <?php phpinfo(); ?>. That page will tell
>> you where your php.ini is (or should be).
>>
> it told me it's in php/lib, but it's not there.
The default php.ini is called php.ini-recommended and will be in the directory
where you installed PHP. Copy it to php/lib and rename it to php.ini. When PHP
can't find php.ini it uses it's built-in defaults - these set register_globals
to off.
> When I input "Wei" for firstname and Wang for surname in the form and submit,
> I got error:
> Warning: pg_exec() query failed: ERROR: Attribute 'andras' not found in
>/local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 6
> ERRORERROR: Attribute 'andras' not found
Show us what is on line 6 and a couple of lines either side of it.
--
Stuart
--- End Message ---
--- Begin Message ---
Is there anything I should do to make the php.ini come into effect? I did
put the register_global = On but still got empty values.
And my $_POST version is like this:
<?php
$db = pg_connect("dbname=friends");
$query = "INSERT INTO friends (id, firstname, surname) values
(nextval('friends_id_seq'), $_POST['firstname'], $_POST['surname'])";
$result = pg_exec($db, $query);
if (!$result) {
printf ("ERROR");
$errormessage = pg_errormessage($db);
echo $errormessage;
exit;
}
printf ("These values were inserted into the database - %s %s", $firstname, $surname);
pg_close();
?>
</body>
</html>
On Sat, 1 Jun 2002 17:08:11 +0100
[EMAIL PROTECTED] (Stuart Dallas) wrote:
> On Saturday, June 1, 2002 at 5:00:18 PM, you wrote:
> > Do you mind telling me where this php.ini is?
>
> Create a php script containing just <?php phpinfo(); ?>. That page will tell
> you where your php.ini is (or should be).
>
> > And I tried the second attempt like this:
>
> > $query = "INSERT INTO friends (id, firstname, surname) values
>(nextval('friends_id_seq'), $_POST['firstname'], $_POST['surname'])";
>
> > which returns error:
> > Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING
>or T_VARIABLE or T_NUM_STRING in
>/local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 5
>
> Try this...
>
> $query = "INSERT INTO friends (id, firstname, surname) values
> (nextval('friends_id_seq'), ".$_POST['firstname'].", ".$_POST['surname'].")";
>
> --
> Stuart
>
--- End Message ---
--- Begin Message ---
Sorry.
I restared apache and php.ini came into effect.
On Sat, 1 Jun 2002 17:29:13 +0100
[EMAIL PROTECTED] (Stuart Dallas) wrote:
> On Saturday, June 1, 2002 at 5:22:02 PM, you wrote:
> >> Create a php script containing just <?php phpinfo(); ?>. That page will tell
> >> you where your php.ini is (or should be).
> >>
> > it told me it's in php/lib, but it's not there.
>
> The default php.ini is called php.ini-recommended and will be in the directory
> where you installed PHP. Copy it to php/lib and rename it to php.ini. When PHP
> can't find php.ini it uses it's built-in defaults - these set register_globals
> to off.
>
> > When I input "Wei" for firstname and Wang for surname in the form and submit,
> > I got error:
>
> > Warning: pg_exec() query failed: ERROR: Attribute 'andras' not found in
>/local/scratch-1/ww220/Apache1.3/htdocs/test/add2.php on line 6
> > ERRORERROR: Attribute 'andras' not found
>
> Show us what is on line 6 and a couple of lines either side of it.
>
> --
> Stuart
>
--- End Message ---
--- Begin Message ---
On Saturday, June 1, 2002 at 5:35:03 PM, you wrote:
> Is there anything I should do to make the php.ini come into effect? I did
> put the register_global = On but still got empty values.
you may not need to do anything or you may need to restart your http server.
Have a look at your phpinfo() page. If it's picking up the php.ini file then it
will show it's filename as well as it's path.
> <?php
> $db = pg_connect("dbname=friends");
> $query = "INSERT INTO friends (id, firstname, surname) values
>(nextval('friends_id_seq'), $_POST['firstname'], $_POST['surname'])";
> $result = pg_exec($db, $query);
> if (!$result) {
> printf ("ERROR");
> $errormessage = pg_errormessage($db);
> echo $errormessage;
> exit;
> }
> printf ("These values were inserted into the database - %s %s", $firstname,
>$surname);
> pg_close();
?>>
> </body>
> </html>
Hmm, line 6 of that code would be printf ("ERROR"); but I'll assume that you
haven't included the first few lines and that line 6 is actually the pg_exec
line. You haven't changed $query as I suggested in a previous message. Change
the $query = line to the following...
$query = "INSERT INTO friends (id, firstname, surname) values
(nextval('friends_id_seq'), ".$_POST['firstname'].", ".$_POST['surname'].")";
--
Stuart
--- End Message ---
--- Begin Message ---
On Saturday, June 1, 2002 at 5:37:37 PM, you wrote:
> Sorry.
> I restared apache and php.ini came into effect.
If you're going to run with register_globals on you should make sure you
understand the implications:
http://www.php.net/manual/en/security.registerglobals.php.
--
Stuart
--- End Message ---
--- Begin Message ---
Changed the query and get this error when input dave as firstname:
ERRORERROR: Attribute 'dave' not found
add2.php is:
<html>
<body>
<?php
$db = pg_connect("dbname=friends");
$query = "INSERT INTO friends (id, firstname, surname) values
(nextval('friends_id_seq'), ".$_POST['firstname'].", ".$_POST['surname'].")";
$result = pg_exec($db, $query);
if (!$result) {
printf ("ERROR");
$errormessage = pg_errormessage($db);
echo $errormessage;
exit;
}
printf ("These values were inserted into the database - %s %s", $firstname, $surname);
pg_close();
?>
</body>
</html>
addform.php is:
<html>
<body>
<form action="add2.php" method="post">
First Name : <input type="text" name="firstname" size="40" length="40"
value=""><BR>
Surname : <input type="text" name="surname" size="40" length="40"
value=""><BR>
<input type="submit" name="submit" value="Submit">
<input type="reset" name="reset" value="Clear It">
</form>
</body>
</html>
On Sat, 1 Jun 2002 17:44:57 +0100
[EMAIL PROTECTED] (Stuart Dallas) wrote:
> On Saturday, June 1, 2002 at 5:35:03 PM, you wrote:
> > Is there anything I should do to make the php.ini come into effect? I did
> > put the register_global = On but still got empty values.
>
> you may not need to do anything or you may need to restart your http server.
> Have a look at your phpinfo() page. If it's picking up the php.ini file then it
> will show it's filename as well as it's path.
>
> > <?php
> > $db = pg_connect("dbname=friends");
> > $query = "INSERT INTO friends (id, firstname, surname) values
>(nextval('friends_id_seq'), $_POST['firstname'], $_POST['surname'])";
> > $result = pg_exec($db, $query);
> > if (!$result) {
> > printf ("ERROR");
> > $errormessage = pg_errormessage($db);
> > echo $errormessage;
> > exit;
> > }
> > printf ("These values were inserted into the database - %s %s", $firstname,
>$surname);
> > pg_close();
> ?>>
> > </body>
> > </html>
>
> Hmm, line 6 of that code would be printf ("ERROR"); but I'll assume that you
> haven't included the first few lines and that line 6 is actually the pg_exec
> line. You haven't changed $query as I suggested in a previous message. Change
> the $query = line to the following...
>
> $query = "INSERT INTO friends (id, firstname, surname) values
> (nextval('friends_id_seq'), ".$_POST['firstname'].", ".$_POST['surname'].")";
>
> --
> Stuart
>
--- End Message ---
--- Begin Message ---
On Saturday, June 1, 2002 at 6:00:22 PM, you wrote:
> $query = "INSERT INTO friends (id, firstname, surname) values
>(nextval('friends_id_seq'), ".$_POST['firstname'].", ".$_POST['surname'].")";
It's so obvious you're gonna kick yourself (I did!). You need to enclose the
two values in quotes, like so...
$query = "INSERT INTO friends (id, firstname, surname) values
(nextval('friends_id_seq'), '".$_POST['firstname']."', '".$_POST['surname']."')";
--
Stuart
--- End Message ---
--- Begin Message ---
Hi,
I've never used a reg exp, but I was trying to do something simple, and I just can't
seem to do it :)
I have a varible $fdata which contains the contents of a webpage, and I want to strip
out the <base> tag.
I try:
$fdata = preg_replace("<base.*>","",$fdata);
But its stripping out everything between the first "<base" and the last ">" on that
line, instead of the of the ">" at the end of the base tag
Hope that makes sense :)
TIA
Andrew
--- End Message ---
--- Begin Message ---
On Saturday 01 June 2002 23:56, Andrew Brampton wrote:
> Hi,
> I've never used a reg exp, but I was trying to do something simple, and I
> just can't seem to do it :)
>
> I have a varible $fdata which contains the contents of a webpage, and I
> want to strip out the <base> tag.
>
> I try:
> $fdata = preg_replace("<base.*>","",$fdata);
>
> But its stripping out everything between the first "<base" and the last ">"
> on that line, instead of the of the ">" at the end of the base tag
Try: (it should remove <base> & </base>)
preg_replace("/(<base>)|(<\/base>)/", "", $fdata);
*** Untested, use at your own risk ***
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
When you make your mark in the world, watch out for guys with erasers.
-- The Wall Street Journal
*/
--- End Message ---
--- Begin Message ---
Hi, thanks for the suggestion, but the <base> tag doesn't have to have a
closing tag, OR it appears many/all sites I've seen don't use the closing
tag.
Andrew
----- Original Message -----
From: "Jason Wong" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, June 01, 2002 6:02 PM
Subject: Re: [PHP] reg exp problems
> On Saturday 01 June 2002 23:56, Andrew Brampton wrote:
> > Hi,
> > I've never used a reg exp, but I was trying to do something simple, and
I
> > just can't seem to do it :)
> >
> > I have a varible $fdata which contains the contents of a webpage, and I
> > want to strip out the <base> tag.
> >
> > I try:
> > $fdata = preg_replace("<base.*>","",$fdata);
> >
> > But its stripping out everything between the first "<base" and the last
">"
> > on that line, instead of the of the ">" at the end of the base tag
>
> Try: (it should remove <base> & </base>)
>
> preg_replace("/(<base>)|(<\/base>)/", "", $fdata);
>
> *** Untested, use at your own risk ***
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
>
> /*
> When you make your mark in the world, watch out for guys with erasers.
> -- The Wall Street Journal
> */
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
On Sat, 1 Jun 2002 16:56:04 +0100, you wrote:
>Hi,
>I've never used a reg exp, but I was trying to do something simple, and I just can't
>seem to do it :)
>
>I have a varible $fdata which contains the contents of a webpage, and I want to strip
>out the <base> tag.
>
>I try:
>$fdata = preg_replace("<base.*>","",$fdata);
>
>But its stripping out everything between the first "<base" and the last ">" on that
>line, instead of the of the ">" at the end of the base tag
Try this (untested):
$fdata = preg_replace ("/<base[^>]*>/","",$fdata);
That should work.
--- End Message ---
--- Begin Message ---
Does anyone know of a function within PHP that will convert a hexadecimal
string (without the leading 0x) into an integer?
regards,
Mikey
--- End Message ---
--- Begin Message ---
Did you check the manual?
http://php.net/hexdec
On Sat, 1 Jun 2002, Michael Davey wrote:
> Does anyone know of a function within PHP that will convert a hexadecimal
> string (without the leading 0x) into an integer?
>
> regards,
>
> Mikey
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
--- End Message ---
--- Begin Message ---
On Saturday, June 1, 2002 at 6:29:59 PM, you wrote:
> Does anyone know of a function within PHP that will convert a hexadecimal
> string (without the leading 0x) into an integer?
FFS!! http://www.php.net/hexdec
--
Stuart
--- End Message ---
--- Begin Message ---
Which is so easy to find in the offline manual...
"Stuart Dallas" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Saturday, June 1, 2002 at 6:29:59 PM, you wrote:
> > Does anyone know of a function within PHP that will convert a
hexadecimal
> > string (without the leading 0x) into an integer?
>
> FFS!! http://www.php.net/hexdec
>
> --
> Stuart
>
--- End Message ---
--- Begin Message ---
From: Jason Wong [mailto:[EMAIL PROTECTED]]
>Try comparing reading 10K rows from a DB using Perl and PHP would be a more
>useful benchmark.
---
When's the last time you wrote a Web page that needed 10K rows displayed?
Writing good _and relevant_ benchmarks is one of the more difficult things
to do in CS. Personally, I look at the time it takes me to code and debug
things since that's the most expensive part of the cost equation to my
customers - hardware's cheap compared to me. I can get something of
production quality up and running on PHP much faster than I can in Perl -
probably due to 20 years of programming in C - so my customers are happy.
Considering that 95% of the time the bottleneck is the bandwidth, not the
application code, and the other 5% of the bottleneck is in the database
application section, my customers don't demand any artificial language
benchmarks.
Mark C.
--- End Message ---
--- Begin Message ---
On Sunday 02 June 2002 02:12, Mark Charette wrote:
> From: Jason Wong [mailto:[EMAIL PROTECTED]]
>
> >Try comparing reading 10K rows from a DB using Perl and PHP would be a
> > more useful benchmark.
>
> ---
> When's the last time you wrote a Web page that needed 10K rows displayed?
Never.
Perhaps you didn't follow the thread. The gist of it was that someone was
concerned that the code which does looping in PHP was slow (compared to Perl)
and would like to see it increased in speed. What I was trying to point out
was that the time it takes to do the loop is (probably) insignificant
compared to whatever is happening /inside/ the loop. Thus my suggestion. Of
course no (sensible) person would want to display 10K rows in a web-page
anymore than one would want to display all the prime numbers from 1 to 10
trillion. However in the context of what PHP is (usually) used for it is a
better measure of speed and more relevant than calculating those prime
numbers.
But it would be hardly useful to compare the speed of retrieval of a single
row as other factors would make it unreliable. How many benchmarks do you see
where the operation is only performed once? I would say not many.
> Writing good _and relevant_ benchmarks is one of the more difficult things
> to do in CS. Personally, I look at the time it takes me to code and debug
> things since that's the most expensive part of the cost equation to my
> customers - hardware's cheap compared to me. I can get something of
> production quality up and running on PHP much faster than I can in Perl -
> probably due to 20 years of programming in C - so my customers are happy.
> Considering that 95% of the time the bottleneck is the bandwidth, not the
> application code, and the other 5% of the bottleneck is in the database
> application section, my customers don't demand any artificial language
> benchmarks.
And I agree, the MS method of throwing in hardware to mask inefficient
programming is quite cost-effective. That is why today my 128MB/500MHz PIII
system feels just a nippy as my 8MB/8MHz Amiga did 10 years ago ;-)
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
Take everything in stride. Trample anyone who gets in your way.
*/
--- End Message ---
--- Begin Message ---
Hi:
I have a Big Problems for my.
I have a server with WINNT 4.0 and IIS 3.0, I wanted to install PHP
(ver. 4.2.1) and it doesn't ascend.
I made it like it was indicated it configures in it paginates it
http://www.php.net/manual/fi/configuration.php
but neither I am this way, did I lack something?, that happen?
I make test with one it paginates call it proves .php and I write several
test instruction but it is not:
<?php $myvar = " Hola. Este es mi primer script en PHP \n"; //es mi
primer script en PHP \n";
//Esto es un comentario
echo $myvar;
?>
<BR>
<tr><td>Forma 1</a></td>
<? echo "Hola, este es un mensaje de Prueba con PHP"; ?>
<BR>
<tr><td>Forma 2</a></td>
<?php echo "Hola, este es un mensaje de Prueba con PHP"; ?>
<BR>
<tr><td>Forma 3</a></td>
<script language="php"> echo "Hola, este es un mensaje de Prueba
con PHP"; </script>
<BR>
<tr><td>Forma4</a></td>
<% echo "Hola, este es un mensaje de Prueba con PHP"; %>
<BR><BR>
<? php phpinfo() ?>
Please that some of you me to help.
Oscar Mora
--- End Message ---
--- Begin Message ---
Another site that you should be aware of is for both internal and external,
NASA uses PHP and MySQL, of which both are free.
"John Christopher" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
> I would like to use PHP in a project for a United States
> Government client. The client is skeptical because PHP
> is not a Microsoft product. I'm looking for statistics and
> links that show that PHP *is* currently in use by the
> US Government.
>
> Is PHP used by the U.S. Department of Defense? Examples?
>
> Is PHP a U.S. Military Standard?
>
> Any stats or links would be most helpful. Thank you.
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
--- End Message ---
--- Begin Message ---
I'm experimenting with PHP's pcntl_* functions using the PHP cgi ... I've
never written a daemon before, and there doesn't seem to be a lot of
information out there about how to do this with the pcntl functions.
So, I've read what I can find on the subject as it deals with UNIX
programming. The goal is a script that will run forever, checking a "job
queue" ... If jobs are waiting, use pcntl_fork() to handle the jobs.
To this end, I've come up with this pseudo-code ... Before going WAY off in
this direction, I'd like to submit this for comments by those who've had
more experience with this sort of thing.
------------------
// run forever if necessary
set_time_limit(0);
// detatch from the controlling terminal
if (!posix_setsid()) {
die('could not detach from terminal');
}
// setup signal handlers
pcntl_signal(SIGTERM, "sig_handler");
pcntl_signal(SIGHUP, "sig_handler");
// loop forever waiting on jobs
while(1) {
// check queue for pending jobs
// (db lookup omitted, let's assume jobs are waiting)
$jobs_waiting = true;
if($jobs_waiting) {
$pid = pcntl_fork();
if($pid == -1) {
die('could not fork');
} else if ($pid) {
// parent
// call waitpid to reap children that
// have already terminated
do {
$tpid = pcntl_waitpid(-1,$status,WNOHANG);
if($tpid == -1)
die('error occurred while waiting for child');
} while (!$tpid);
} else {
// child
// perform task on jobs waiting
// when job(s) complete, quit
exit();
}
}
// wait two seconds before checking queue again
sleep(2);
unset($jobs_waiting);
}
function sig_handler($signo) {
// blah blah
}
--------------------
I am open to suggestions or comments on this approach! Please let me know if
you think this looks nuts.
Thanks,
Clay
--- End Message ---
--- Begin Message ---
I an effort to deter fraudulent credit cards, I'd like to display the
client's IP address. Anyone know how this is done with PHP scripting?
There is SSI code & Perl code for this, but I need to have this be a .php
page since it's talking to MySQL.
Any help would be much appreciated.
Hugo
--- End Message ---
--- Begin Message ---
$_SERVER['REMOTE_ADDR']
Hugo Gallo wrote:
>I an effort to deter fraudulent credit cards, I'd like to display the
>client's IP address. Anyone know how this is done with PHP scripting?
>
>There is SSI code & Perl code for this, but I need to have this be a .php
>page since it's talking to MySQL.
>
>Any help would be much appreciated.
>
>Hugo
>
>
>
>
>
--
Gerard Samuel
http://www.trini0.org:81/
http://dev.trini0.org:81/
--- End Message ---
--- Begin Message ---
Hey dude,
Yeah, I seem to have a talent for pissing people of unintentally, and Julie
seemed to have gotten more than a little pissed at me.
Anyway, the reason I didnt specify the type was that I was under the
impression that if you have a auto_increment it has to be an integer...I
mean you cant have a text....and if you have a float/double like 2.23 what
will it increment to? 2.24 or 3.23? just did not think of date, time.....
Guess she just had a bad day and I was the final straw.......:)
I kinda understood what you mean but not totally so am sending you the
actual code used below.....
<?php
$connect=mysql_connect();
$database["server"] = "localhost";
$database["user"] = "ryan1";
$database["password"] = "ryan777";
$database["database"] = "ryan";
if(!$connect = @mysql_connect($database["server"],
$database["user"],
$database["password"]))
{print("Problem connecting, failed to connect to:" . $database["server"]);}
$database["sql"] = "insert into Ref_Users
values(NULL,'$FName','$LName','$SiteName',"
.
"'$SiteAddress','$Company','$Address','$Username','$pw','$Email',MONTH(now()
),YEAR(now()),0)";
mysql_select_db($database["database"]);
if (mysql_query($database["sql"]))
{}
else
{print("<p>PROBLEM, Could not create account...ERROR: " . mysql_error() .
"</p>");}
?>
What do you think? good, bad or ugly?
Give me your comments/suggestions and if possible add the mysql_insert_id in
the correct place and comment it so that I will know....
> Wow, Ryan, lovely reception you've gotten on this one. :-)
>
> Julie has a point (she needs some Prozac or xanex or something, but she
has a point) in that the ID
> field needs a type, either date/time, integer, or string of some sort...
so you'd need to be more
> specific than your original layout:
> id (auto increment)
> name (varchar)
> hits (int)
>
> Something more along the lines of:
> id INT NOT NULL UNSIGNED AUTO_INCREMENT PRIMARY KEY,
> name VARCHAR(255) NOT NULL,
> hits INT UNSIGNED NOT NULL DEFAULT 0
>
> or something like that, depending of course on how you want the table to
behave. You really should
> look into the MySQL manual a bit on table types; the information is well
laid out and easy to
> understand, and if you figure this stuff out now, before you've started
inserting stuff into the
> database, you'll save bunches of time by not needing to change much later
(trust me on this one,
> hooo boy!). You might also want to purchase MySQL by Paul DuBois if you
haven't already, it's a
> fantastic book and widely known on the MySQL mailing list as the MySQL
bible. :-)
>
> Okay, so you have a table called bob or something, and your id is
auto_increment, and you want to
> know what the last ID was from php. You've done an
>
> INSERT INTO bob VALUES (NULL,'myname',300)
>
> with php, and now you wanna know what it thinks id is. You need to
remember what you named your
> connection variable, and pass that to mysql_insert_id like so:
>
> $last_ID = mysql_insert_id($this_connection);
>
> Auto_increment works on a per-connection basis, such that it will remember
only the last ID for this
> specific connection, and as such you need to tell it which connection to
get the ID for, NOT which
> query did the insert (that's what I thought it needed originally, didn't
work very well).
>
> I hope that explains, lemme know if it doesn't :-)
>
> Cheers,
>
> # Nathan
--- End Message ---
--- Begin Message ---
> Yeah, I seem to have a talent for pissing people of
> unintentally, and Julie seemed to have gotten more than a
> little pissed at me. Anyway, the reason I didnt specify the
Perhaps the problem is that you're asking a question that you could
solve yourself.
You asked about mysql_insert_id() and what it would tell you. Surely
the easiest way to do that would be to _USE_ that function and examine
the result. You have a web server, you have php and you have a mysql
server. You can, and if you can't then you should immediately correct
that, examine the raw data in your database. Because of that you can
see what you expect the relevant part of your code to return by looking
at the raw data and then see if the code returns the correct data. If
it doesn't then you can start figuring out why.
For anyone else to answer your question you're asking them to figure out
what you're doing, probably ask more questions to figure out what you
could have told them first time around, provide a general answer to
which you will reply that it doesn't work, have them ask for your source
code so they can look at it, have them set the source code up as a test
in their own development environment, etc, etc ,etc.
Sorry, but this almost comes down to basic programming technique - if
you want to do something apply some logic to what you want to achieve
and then figure out a way to do it. If you think you've found a way,
test it. If it doesn't work, try something else. If you are getting
nowhere and decide to ask a question here, at least give some
indications of what you've tried and had not work.
Just some thoughts, and while directed at you, could equally apply to
many others in here (no doubt myself included at times).
CYA, Dave
--- End Message ---
--- Begin Message ---
I am *very* new to PHP & am trying to write a tool where a user can add books to a
library MySQL database.
The user fills out an HTML form. I do some form validation & if the form entries are
ok, I need to run some SQL queries using the form variables.
I have the HTML form posting back to itself to do the error checking. The part I am
unclear on is how to handle the SQL queries.
I was thinking that if the user filled out the form correctly, I could redirect to a
new php script/page to handle the SQL queries. The problem is that if I do so, I do
not have access to the form variables that I need. The only way I know to pass
variables to a new script is through a form posting & it doesn't make sense to have 2
form postings for one form.
I suppose I could run the SQL queries from the same script although when I use my
below logic, the SQL queries print out underneath the HTML form which looks pretty bad.
I was thinking that if I approach it this way, I need some way to loop back through
all my "if" statements so that I could catch the last one only ($REQUEST_METHOD ==
"post" && $validated == "yes")
and therefore wouldn't get the HTML form again. I tried putting a while(true){ } loop
around the entire thing which resulted in printing my HTML table infinity times :)
I included a pseudocode form of my logic here & my actual code below.
If anyone has any thoughts, suggestions, ideas, or comments, I'd really appreciate it!
Also, is there a good IRC channel for php users?
Laura
[EMAIL PROTECTED]
Instant Messenger: lefindley
if ($REQUEST_METHOD != "POST"){
include("./form.html");
} else if ($REQUEST_METHOD == "POST" && $validated == "no"){
perform error checking
display errors at top of page
include("./form.html");
} else if ($REQUEST_METHOD == "POST" && $validated
== "yes") {
**here is where I need to run the SQL queries**
}
--------------------------------------------------
<?
$err = "";
$validated = "no";
// display form for user to fill out
if ($REQUEST_METHOD != "POST") {
include("./form.html");
} else if ($REQUEST_METHOD == "POST" && $validated == "no") {
// if user is submitting the form, do error
// checking. if there are errors, display them at
// the beginning of the form
if ($book_title == ""){
$err .= "<LI><font color="red">Book title cannot be blank!</font><br>";
}
if ($author == "") {
$err .= "<LI><font color="red">Author cannot be left blank!</font><br>"; }
if ($author != ""){
if (!ereg('[a-zA-Z]', $author)){
$err .= "<LI><font color="red">Author name must be " .
"letters!</font><br>";
}
}
if ($price == ""){
$err .= "<LI><font color="red">Price cannot be left blank!</font><br>";
}
if ($price != ""){
if (!is_numeric($price)){
$err .= "<LI><font color="red">Price must be numbers!</font><br>";
}
}
if ($isbn == ""){
$err .= "<LI><font color="red">ISBN cannot be left blank!</font><br>";
}
if ($isbn != ""){
if (!is_numeric($isbn)){
$err .= "<LI><font color="red">ISBN must be numbers!</font><br>";
}
}
if ($num_copies != ""){
if (!is_numeric($num_copies)){
$err .= "<LI><font color="red"># of copies must be ".
" numbers!</font><br>";
}
}
if ($checked_out != ""){
if (!is_numeric($checked_out)){
$err .= "<LI><font color="red"># of checked out copies must be " .
if ($checked_out != ""){
if (!is_numeric($checked_out)){
$err .= "<LI><font color="red"># of checked out copies must be " .
" numbers!</font><br>";
}
}
if (is_numeric($checked_out) && is_numeric($num_copies)){
if ($checked_out > $num_copies){
$err .= "<LI><font color="red"># of copies checked out cannot " .
"exceed number of copies in library!</font><br>";
}
}
include("./form.html");
if ($err == ""){
$validated = "yes";
break;
}
print "Validated: $validated";
} // end of else if
if ($REQUEST_METHOD == "POST" && $validated == "yes"){
// if user has correctly filled out the form, I
// need to run some MySQL queries using the form // variables - not sure if it is best
to do this // on the same page or redirect to another.
// if i run the SQL queries from the same page,
// i need to be able to not display the HTML form
// if i redirect to another script, I need a way
// to pass the form variables
print "do some SQL stuff";
}
?>
--- End Message ---
--- Begin Message ---
> I included a pseudocode form of my logic here & my actual code below.
A suggestion in similar pseudo code.
"top of page"
"set a flag to display form"
If (form submitted)
{
"validate entered data"
if (data is correctly validated)
{
"enter data into database"
if (database operation ok)
{
"include database ok page"
"clear a flag to display form"
} else {
"include database error page"
"clear a flag to display form" (or not, depends on how you want to
deal with this)
}
} else {
"display information about data entry problems"
"set a flag to display form"
}
}
If (flag to display form is set)
{
"display form"
}
"end of page"
This is much the same as yours but permits you to handle the whole thing
in one page without having to re-display the form if you don't need to.
I use this basic layout all the time and it has the advantage that you
can keep the form but clear the data if you're expecting someone to
enter more data into the thing.
This method can also let you redisplay the form with data already
provided in cases where the form validation has failed. You can also
display the relevant validation errors in a way that highlights the
problem within the actual form.
CYA, Dave
--- End Message ---
--- Begin Message ---
Okay so this is what I'm trying, basically for the
purposes of posting a news article I want to be able
to upload supporting text files with the content of
the article. Here's what I've got so far... I think
I've totally missed the mark or understood the
documentation in the manual on this... Someone please
set me straight:
<?php
/*Some loops will be added to this after variables
from the previous page. This is why this has been
printed into PHP format.*/
print("<form action=\"process_form.php\"
method=\"post\" enctype=\"multipart/form-data\">");
print("First File: <input name=\"userfile[0]\"
type=\"file\"><br>");
print("Second File: <input name=\"userfile[1]\"
type=\"file\"><br>");
print("<input type=\"submit\" value=\"Upload
Files\">");
print("</form>");
?>
This is the catch file...:
<?php
if
(is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'][0]))
{
copy($HTTP_POST_FILES['userfile']['tmp_name'][0],
"articles/placetogo");
copy($HTTP_POST_FILES['userfile']['tmp_name'][1],
"articles/placetogo");
print("Files Loaded Successfully!");
} else {
print("Unable to Load Files");
}
?>
Any help is appreciated. Sorry if the formatting on
this came out strange.
__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com
--- End Message ---
--- Begin Message ---
Only one value from a msSQL field.
I have many values the same in a field and would like to know how i can select one of
each (not mating).
$sql = "SELECT * FROM brands WHERE 1 ORDER BY `sId` DESC LIMIT 6";
lists everything ..
ANy help would be cool.
Phil
--- End Message ---