|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general-digest-help_at_lists.php.net
Date: Mon Aug 26 2002 - 10:57:41 CDT
php-general Digest 26 Aug 2002 15:57:41 -0000 Issue 1548
Topics (messages 114097 through 114151):
Re: Can someone - anyone see my error?
114097 by: . Edwin
Re: Base64 and MS Word cutting and pasting.
114098 by: . Edwin
Re: Call to undefined function mysql_connect()
114099 by: hugh danaher
114100 by: Peter Houchin
114101 by: Peter Houchin
Blank db entry??
114102 by: JohnP
114103 by: JohnP
114114 by: . Edwin
114120 by: David Robley
Re: PHP and LDAP over SSL
114104 by: Stig Venaas
php newsletter source
114105 by: adi
114106 by: Manuel Lemos
newbie... - undefined var
114107 by: Matt Zur
114109 by: Chris Shiflett
114111 by: Jonni
114112 by: . Edwin
Problems with the safe mode...
114108 by: Sebastian Tomasino
114110 by: . Edwin
Re: known bugs in current CHM, contribution appreciated!
114113 by: Dallas Thunder
Re: Attachements
114115 by: MikeTsapenko
Virtual includes
114116 by: Gregory Barker
114117 by: David T-G
114118 by: Scott Houseman
114121 by: David Robley
Re: carriage return/line break problem
114119 by: David T-G
Re: php equivalient of pushd?
114122 by: David T-G
Re: Shell commands as root?
114123 by: David T-G
Re: error message: Nesting level too deep - recursive dependency?
114124 by: Ondrej Ivanic
Re: Doing system things with PHP
114125 by: Eric Pignot
114126 by: David T-G
Re: search in serialized string
114127 by: Rodrigo Peres
114133 by: DL Neil
check unread messages in a forum
114128 by: Charlotte
114131 by: Matt Schroebel
114132 by: Stas Maximov
114135 by: Eric Pignot
114136 by: Eric Pignot
curl and UTF-8
114129 by: Merijn van den Kroonenberg
make problems, sapi
114130 by: Jesse Lawrence
Object member variable names
114134 by: Karl Moritz Hermann
strange error message when trying to start apache
114137 by: Jesse Lawrence
PHP/MYSQL query error
114138 by: Chris Crane
114139 by: Chris Crane
114140 by: Jay Blanchard
114141 by: Chris Crane
114142 by: Chris Crane
114143 by: Justin French
114146 by: Chris Crane
114148 by: Chris Crane
Re: Help with script
114144 by: Erich Kolb
curl and UTF-8, follow up
114145 by: Merijn van den Kroonenberg
Re: Automatic Download using URL, HELP!
114147 by: Hankley, Chip
New to PHP/mySQL - Help on script
114149 by: Ray Healy \(Data Net Services\)
114151 by: Adam Williams
Re: set filename of file open/download
114150 by: Roger Lewis
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
Just curious... Have you tried it with POSTed variables? As in the case
mentioned?
Just wondering... Anyway, I'll try it myself later...
- E
>
>using register_globals=on and trying to echo out the $5400 errors as
>expected, but php sees the correct entry in the $_GET superglobal array as
>it should. running a simple foreach($_GET as $key => $val) returns a key
of
>5400 and a value of 1000 on a page with the querystring of
>page.php?5400=1000, so you should be able to pull that info into another
>variable correctly.
>
>Jason Reid
>jason
achost.ca
>--
>AC Host Canada
>www.achost.ca
>
>----- Original Message -----
>From: "Eric Pignot" <eric.pignot
alinto.com>
>To: <php-general
lists.php.net>
>Sent: Sunday, August 25, 2002 7:24 PM
>Subject: [PHP] Re: Can someone - anyone see my error?
>
>
> > > <form enctype="multipart/form-data" action="postbit.php"
method="post">
> > > <input type="hidden" name="5400" value="1000">
> > > Send this file: <input name="userfile" type="file">
> > > <input type="submit" value="Send File">
> > > </form>
> >
> > I am not really replying to your question, but just as a remark, in
php, a
> > variable needs to start with a letter or and underscire. (must be
detailed
> > in the doc)
> > So I have absolutely no idea how PHP will interpret this line :
> > <input type="hidden" name="5400" value="1000">
> > (and I would be curious to know how it actually does ! can you tell me
? )
> >
> > bye
> >
> > Eric
> >
> >
> >
> > --
> > 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
_________________________________________________________________
$B%O%$%;%s%9$J>&IJ$r5$7Z$K9XF~(B MSN $B%7%g%C%T%s%0(B http://shopping.msn.co.jp/
attached mail follows:
I see. It seems like, asking the users to copy from Word to Notepad then to
the textarea is not really an option so I guess you really need to find a
way how to fix it.
How about Manuel Lemos' advice posted earlier?
BTW, I was just wondering if you've also considered that the problem might
be on the mail client side itself. Because you said that "not all mail
clients..." so at least on some it worked. When you said that with Notepad
there's no problem, did you mean that ALL mail clients worked as you
expected?
Also, I wonder what these "pasted text" are. Perhaps, you can give some
samples?
I don't really think that I can be of so much help but I'm just curious...
- E
PS
Just in case you haven't seen it. I think, there's a related topic
discussed in phpbuilder.com. Here's the address:
http://www.phpbuilder.com/columns/kartic20000807.php3
>
>I've isolated the problem with MS Word and MS Wordpad; The problem does
not
>occur when pasting from Notepad. I want to make sure that all the text is
>ASCII before converting to MIME encoding. This shoul alleviate the
problems
>that are occuring.
>
>Thanks,
>/dkm
>
>
>----- Original Message -----
>From: "
Edwin" <copperwalls
hotmail.com>
>To: <dmoore
ravens-nest.com>
>Cc: <php-general
lists.php.net>
>Sent: Saturday, August 24, 2002 6:37 PM
>Subject: Re: [PHP] Base64 and MS Word cutting and pasting.
>
>
> > Just some ideas.
> >
> > First, to check if it's really the pasted text from MS Word that is
really
> > causing the problem, paste the text from MS Word to a text editor like
> > "notepad" THEN from "notepad" copy and paste to the <textarea> and see
if
> > the problem is still there.
> >
> > If it's still there, well, that means it's a different problem.
> >
> > Perhaps, it's about the "quotes and apostrophes" that you've mention so
> > it'd be better to check the manual. See addslashes() or stripslashes().
> >
> > Or, the problem could be something else. But, I don't really think it's
> > because the pasted text is from MS Word... (Pasted text to the textarea
> > should have been already converted...)
> >
> > - E
> >
> > >
> > >I have an application which uses the <textarea> tag for users to input
> > data. This works fine. However, some users are using MS Word to
generate
> > the text and then cutting and pasting into the <textarea>. This works
>fine
> > as well.
> > >
> > >However, I am encountering a problem when the application mails the
> > submitted content. Everything is viewed fine throught the web. We are
> > MIME encoding the message using base64 functions. The problem is that
not
> > all email clients are decoding the MS Word pasted content properly.
> > Quotes and apostrophes are not being decoded properly.
> > >
> > >I assume the problem is that the MS Word pasted content is not ASCII.
>I
> > need to convert this content to ASCII before we encode the MIME
message.
> > >
> > >Do you have any ideas?
> > >
> > >/dkm
> >
> >
> >
> >
> > _________________________________________________________________
> > $B%&%#%k%9%a!<%k!"LBOG%a!<%kBP:v$J$i(B MSN Hotmail
http://www.hotmail.com/JA
> >
> >
> > --
> > 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
>
_________________________________________________________________
$B$+$o$$$/$FL{2w$J%$%i%9%HK~:\(B MSN $B%-%c%i%/%?!<(B http://character.msn.co.jp/
attached mail follows:
Thanks Edwin, I'll forward your notes to my new host. I also checked the
archives and find that there's an extension=mysql.so snip that needs to go
in the php.ini file, and I'll forward this to my host too.
Thanks,
Hugh
----- Original Message -----
From: "
Edwin" <copperwalls
hotmail.com>
To: <hdanaher
earthlink.net>
Cc: <php-general
lists.php.net>
Sent: Sunday, August 25, 2002 8:54 PM
Subject: Re: [PHP] Call to undefined function mysql_connect()
>
> >
> >Help!
> >
> >I am getting the following error message for :
> ><?
> > $link=mysql_connect("localhost","$user","$pass"); // line 34
> >?>
> >
> >Fatal error: Call to undefined function: mysql_connect() in
> /home/www/test.somename.org/aux/db-mod.php on line 34
> >
> >I have used this call successfully on php v4.0.6, and am now trying it on
> a new install (which someone else did, as I haven't a clue in setting up a
> server) which is v4.1.1. Is mysql_connect a defunct command, or do I need
> to do something to enable its use?
>
> Perhaps, if you check the manual you'll see if a certain function is
> already "defunct".
>
> Checking mysql_connect() here,
>
> http://www.php.net/manual/en/function.mysql-connect.php
>
> shows that it's even "better" than before.
>
> So, most probably, when the person who set up the server didn't include
> mysql support in php. It'd be better to ask the person to enable it.
>
> BTW, you can do phpinfo() and see if mysql support is enabled or not. (Of
> course, you also need to check IF MySQL is even installed...)
>
> - E
>
>
> >
> >Thanks for any help.
> >Hugh
> >
> >
> >
> >
> >
> >
>
>
>
>
> _________________________________________________________________
> $B2q0wEPO?$OL5NA!&=<<B$7$?=PIJ%"%$%F%`$J$i(B MSN $B%*!<%/%7%g%s(B
> http://auction.msn.co.jp/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
attached mail follows:
do a php_info() on a page and check the mysql propeties in there.. might
give you a clue..
> -----Original Message-----
> From: hugh danaher [mailto:hdanaher
earthlink.net]
> Sent: Monday, 26 August 2002 1:18 PM
> To: php
> Subject: [PHP] Call to undefined function mysql_connect()
>
>
> Help!
>
> I am getting the following error message for :
> <?
> $link=mysql_connect("localhost","$user","$pass"); // line 34
> ?>
>
> Fatal error: Call to undefined function: mysql_connect() in
> /home/www/test.somename.org/aux/db-mod.php on line 34
>
> I have used this call successfully on php v4.0.6, and am now
> trying it on a new install (which someone else did, as I haven't
> a clue in setting up a server) which is v4.1.1. Is mysql_connect
> a defunct command, or do I need to do something to enable its use?
>
> Thanks for any help.
> Hugh
>
>
>
>
>
>
>
attached mail follows:
do a php_info() on a page and check the mysql propeties in there.. might
give you a clue..
> -----Original Message-----
> From: hugh danaher [mailto:hdanaher
earthlink.net]
> Sent: Monday, 26 August 2002 1:18 PM
> To: php
> Subject: [PHP] Call to undefined function mysql_connect()
>
>
> Help!
>
> I am getting the following error message for :
> <?
> $link=mysql_connect("localhost","$user","$pass"); // line 34
> ?>
>
> Fatal error: Call to undefined function: mysql_connect() in
> /home/www/test.somename.org/aux/db-mod.php on line 34
>
> I have used this call successfully on php v4.0.6, and am now
> trying it on a new install (which someone else did, as I haven't
> a clue in setting up a server) which is v4.1.1. Is mysql_connect
> a defunct command, or do I need to do something to enable its use?
>
> Thanks for any help.
> Hugh
>
>
>
>
>
>
>
attached mail follows:
Ok I have a script done but it does not work - If there is no info in the db row I need the script to detect that and enter a number - the problem I am having is that if the row is empty it will return nothing - is there a function or something else that you can use to return true if a db row is completly empty??
Thanks - JohnP
attached mail follows:
Forgot to add one thing - I don't need to add the new number after detection
to the db but rather just print it out
"Johnp" <aerc
aerc.biz> wrote in message
news:20020826061357.78598.qmail
pb1.pair.com...
Ok I have a script done but it does not work - If there is no info in the db
row I need the script to detect that and enter a number - the problem I am
having is that if the row is empty it will return nothing - is there a
function or something else that you can use to return true if a db row is
completly empty??
Thanks - JohnP
attached mail follows:
I think you can use this:
http://www.php.net/manual/en/function.mysql-num-rows.php
- E
>
>Forgot to add one thing - I don't need to add the new number after
detection
>to the db but rather just print it out
>
>
>"Johnp" <aerc
aerc.biz> wrote in message
>news:20020826061357.78598.qmail
pb1.pair.com...
>Ok I have a script done but it does not work - If there is no info in the
db
>row I need the script to detect that and enter a number - the problem I am
>having is that if the row is empty it will return nothing - is there a
>function or something else that you can use to return true if a db row is
>completly empty??
>
>Thanks - JohnP
>
>
>
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
_________________________________________________________________
$B%&%#%k%9%a!<%k!"LBOG%a!<%kBP:v$J$i(B MSN Hotmail http://www.hotmail.com/JA
attached mail follows:
In article <20020826063452.94194.qmail
pb1.pair.com>, aerc
aerc.biz
says...
> Forgot to add one thing - I don't need to add the new number after detection
> to the db but rather just print it out
>
>
> "Johnp" <aerc
aerc.biz> wrote in message
> news:20020826061357.78598.qmail
pb1.pair.com...
> Ok I have a script done but it does not work - If there is no info in the db
> row I need the script to detect that and enter a number - the problem I am
> having is that if the row is empty it will return nothing - is there a
> function or something else that you can use to return true if a db row is
> completly empty??
>
> Thanks - JohnP
Perhaps if you can show the code that doesn't work?
-- David Robley Temporary Kiwi!Quod subigo farinam
attached mail follows:
On Fri, Aug 23, 2002 at 11:52:11AM -0500, Curtis Robinson wrote: > So, I see that php does not have the CA. But, I have no clue as to where > to define the location of the CA in the php configuration. So, does > anyone know how I can configure this option?
Are you using OpenLDAP? The below is only valid for OpenLDAP.
When you tested on the command line, didn't you modify your ldap.conf? Anyway, in ldap.conf you can specify:
TLS_CACERT /path/to/ca.crt
Make sure that this file is readable by your webserver.
You might also want to specify the following in .ldaprc (in the users home directory):
TLS_CERT /path/to/client.crt TLS_KEY /path/to/client.key
If you run apache as say nobody, they must be in the home directory of nobody I guess...
Stig
attached mail follows:
Hi, there is a newsletter or massmailer(open source), created with php, with option for sending mail with attashments to groups of clients? I tried phpmailer,DeepThroat,MyMail but atashments are not permitted, or only html and text. Any other sources? tx in advance for any help adi
attached mail follows:
Hello,
On 08/26/2002 03:49 AM, Adi wrote: > Hi, > there is a newsletter or massmailer(open source), created with php, with option for sending mail with attashments to groups of clients? > I tried phpmailer,DeepThroat,MyMail but atashments are not permitted, or only html and text. > Any other sources?
This class lets you compose messages with attachments, in text, HTML with embededed images or not, HTML with alternative text, etc...
http://www.phpclasses.org/mimemessage
--Regards, Manuel Lemos
attached mail follows:
I'm just starting to learn php and have a quick question. I'm making a site with file includes. so for example my default page will be: index.php and services page with be called services.php
BUT... I want to link to services via this method: index.php?vw=services
Still no problem there.
BUT on the index.php I want to write this if statement:
if ($vw == "") { write this code }
But then I get an error that the var is non defined. Do all vars in PHP have to be defined first? If it isn't defined, doesn't the program assume it's value is nothing?
-Matt
-- Matt Zur mattzzurnet.com http://www.zurnet.com
Need a Web Site??? - Visit... www.zurnet.com
1997 - 2002 - 5th Anniversary!!!
attached mail follows:
Matt Zur wrote:
> BUT on the index.php I want to write this if statement: > > if ($vw == "") { > write this code > }
If you really mean to see if the variable has been set, try this instead:
if (!isset($vw)) { echo "variable is not set"; }
Happy hacking.
Chris
attached mail follows:
try using a switch statement.
<?
switch($vw)
{
case "":
include "intro.php";
break;
case "services":
include "services.php";
break;
case "next":
include "next.php";
default:
include "error.php";
break;
}
?>
> -----Original Message-----
> From: Matt Zur [mailto:mattz
zurnet.com]
> Sent: Monday, August 26, 2002 12:41 AM
> To: php-general
lists.php.net
> Subject: [PHP] newbie... - undefined var
>
>
> I'm just starting to learn php and have a quick question. I'm making a
> site with file includes. so for example my default page will be:
> index.php and services page with be called services.php
>
> BUT... I want to link to services via this method:
> index.php?vw=services
>
> Still no problem there.
>
> BUT on the index.php I want to write this if statement:
>
> if ($vw == "") {
> write this code
> }
>
> But then I get an error that the var is non defined. Do all
> vars in PHP
> have to be defined first? If it isn't defined, doesn't the program
> assume it's value is nothing?
>
> -Matt
attached mail follows:
Or, perhaps, you should do: (if register_globals off)
if (!isset($_GET['vw'])){ echo "variable is not set"; }
Of course, you can also do: (if you want to--for some reason)
if ($_GET['vw'] == ""){ write this code }
- E
PS > Do all vars in PHP have to be defined first?
No.
> >Matt Zur wrote: > >>BUT on the index.php I want to write this if statement: >> >>if ($vw == "") { >>write this code >>} > > >If you really mean to see if the variable has been set, try this >instead: > >if (!isset($vw)) >{ > echo "variable is not set"; >} > >Happy hacking. > >Chris > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php
_________________________________________________________________ $B:G?7$N%U%!%$%J%s%9>pJs$H%i%$%U%W%i%s$N%"%I%P%$%9(B MSN $B%^%M!<(B http://money.msn.co.jp/
attached mail follows:
Hi everyone... I have some problem with the safe mode of php. i get this errors when i try to access the file. ---------------------------------------------------------------------- PHP Warning: SAFE MODE Restriction in effect. The script whose uid/gid is -1/-1 is not allowed to access data.txt owned by uid/gid 0/0 in /var/www/htdocs/ntfs/cap10/handlefile.php on line 7
PHP Warning: fopen("data.txt", "a+") - No such file or directory in /var/www/htdocs/ntfs/cap10/handlefile.php on line 7 ------------------------------------------------------------------------- I donīt know why uid-gid = -1/-1 ??. i che the user and permissions more than once and everything is ok. Itīs seems like php not recognize the permissions of the script but yes recognize well the permissions of the data.txt. Hi read that php 4.2.2 have alpha support for apache 2.0.39/40. is that it?
In my winXP configuration (apache 2.0.40 php 4.2.2) have the same problem but, when i switch from isapi mode and run php in the normal mode, recognize the correct file user/group permissions. But in my slack 8.1 conf (apache 2.0.39 php 4.2.2) i dont know what to do... Any Ideas ???
Thanks for your help... Sebastian
attached mail follows:
I'm not sure but...
Check your httpd.conf and see if you're running Apache as "Group -1". Change this to "nobody" or better yet make a new user/group (like apache/apache for example) for your Apache and change the lines-
User nobody Group -1
to
User apache Group apache
Then, restart Apache after making the changes.
Also, try chmod(ing) 777 "data.txt" and see what happens... (You can even try changing the owner of "data.txt" itself...)
- E
> >Hi everyone... >I have some problem with the safe mode of php. >i get this errors when i try to access the file. >---------------------------------------------------------------------- >PHP Warning: SAFE MODE Restriction in effect. The script whose >uid/gid is -1/-1 is not allowed to access data.txt owned by uid/gid >0/0 in /var/www/htdocs/ntfs/cap10/handlefile.php on line 7 > >PHP Warning: fopen("data.txt", "a+") - No such file or directory in >/var/www/htdocs/ntfs/cap10/handlefile.php on line 7 >------------------------------------------------------------------------- >I don$B%((Bt know why uid-gid = -1/-1 ??. i che the user and permissions >more than once and everything is ok. It$B%((Bs seems like php not >recognize the permissions of the script but yes recognize well the >permissions of the data.txt. >Hi read that php 4.2.2 have alpha support for apache 2.0.39/40. is >that it? > >In my winXP configuration (apache 2.0.40 php 4.2.2) have the same >problem but, when i switch from isapi mode and run php in the normal >mode, recognize the correct file user/group permissions. >But in my slack 8.1 conf (apache 2.0.39 php 4.2.2) i dont know what >to do... Any Ideas ??? > >Thanks for your help... >Sebastian > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php
_________________________________________________________________ $B%O%$%;%s%9$J>&IJ$r5$7Z$K9XF~(B MSN $B%7%g%C%T%s%0(B http://shopping.msn.co.jp/
attached mail follows:
I'm using IE6 under WinXP, I've encountered all the three known bugs in Sample7. The third one is really unacceptable.
attached mail follows:
"Oliver Witt" <oliverwitt
t-online.de> ???????/???????? ? ????????
?????????: news:3D673047.F9FCA733
t-online.de...
> Hi,
> Can you attach files to emails and send them through a php script? If
> so, how?
> Kind regards,
> Oliver
>
You can use this function. It can attach just one file. $mode = message type: plain (default) or HTML otherwise
function SendMail($email,$subject,$body,$from="",$mode="plain",$file_name="",$file_ty pe="",$no_template=0) { $body_prefix=""; $body_suffix=""; $from_suffix="";
if(!empty($file_name)) { $file=fopen($file_name,"r"); if($file) { $file_content=""; while(!feof($file)) $file_content.=fread($file,4096); fclose($file);
$file_name=basename($file_name);
$body_prefix="This is a multi-part message in MIME format.
------Part012345678 Content-Type: text/$mode; charset=\"ISO-8859-1\"
"; $body_suffix="
------Part012345678 Content-Type: ".( empty($file_type) ? "application/octet-stream" : $file_type )."; name=\"$file_name\" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=\"$file_name\"
".chunk_split(base64_encode($file_content))." ------Part012345678-- "; $from_suffix=" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=\"----Part012345678\""; } } else { $from_suffix=" MIME-Version: 1.0 Content-Type: text/$mode; charset=\"ISO-8859-1\""; }
$result=
mail(trim($email),trim($subject),$body_prefix.$body.$body_suffix,"F
rom: ".$from.$from_suffix);
return $result;
}
WBR, Mike Tsapenko Chief of Web-development Dept. AlarIT http://www.AlarIT.com
attached mail follows:
Hi all,
I'm trying include .php files which reside in alternative directories or sub-directories. Such as a file which reside in www/chat/page.php, and for this page I would like to include a file which resides in www/forum/include/
I've tried the following which just results in a error: include '/forum/include/test.php'; aqnd multiple variations of it.
How do I get around this problem?
Greg
attached mail follows:
Gregory --
[You know, you shouldn't just reply to any old message and start a new topic; send a fresh message to the list instead so that it will be the start of a new thread.]
...and then Gregory Barker said... % % Hi all,
Hello!
% % I'm trying include .php files which reside in alternative directories or % sub-directories. Such as a file which reside in www/chat/page.php, and for % this page I would like to include a file which resides in www/forum/include/
That can definitely be done.
% % I've tried the following which just results in a error: % include '/forum/include/test.php'; aqnd multiple variations of it.
Ah, but you're using the website-based path instead of the actual path in the filesystem. You're not including a URL, but a file, so you should spell it out.
% % How do I get around this problem?
The simplest way to start is to just give the full path:
include /path/to/site/www/forum/include/test.php ;
although that begins to be cumbersome once you start including lots of stuff from here and there. You might simplify it a bit and just
include $_SERVER[DOCUMENT_ROOT]/forum/include/test.php ;
to make your code reusable in any web site dir, since the variable will expand to whatever the doc root is (like /path/to/site/www). You might want to be even more general, though, and pull something from the parent directory; you might use
$currdir = getcwd() ; include $currdir . "/../parentdirfile.php" ;
to do that.
As always, RTFM. See "Directory functions" and "Filesystem functions" for starters on this type of task.
% % Greg
HTH & HAND
:-D
-- David T-G * It's easier to fight for one's principles (play) davidtgjustpickone.org * than to live up to them. -- fortune cookie (work) davidtgwork
justpickone.org http://www.justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD)
iD8DBQE9afiAGb7uCXufRwARAmj1AJ9vZ8E04ap8BAgdnpeDb0LaLVX2IgCfUQ6T e9qxf8ixc1Rgq+/HAzVr/lw= =rViJ -----END PGP SIGNATURE-----
attached mail follows:
Hi there.
This should work I think.
include( '../forum/include/test.php' );
This uses the path in relation to the current directory the script resides in.
Regards
-Scott
> -----Original Message-----
> From: Gregory Barker [mailto:gregb
exclusivebooks.com]
> Sent: 26 August 2002 11:12
> To: php-general
lists.php.net
> Subject: [PHP] Virtual includes
>
>
> Hi all,
>
> I'm trying include .php files which reside in alternative directories or
> sub-directories. Such as a file which reside in www/chat/page.php, and for
> this page I would like to include a file which resides in
> www/forum/include/
>
> I've tried the following which just results in a error:
> include '/forum/include/test.php'; aqnd multiple variations of it.
>
> How do I get around this problem?
>
> Greg
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
In article <01d301c24ce0$a818d460$63a429c4
tech01>,
gregb
exclusivebooks.com says...
> Hi all,
>
> I'm trying include .php files which reside in alternative directories or
> sub-directories. Such as a file which reside in www/chat/page.php, and for
> this page I would like to include a file which resides in www/forum/include/
>
> I've tried the following which just results in a error:
> include '/forum/include/test.php'; aqnd multiple variations of it.
>
> How do I get around this problem?
>
> Greg
>
>
If you are including from the local file system, you need to use the full
pathname, not the URI.
Assuming www is really /www, you would need
include '/www/forum/include/test.php'
-- David Robley Temporary Kiwi!Quod subigo farinam
attached mail follows:
Pag --
...and then Pag said... % % At 16:46 24-08-2002 +0200, Bas Jobsen wrote: % >use nl2br($content); % % I assume i should use that function when sending to the page,
Right; it will convert newlines to linebreaks.
% after retrieving the text from the DB, right? Cant i do something when
That's generally when one would do it. I tend to just use <pre> tags when I need to preserve line breaks rather than converting content, personally.
% getting the text TO the db and then when i need it, i can just retrieve it, % ready to be put on the page?
If you don't mind having HTML code in the database, then go ahead and convert it a la
$content = nl2br($content) ;
before writing it to the DB and then it will be that way when it comes out.
% % Thanks.
Sure thing!
% % Pag
HTH & HAND
:-D
-- David T-G * It's easier to fight for one's principles (play) davidtgjustpickone.org * than to live up to them. -- fortune cookie (work) davidtgwork
justpickone.org http://www.justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD)
iD8DBQE9afnsGb7uCXufRwARAr3uAJ9CR9VmVHD2WYwT4KBezdzjlKTMPQCfSPDC bRv2IIniDqsAYvQoKNOGYXc= =bMaG -----END PGP SIGNATURE-----
attached mail follows:
Bill --
...and then bill said... % % I'm running a php script using cron, and want to change the working directory.
Piece of cake; use the chdir command.
% % Is there a PHP equivalent of Linux pushd command?
Why do you want to pushd? Do you have any intention of coming back to the initial directory? Note that pushd is meant to be used when you expect to pop off of the stack and not just as a cd/chdir replacement...
If you really did need a pushd function, you might declare a $dirlist array and then use the array_push() and array_pop() functions to do the work for you. See the Fine Manual for more info.
% % kind regards, % % bill hollett
HTH & HAND
:-D
-- David T-G * It's easier to fight for one's principles (play) davidtgjustpickone.org * than to live up to them. -- fortune cookie (work) davidtgwork
justpickone.org http://www.justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD)
iD8DBQE9afrbGb7uCXufRwARAoF0AJ42HHGrLo9JhP8a2heZQ68I37Q56ACcDfNL TRY5ECd0knyTC2Z43eqkALs= =iN27 -----END PGP SIGNATURE-----
attached mail follows:
Nick --
...and then Nick Price said... % % How can I get PHP to run a shell command as root? Thanks!
If [apache running] php is running as root (bad), then just run the command.
If the user running [apache running] php (typically "nobody" or "http" or "web" or such) has sudo permissions (generally bad), then use sudo.
When all else fails (typically for a reason), you could just turn on the SUID bit on that command, or its wrapper script, and then just run it (also generally bad).
Why do you want your web server to run a command as root?
HTH & HAND
:-D
-- David T-G * It's easier to fight for one's principles (play) davidtgjustpickone.org * than to live up to them. -- fortune cookie (work) davidtgwork
justpickone.org http://www.justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD)
iD8DBQE9afvtGb7uCXufRwARAgQoAJ4rP1+YO3mRLIPl0geWSKHqqpFfswCfbip1 BMwIEtthrgVxWNw7VltUjRk= =NXF+ -----END PGP SIGNATURE-----
attached mail follows:
Richard Lynch wrote: > It still boggles my mind that you'd want to even *do* all this when you have > a built-in array type that can do everything you've done about a zillion > times faster...
1)I'm programing with php-oop for a few months. I need to know how to PHP work with references, class, ... .
2) I need data stucture like this: method add($object): append object (anywhere, position is not important) method remove($object): remove object method item($index): get object at $index
with array??? There is a identical problem: deep recursion. Object1 have references to object2 across Object3 which have ... and vice versa.
Function uniqid() (or microtime()) is quite good, but is not a clear solution.
For example:
class Storage { $container = array();
function add(&$object) { $objectID = microtime(); $object->__uniqueObjectID__ = $objectID; $this->container[$objectID] = $object; }
function remove(&$object) { unset($this->container[$object->__uniqueObjectID__]; }
function item($index) { $keys = array_keys($this->container); return $this->container[$keys[$index]] } }
Grrr... to many problems:
1) adding variable to the third-party object 2) in remove() method: remove __uniqueObjectID__ varible from object or not??? 3) if exists __uniqueObjectID__ variable replace with new value or keep current value??? 4) Zend Engine 2.0 __clone() method: $obj = new MyObject(); Storage->add($obj); $obj2 = $obj.__clone(); Storage->remove($obj2); // Error: I want remove Obj2 not Obj1
and more...
-- Ondrej Ivanic (ondrejkmit.sk)
attached mail follows:
> kill -HUP `cat /var/run/httpd.pid`
>
> If you execute this as nobody, I believe it will work, but I haven't
> tested it.
nope, it won't, as you need to be the owner to send a signal to a process.
regards.
Eric
attached mail follows:
Eric, et al --
...and then Eric Pignot said... % % > kill -HUP `cat /var/run/httpd.pid` % > % > If you execute this as nobody, I believe it will work, but I haven't % > tested it. % % nope, it won't, as you need to be the owner to send a signal to a process.
And if the web server is running as nobody, as it probably should be, then... ?
% % regards. % % Eric
HTH & HAND
:-D
-- David T-G * It's easier to fight for one's principles (play) davidtgjustpickone.org * than to live up to them. -- fortune cookie (work) davidtgwork
justpickone.org http://www.justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.7 (FreeBSD)
iD8DBQE9aggKGb7uCXufRwARAkTBAJ45D5x6q1jS3TBr8SUfm33OYXIGUACfQu2G H4a8f2P0XyjtjG/VnFSmBYk= =4mar -----END PGP SIGNATURE-----
attached mail follows:
well, I my opinion is not the way to work, but like I said the work was done by other guy, and now I have the problem to solve. So i back to old question :-) How can I search with some precision in a serialized string?
on 8/24/02 12:13 PM, DL Neil at PHPml
DandE.HomeChoice.co.uk wrote:
> Rodrigo, > > Then the question to be asked is: is serialize()ing this data good > design/technique, or is there a better way? > > Regards, > =dn > >
attached mail follows:
Rodrigo,
Inherited problems = ouch!
Sorry I don't keep old list msgs, perhaps you mentioned this before: does the language skills field contain: 1 both the language and the skill-level, eg English - Advanced 1b what separator is used between the two words? 2 more than one language/skill-level where applicable, eg English - Advanced, German - Intro. 2b what separator is used between language entries?
What is the database field description in the table schema?
Please advise, =dn
> well, I my opinion is not the way to work, but like I said the work was
done
> by other guy, and now I have the problem to solve. So i back to old
question
> :-)
> How can I search with some precision in a serialized string?
>
>
>
> on 8/24/02 12:13 PM, DL Neil at PHPml
DandE.HomeChoice.co.uk wrote:
>
> > Rodrigo,
> >
> > Then the question to be asked is: is serialize()ing this data good
> > design/technique, or is there a better way?
> >
> > Regards,
> > =dn
> >
> >
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
attached mail follows:
I have made a forum in PHP, and the users are logged in using cookies. I want all new threads (and if there are new replies in an old thread) to be highlight or something like that.
How do I check if a user has read a message or not?
/Charlotte
attached mail follows:
> From: Charlotte [mailto:evelone
worldonline.se]
> Sent: Monday, August 26, 2002 8:04 AM
> To: php-general
lists.php.net
> Subject: [PHP] check unread messages in a forum
>
>
> I have made a forum in PHP, and the users are logged in using
> cookies. I
> want all new threads (and if there are new replies in an old
> thread) to be
> highlight or something like that.
>
> How do I check if a user has read a message or not?
I'd say you'd need to keep a list of messages read by users somewhere.
attached mail follows:
Hi,
Just store the user's last log-in date/time either in the database or in cookie. On the next log-in "select * messages where creationDate > $userLastLoginDate" and highlight those selected. It won't work for every particular unread message, but I doubt if one needs to be that much specific.
HTH, Stas
----- Original Message -----
From: "Charlotte" <evelone
worldonline.se>
To: <php-general
lists.php.net>
Sent: Monday, August 26, 2002 1:04 PM
Subject: [PHP] check unread messages in a forum
> I have made a forum in PHP, and the users are logged in using cookies. I > want all new threads (and if there are new replies in an old thread) to be > highlight or something like that. > > How do I check if a user has read a message or not? > > > > /Charlotte > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
attached mail follows:
the method explained by Stas is the most common method used on all boards. But if you need a more precise method, that will also require more ressources from you server, what you can do is have a specific DB table called "msg_read" taking 2 parameters : msg_id, user_id. - Each time a user reads a message, you insert the pair "msg_id"/"user_id". - Each time the user reloads a page,you do something like this : $sql = "select msg_id from msg_read where user_id = ".addslashes($user_id); // process $sql query $msg_list = array(); while ( $row = getNextRow($mysqlResult)){ array_push($msg_list, $row[0]); } - when displaying the list of all message you just check if the message is in the array $msg_list if ( in_array($currentMsg, $msg_list)){ echo "READ"; }else{ echo "UNREAD"; }
regards
Eric
> Just store the user's last log-in date/time either in the database or in
> cookie. On the next log-in "select * messages where creationDate >
> $userLastLoginDate" and highlight those selected. It won't work for every
> particular unread message, but I doubt if one needs to be that much
> specific.
>
> HTH, Stas
>
> ----- Original Message -----
> From: "Charlotte" <evelone
worldonline.se>
> To: <php-general
lists.php.net>
> Sent: Monday, August 26, 2002 1:04 PM
> Subject: [PHP] check unread messages in a forum
>
>
> > I have made a forum in PHP, and the users are logged in using cookies. I
> > want all new threads (and if there are new replies in an old thread) to
be
> > highlight or something like that.
> >
> > How do I check if a user has read a message or not?
> >
> >
> >
> > /Charlotte
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
attached mail follows:
the method explained by Stas is the most common method used on all boards. But if you need a more precise method, that will also require more ressources from you server, what you can do is have a specific DB table called "msg_read" taking 2 parameters : msg_id, user_id. - Each time a user reads a message, you insert the pair "msg_id"/"user_id". - Each time the user reloads a page,you do something like this : $sql = "select msg_id from msg_read where user_id = ".addslashes($user_id); // process $sql query $msg_list = array(); while ( $row = getNextRow($mysqlResult)){ array_push($msg_list, $row[0]); } - when displaying the list of all message you just check if the message is in the array $msg_list if ( in_array($currentMsg, $msg_list)){ echo "READ"; }else{ echo "UNREAD"; }
regards
Eric
> Just store the user's last log-in date/time either in the database or in
> cookie. On the next log-in "select * messages where creationDate >
> $userLastLoginDate" and highlight those selected. It won't work for every
> particular unread message, but I doubt if one needs to be that much
> specific.
>
> HTH, Stas
>
> ----- Original Message -----
> From: "Charlotte" <evelone
worldonline.se>
> To: <php-general
lists.php.net>
> Sent: Monday, August 26, 2002 1:04 PM
> Subject: [PHP] check unread messages in a forum
>
>
> > I have made a forum in PHP, and the users are logged in using cookies. I
> > want all new threads (and if there are new replies in an old thread) to
be
> > highlight or something like that.
> >
> > How do I check if a user has read a message or not?
> >
> >
> >
> > /Charlotte
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
attached mail follows:
Hello List,
I have a problem with the php CURL module and UTF-8 data. My php script uses curl to do a post to a perl/cgi script. This perl script returns UTF-8 encoded XML. The perl script returns utf-8, i have verified that using the webserver logfiles, but the data that i receive in $result (see below) is decoded to ISO-8859-1.
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $post_url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_VERBOSE, 0); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); $result = curl_exec ($ch);// #### UTF compatible? curl_close ($ch);
Anyone an idea how i can get curl to return me UTF-8 data?
Thank you,
Merijn van den Kroonenberg
attached mail follows:
Hello all, I'm trying to install php 4.2.2 as a DSO with Apache-2.0.40 on a Mandrake Linux machine, and have come come upon a problem. It's having problems with sapi(?). I'm just wondering if anyone might know what is causing this problem, and if you could possibly point me towards a solution. Here's the error message:
sapi_apache2.c: In function `php_register_hook': sapi_apache2.c:534: warning: passing arg 3 of `ap_register_output_filter' makes pointer from integer without a cast sapi_apache2.c:534: too few arguments to function `ap_register_output_filter' sapi_apache2.c:535: warning: passing arg 3 of `ap_register_input_filter' makes pointer from integer without a cast sapi_apache2.c:535: too few arguments to function `ap_register_input_filter' make[3]: *** [sapi_apache2.lo] Error 1 make[3]: Leaving directory `/home/jalaw/downloads/php-4.2.2/sapi/apachefilter' make[2]: *** [all-recursive] Error 1 make[2]: Leaving directory `/home/jalaw/downloads/php-4.2.2/sapi/apachefilter' make[1]: *** [all-recursive] Error 1 make[3]: Leaving directory `/home/jalaw/downloads/php-4.2.2/sapi/' make: *** [all-recursive] Error 1 Thanks very much, Jesse Lawrence
______________________________________________________________________ Post your ad for free now! http://personals.yahoo.ca
attached mail follows:
Hi,
I've got a little problem with variable naming of object members. Here is my situation: I've got a website form, whoms contents will be saved in a MySQL table with two fields: name and value. The name could be anything like "bla->test", "array[3]->test[4]->name"...
Now I have a php script reading out the MySQL table, and I want to assign the variables like this: $object->$name, i.e. $object->bla->test = "some value"; $object->array[3]->tes[4]->name = "some other value"; etc.
Using $object->$name doesn't work, as this seems to ignore submembers and arrays. Any ideas how to solve my problem?
Regards,
Karl
-- GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net
attached mail follows:
Hello again, so earlier I was trying to install PHP-4.2.2 with Apache-2.0.40 and was having some sapi problems. I then read that I might be better off going with Apache-1.3.26. Well, I installed 1.3.26, and then configured and installed php into apache as a DSO. Everything appeared to go smoothly, except when I try to start up Apache, I get the following error message:
Syntax error on line 205 of /usr/local/apache/conf/httpd.conf: API module structure `php4_module' in file /usr/local/apache/libexec/libphp4.so is garbled -perhaps this is not an Apache module DSO? /usr/local/apache/bin/apachectl start: httpd could not be started
Can anyone lend me a hand with this?
Thanks very much, Jesse Lawrence
______________________________________________________________________ Post your ad for free now! http://personals.yahoo.ca
attached mail follows:
I am getting a failed query error message. Could someone take a look and let me know.
//F U N C T I O N S //================= function AddSignupRequest($Signup_FName, $Signup_LName, $Signup_Address1, $Signup_Address2, $Signup_City, $Signup_State, $Signup_Zip, $Signup_Email, $Signup_Phone, $Signup_ContactMethod, $Signup_Date, $Signup_IP, $Signup_Status, $Signup_Comments) { /* Connecting, selecting database */ $dbh=mysql_connect ($MySQL_Host, $MySQL_User, $MySQL_Password) or die ('I cannot connect to the database.'); mysql_select_db ("havasuin_Signups");
/* Performing SQL query */
$query = "INSERT INTO SignupRequests ('FirstName', 'LastName',
'Address1', 'Address2',
'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
'IP', 'Status', 'Comments')
VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
'Vernon', 'CT', '06066', 'ccrane
inxdesign.com',
'860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
Requested', 'Testing')";
$result = mysql_query($query) or die("Query failed");
/* Free resultset */ mysql_free_result($result);
/* Closing connection */ mysql_close($link); print "<br>$Signup_LName, $Signup_FName<br>\n";
}
attached mail follows:
I did some more testing and I found that I forgot the first field in the columns section of the Statement. So now it looks like this: I also copy and pasted the statement into PHPMYADMIN and it worked fine. It just doesn't work here????
function AddSignupRequest($Signup_FName, $Signup_LName, $Signup_Address1, $Signup_Address2, $Signup_City, $Signup_State, $Signup_Zip, $Signup_Email, $Signup_Phone, $Signup_ContactMethod, $Signup_Date, $Signup_IP, $Signup_Status, $Signup_Comments) { /* Connecting, selecting database */ $dbh=mysql_connect ($MySQL_Host, $MySQL_User, $MySQL_Password) or die ('I cannot connect to the database.'); mysql_select_db ("havasuin_Signups");
/* Performing SQL query */
$query = "INSERT INTO SignupRequests ('SignupID', 'FirstName',
'LastName', 'Address1', 'Address2',
'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
'IP', 'Status', 'Comments')
VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
'Vernon', 'CT', '06066', 'ccrane
inxdesign.com',
'860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
Requested', 'Testing')";
$result = mysql_query($query) or die("Query failed");
/* Free resultset */ mysql_free_result($result);
/* Closing connection */ mysql_close($link); print "<br>$Signup_LName, $Signup_FName<br>\n";
}
"Chris Crane" <ccrane
inxdesign.com> wrote in message
news:20020826134136.77666.qmail
pb1.pair.com...
> I am getting a failed query error message. Could someone take a look and
let
> me know.
>
> //F U N C T I O N S
> //=================
> function AddSignupRequest($Signup_FName, $Signup_LName, $Signup_Address1,
> $Signup_Address2, $Signup_City,
> $Signup_State, $Signup_Zip, $Signup_Email, $Signup_Phone,
> $Signup_ContactMethod,
> $Signup_Date, $Signup_IP, $Signup_Status, $Signup_Comments) {
> /* Connecting, selecting database */
> $dbh=mysql_connect ($MySQL_Host, $MySQL_User, $MySQL_Password) or die
> ('I cannot connect to the database.');
> mysql_select_db ("havasuin_Signups");
>
> /* Performing SQL query */
> $query = "INSERT INTO SignupRequests ('FirstName', 'LastName',
> 'Address1', 'Address2',
> 'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
> 'IP', 'Status', 'Comments')
> VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
> 'Vernon', 'CT', '06066', 'ccrane
inxdesign.com',
> '860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
> Requested', 'Testing')";
> $result = mysql_query($query) or die("Query failed");
>
> /* Free resultset */
> mysql_free_result($result);
>
> /* Closing connection */
> mysql_close($link);
> print "<br>$Signup_LName, $Signup_FName<br>\n";
>
> }
>
>
attached mail follows:
[snip]
/* Performing SQL query */
$query = "INSERT INTO SignupRequests ('FirstName', 'LastName',
'Address1', 'Address2',
'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
'IP', 'Status', 'Comments')
VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
'Vernon', 'CT', '06066', 'ccrane
inxdesign.com',
'860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
Requested', 'Testing')";
$result = mysql_query($query) or die("Query failed");
[/snip]
Have you printed the query to make sure that the syntax is right? The first thing that I see is that there are 13 items in your INSERT statement and 15 items in your VALUES statement ... these must match in order for the query to work.
HTH!
Jay
Ask smart questions: http://www.tuxedo.org/~esr/faqs/smart-questions.html Top Questions on php-general; (Answers can be found by RTFM, STFW, or STFA, save for #3 and #6 which can probably be found the same way, since they are usually one of the other questions on this list.) 1. How can I make file uploads work? 2. How come my form will not pass variables? 3. HELP! HELP! Please HELP! 4. Register_Globals ?!? 5. Is there a function to ... [insert thought here]? 6. Anyone see the error in this code?
attached mail follows:
Initially there was an error with too many values verses columns. But I think it was fixed. I am double checking now.
"Jay Blanchard" <jay.blanchard
niicommunications.com> wrote in message
news:003201c24d07$b8560470$8102a8c0
000347D72515...
> [snip]
> /* Performing SQL query */
> $query = "INSERT INTO SignupRequests ('FirstName', 'LastName',
> 'Address1', 'Address2',
> 'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
> 'IP', 'Status', 'Comments')
> VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
> 'Vernon', 'CT', '06066', 'ccrane
inxdesign.com',
> '860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
> Requested', 'Testing')";
> $result = mysql_query($query) or die("Query failed");
> [/snip]
>
> Have you printed the query to make sure that the syntax is right? The
first
> thing that I see is that there are 13 items in your INSERT statement and
15
> items in your VALUES statement ... these must match in order for the query
> to work.
>
>
> HTH!
>
> Jay
>
> Ask smart questions:
> http://www.tuxedo.org/~esr/faqs/smart-questions.html
> Top Questions on php-general;
> (Answers can be found by RTFM, STFW, or STFA,
> save for #3 and #6 which can probably be found
> the same way, since they are usually one of the
> other questions on this list.)
> 1. How can I make file uploads work?
> 2. How come my form will not pass variables?
> 3. HELP! HELP! Please HELP!
> 4. Register_Globals ?!?
> 5. Is there a function to ... [insert thought here]?
> 6. Anyone see the error in this code?
>
>
attached mail follows:
There are 15 columns and 15 pieces of data. In my second post I fixed this error and pasted it into PHPMYADMIN and it worked fine, but not here...
"Chris Crane" <ccrane
inxdesign.com> wrote in message
news:20020826135509.94145.qmail
pb1.pair.com...
> Initially there was an error with too many values verses columns. But I
> think it was fixed. I am double checking now.
>
>
> "Jay Blanchard" <jay.blanchard
niicommunications.com> wrote in message
> news:003201c24d07$b8560470$8102a8c0
000347D72515...
> > [snip]
> > /* Performing SQL query */
> > $query = "INSERT INTO SignupRequests ('FirstName', 'LastName',
> > 'Address1', 'Address2',
> > 'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
> > 'IP', 'Status', 'Comments')
> > VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
> > 'Vernon', 'CT', '06066', 'ccrane
inxdesign.com',
> > '860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
> > Requested', 'Testing')";
> > $result = mysql_query($query) or die("Query failed");
> > [/snip]
> >
> > Have you printed the query to make sure that the syntax is right? The
> first
> > thing that I see is that there are 13 items in your INSERT statement and
> 15
> > items in your VALUES statement ... these must match in order for the
query
> > to work.
> >
> >
> > HTH!
> >
> > Jay
> >
> > Ask smart questions:
> > http://www.tuxedo.org/~esr/faqs/smart-questions.html
> > Top Questions on php-general;
> > (Answers can be found by RTFM, STFW, or STFA,
> > save for #3 and #6 which can probably be found
> > the same way, since they are usually one of the
> > other questions on this list.)
> > 1. How can I make file uploads work?
> > 2. How come my form will not pass variables?
> > 3. HELP! HELP! Please HELP!
> > 4. Register_Globals ?!?
> > 5. Is there a function to ... [insert thought here]?
> > 6. Anyone see the error in this code?
> >
> >
>
>
attached mail follows:
Why don't you do
$result = mysql_query($query) or die(mysql_error());
or
$result = mysql_query($query); echo mysql_error();
That way, instead of "Query Failed" you'll get something meaningful... probably something that will solve the problem.
Justin French
on 26/08/02 11:55 PM, Chris Crane (ccrane
inxdesign.com) wrote:
> Initially there was an error with too many values verses columns. But I
> think it was fixed. I am double checking now.
>
>
> "Jay Blanchard" <jay.blanchard
niicommunications.com> wrote in message
> news:003201c24d07$b8560470$8102a8c0
000347D72515...
>> [snip]
>> /* Performing SQL query */
>> $query = "INSERT INTO SignupRequests ('FirstName', 'LastName',
>> 'Address1', 'Address2',
>> 'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
>> 'IP', 'Status', 'Comments')
>> VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
>> 'Vernon', 'CT', '06066', 'ccrane
inxdesign.com',
>> '860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
>> Requested', 'Testing')";
>> $result = mysql_query($query) or die("Query failed");
>> [/snip]
>>
>> Have you printed the query to make sure that the syntax is right? The
> first
>> thing that I see is that there are 13 items in your INSERT statement and
> 15
>> items in your VALUES statement ... these must match in order for the query
>> to work.
>>
>>
>> HTH!
>>
>> Jay
>>
>> Ask smart questions:
>> http://www.tuxedo.org/~esr/faqs/smart-questions.html
>> Top Questions on php-general;
>> (Answers can be found by RTFM, STFW, or STFA,
>> save for #3 and #6 which can probably be found
>> the same way, since they are usually one of the
>> other questions on this list.)
>> 1. How can I make file uploads work?
>> 2. How come my form will not pass variables?
>> 3. HELP! HELP! Please HELP!
>> 4. Register_Globals ?!?
>> 5. Is there a function to ... [insert thought here]?
>> 6. Anyone see the error in this code?
>>
>>
>
>
attached mail follows:
Thank you. I will try that.
"Justin French" <justin
indent.com.au> wrote in message
news:B99071C8.EADA%justin
indent.com.au...
> Why don't you do
>
> $result = mysql_query($query) or die(mysql_error());
>
> or
>
> $result = mysql_query($query);
> echo mysql_error();
>
> That way, instead of "Query Failed" you'll get something meaningful...
> probably something that will solve the problem.
>
>
> Justin French
>
>
> on 26/08/02 11:55 PM, Chris Crane (ccrane
inxdesign.com) wrote:
>
> > Initially there was an error with too many values verses columns. But I
> > think it was fixed. I am double checking now.
> >
> >
> > "Jay Blanchard" <jay.blanchard
niicommunications.com> wrote in message
> > news:003201c24d07$b8560470$8102a8c0
000347D72515...
> >> [snip]
> >> /* Performing SQL query */
> >> $query = "INSERT INTO SignupRequests ('FirstName', 'LastName',
> >> 'Address1', 'Address2',
> >> 'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
> >> 'IP', 'Status', 'Comments')
> >> VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
> >> 'Vernon', 'CT', '06066', 'ccrane
inxdesign.com',
> >> '860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
> >> Requested', 'Testing')";
> >> $result = mysql_query($query) or die("Query failed");
> >> [/snip]
> >>
> >> Have you printed the query to make sure that the syntax is right? The
> > first
> >> thing that I see is that there are 13 items in your INSERT statement
and
> > 15
> >> items in your VALUES statement ... these must match in order for the
query
> >> to work.
> >>
> >>
> >> HTH!
> >>
> >> Jay
> >>
> >> Ask smart questions:
> >> http://www.tuxedo.org/~esr/faqs/smart-questions.html
> >> Top Questions on php-general;
> >> (Answers can be found by RTFM, STFW, or STFA,
> >> save for #3 and #6 which can probably be found
> >> the same way, since they are usually one of the
> >> other questions on this list.)
> >> 1. How can I make file uploads work?
> >> 2. How come my form will not pass variables?
> >> 3. HELP! HELP! Please HELP!
> >> 4. Register_Globals ?!?
> >> 5. Is there a function to ... [insert thought here]?
> >> 6. Anyone see the error in this code?
> >>
> >>
> >
> >
>
attached mail follows:
I got it working. It did not like the single quotes around the column names.
"Chris Crane" <ccrane
inxdesign.com> wrote in message
news:20020826140920.9594.qmail
pb1.pair.com...
> Thank you. I will try that.
> "Justin French" <justin
indent.com.au> wrote in message
> news:B99071C8.EADA%justin
indent.com.au...
> > Why don't you do
> >
> > $result = mysql_query($query) or die(mysql_error());
> >
> > or
> >
> > $result = mysql_query($query);
> > echo mysql_error();
> >
> > That way, instead of "Query Failed" you'll get something meaningful...
> > probably something that will solve the problem.
> >
> >
> > Justin French
> >
> >
> > on 26/08/02 11:55 PM, Chris Crane (ccrane
inxdesign.com) wrote:
> >
> > > Initially there was an error with too many values verses columns. But
I
> > > think it was fixed. I am double checking now.
> > >
> > >
> > > "Jay Blanchard" <jay.blanchard
niicommunications.com> wrote in message
> > > news:003201c24d07$b8560470$8102a8c0
000347D72515...
> > >> [snip]
> > >> /* Performing SQL query */
> > >> $query = "INSERT INTO SignupRequests ('FirstName', 'LastName',
> > >> 'Address1', 'Address2',
> > >> 'City', 'State', 'Zip', 'Email', 'Phone', 'ContactMethod', 'Date',
> > >> 'IP', 'Status', 'Comments')
> > >> VALUES ('', 'Chris', 'Crane', '655 Talcottville Road', 'Apt. 185',
> > >> 'Vernon', 'CT', '06066', 'ccrane
inxdesign.com',
> > >> '860-659-6464', 'Email', 'August 25, 2002', '64.252.232.82', 'Newly
> > >> Requested', 'Testing')";
> > >> $result = mysql_query($query) or die("Query failed");
> > >> [/snip]
> > >>
> > >> Have you printed the query to make sure that the syntax is right? The
> > > first
> > >> thing that I see is that there are 13 items in your INSERT statement
> and
> > > 15
> > >> items in your VALUES statement ... these must match in order for the
> query
> > >> to work.
> > >>
> > >>
> > >> HTH!
> > >>
> > >> Jay
> > >>
> > >> Ask smart questions:
> > >> http://www.tuxedo.org/~esr/faqs/smart-questions.html
> > >> Top Questions on php-general;
> > >> (Answers can be found by RTFM, STFW, or STFA,
> > >> save for #3 and #6 which can probably be found
> > >> the same way, since they are usually one of the
> > >> other questions on this list.)
> > >> 1. How can I make file uploads work?
> > >> 2. How come my form will not pass variables?
> > >> 3. HELP! HELP! Please HELP!
> > >> 4. Register_Globals ?!?
> > >> 5. Is there a function to ... [insert thought here]?
> > >> 6. Anyone see the error in this code?
> > >>
> > >>
> > >
> > >
> >
>
>
attached mail follows:
Please see below. I have posted the entire script.
"Bogdan Stancescu" <mgv
canad.ro> wrote in message
news:3D66DABE.6030304
canad.ro...
> Then you're doing something wrong. Can you post a piece of code?
>
> Bogdan
>
> Erich Kolb wrote:
> > I have already downloaded the entire file so that Im not constantly
> > accessing FreshMeat.net's servers. I will be processing the update
files as
> > soon as I can get the big one done.
> > I have also tried to use htmlspecialchars, and nl2br, but it doesnt look
> > like there is any output to process.
> >
> > "Bogdan Stancescu" <mgv
canad.ro> wrote in message
> > news:20020823230239.8210.qmail
pb1.pair.com...
> >
> >>Hi!
> >>
> >>You can get the content of that file with php, using <?
> >>$projects_rdf=file("http://www.freshmeat.net/backend/fm-projects.rdf");
> >>?> - then you can do whatever you please with it. Make sure to
> >>htmlspecialchars() it before outputting to a browser - and consider a
> >>nl2br() while you're at it as well.
> >>
> >>Please be warned that it's a huge download though - you may consider
> >>only downloading the updates, available from freshmeat from another
> >>location (I'm sure you can find it easily, I don't have the link at
hand).
> >>
> >>HTH
> >>
> >>Bogdan
> >>
> >>Erich Kolb wrote:
> >>
> >>>I am trying to write a script that will take a look at the
freshmeat.net
> >>>database (http://www.freshmeat.net/backend/fm-projects.rdf), parse the
> >>
> > file,
> >
> >>>and insert it into a MySQL DB. I have already wrote one for
> >>
> > slashdot.org
> >
> >>>that puts the output into html and displays it in a web browser and it
> >>
> > works
> >
> >>>fine. I am trying to do the same to start with for freshmeat (I am
> >>
> > learning
> >
> >>>as I go) but there is nothing displayed on the browser. Can someone
> >>
> > help me
> >
> >>>out with this?
> >>>
> >>>Here is the code I have written for slashdot:
> >>><?php
> >>>
> >>>$insideitem = false;
> >>>$tag = "";
> >>>$title = "";
> >>>$description = "";
> >>>$link = "";
> >>>
> >>>function startElement($parser, $name, $attrs) {
> >>> global $insideitem, $tag, $title, $description, $link;
> >>> if ($insideitem) {
> >>> $tag = $name;
> >>> } elseif ($name == "STORY") {
> >>> $insideitem = true;
> >>> }
> >>>}
> >>>
> >>>function endElement($parser, $name) {
> >>> global $insideitem, $tag, $title, $description, $link;
> >>> if ($name == "STORY") {
> >>> printf("<dt><b><a href='%s'>%s</a></b></dt>",
> >>> trim($description),htmlspecialchars(trim($title)));
> >>> #printf("<dd>%s</dd>",htmlspecialchars(trim($description)));
> >>> $title = "";
> >>> $description = "";
> >>> $link = "";
> >>> $insideitem = false;
> >>> }
> >>>}
> >>>
> >>>function characterData($parser, $data) {
> >>> global $insideitem, $tag, $title, $description, $link;
> >>> if ($insideitem) {
> >>> switch ($tag) {
> >>> case "TITLE":
> >>> $title .= $data;
> >>> break;
> >>> case "URL":
> >>> $description .= $data;
> >>> break;
> >>> }
> >>> }
> >>>}
> >>>
> >>>$xml_parser = xml_parser_create();
> >>>xml_set_element_handler($xml_parser, "startElement", "endElement");
> >>>xml_set_character_data_handler($xml_parser, "characterData");
> >>>$fp = fopen("http://www.slashdot.org/slashdot.xml","r")
> >>> or die("Error reading RSS data.");
> >>>while ($data = fread($fp, 4096))
> >>> xml_parse($xml_parser, $data, feof($fp))
> >>> or die(sprintf("XML error: %s at line %d",
> >>> xml_error_string(xml_get_error_code($xml_parser)),
> >>> xml_get_current_line_number($xml_parser)));
> >>>fclose($fp);
> >>>xml_parser_free($xml_parser);
> >>>
> >>>?>
> >>>
> >>>And here is what I have so far for FreshMeat.net. Its pretty much the
> >>
> > same,
> >
> >>>but the elements are a little different:
> >>><?php
> >>>
> >>>$insideitem = false;
> >>>$tag = "";
> >>>$project_id = "";
> >>>$date_added = "";
> >>>$date_updated = "";
> >>>$projectname_short = "";
> >>>$projectname_full = "";
> >>>$desc_short = "";
> >>>$desc_full = "";
> >>>$url_homepage = "";
> >>>
> >>>function startElement($parser, $name, $attrs){
> >>>global $insideitem, $tag, $project_id, $date_added, $date_updated,
> >>>$projectname_short, $projectname_full, $desc_short, $desc_full,
> >>>$url_homepage;
> >>> if($insideitem){
> >>> $tag = $name;
> >>> }
> >>> elseif ($name == "project"){
> >>> $insideitem = true;
> >>> }
> >>>}
> >>>
> >>>function characterData($parser, $data){
> >>>global $insideitem, $tag, $project_id, $date_added, $date_updated,
> >>>$projectname_short, $projectname_full, $desc_short, $desc_full,
> >>>$url_homepage;
> >>> if($insideitem){
> >>> switch ($tag){
> >>> case "project_id":
> >>> $project_id .=$data;
> >>> break;
> >>>
> >>> case "date_added":
> >>> $date_added .=$data;
> >>> break;
> >>>
> >>> case "date_updated":
> >>> $date_updated .=$data;
> >>> break;
> >>>
> >>> case "projectname_short":
> >>> $projectname_short .=$data;
> >>> break;
> >>>
> >>> case "projectname_full":
> >>> $projectname_full .=$data;
> >>> break;
> >>>
> >>> case "desc_short":
> >>> $desc_short .=$data;
> >>> break;
> >>>
> >>> case "desc_full":
> >>> $desc_full .=$data;
> >>> break;
> >>>
> >>> case "url_homepage":
> >>> $url_homepage .=$data;
> >>> break;
> >>> }
> >>> }
> >>> }
> >>>
> >>>function endElement($parser, $name){
> >>>global $insideitem, $tag, $project_id, $date_added, $date_updated,
> >>>$projectname_short, $projectname_full, $desc_short, $desc_full,
> >>>$url_homepage;
> >>>if ($name =="project"){
> >>> echo trim($projectname_full)."\n";
> >>> echo trim($url_homepage)."\n";
> >>> $projectname_full ="";
> >>> $url_homepage ="";
> >>> }
> >>>}
> >>>
> >>>
> >>>$xml_parser = xml_parser_create();
> >>>xml_set_element_handler($xml_parser, "startElement", "endElement");
> >>>xml_set_character_data_handler($xml_parser, "characterData");
> >>>$fp = fopen("fm-projects.rdf","r")
> >>> or die("Error reading RSS data.");
> >>>while ($data = fread($fp, 4096))
> >>> xml_parse($xml_parser, $data, feof($fp))
> >>> or die(sprintf("XML error: %s at line %d",
> >>> xml_error_string(xml_get_error_code($xml_parser)),
> >>> xml_get_current_line_number($xml_parser)));
> >>>
> >>>
> >>>fclose($fp);
> >>>xml_parser_free($xml_parser);
> >>>
> >>>
> >>>?>
> >>>
> >>>
> >>>
> >
> >
>
>
attached mail follows:
I did some further testing, and i found that this behaviour is not consistent. Actually i am pretty puzzled about this.
When i wrote the message below is was testing with a xml document that contained only the following multi byte utf chacracter: \303\253 (octal utf8) (LATIN SMALL LETTER E WITH DIAERESIS) The output from CURL got automatically decoded to latin1.
Then after i wrote the message i tested with another xml document that contained the following multi byte utf character: \342\202\254 (octal utf8) (EURO SIGN) I was suprised to see that the output was now correct UTF-8.
Now i modified the first document and inserted the EURO SIGN in this document. When i process this document again, the CURL output is UTF-8. So it seems the output of CURL depends on what it detects on its imput, and it will try to convert the data to latin1 if possible??
Does anyone know how i can disable this behaviour? For me, CURL should not do any encoding of my data.
Greetings, Merijn van den Kroonenberg
----- Original Message -----
From: "Merijn van den Kroonenberg" <merijnspam
e-factory.nl>
To: <php-general
lists.php.net>
Sent: Monday, August 26, 2002 2:36 PM
Subject: [PHP] curl and UTF-8
> Hello List, > > I have a problem with the php CURL module and UTF-8 data. > My php script uses curl to do a post to a perl/cgi script. This perl script > returns UTF-8 encoded XML. The perl script returns utf-8, i have verified > that using the webserver logfiles, but the data that i receive in $result > (see below) is decoded to ISO-8859-1. > > $ch = curl_init(); > curl_setopt($ch, CURLOPT_URL, $post_url); > curl_setopt($ch, CURLOPT_HEADER, 0); > curl_setopt($ch, CURLOPT_VERBOSE, 0); > curl_setopt($ch, CURLOPT_POST, 1); > curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); > curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); > $result = curl_exec ($ch);// #### UTF compatible? > curl_close ($ch); > > Anyone an idea how i can get curl to return me UTF-8 data? > > Thank you, > > Merijn van den Kroonenberg > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >
attached mail follows:
Bogdan -
Sorry for the delay to your follow-up.
The total script is below... first let me explain a little more of what I'm doing for clarity's sake.
I'm downloading a lot of data files from a site. The way the site works, you supply some information in a form regarding the data set you want. This goes to a PERL script which creates a packaged (zipped) data set and puts it in an FTP directory.
What I wanted to do was write a script that would automatically do the form submission, retrieve the name and location of the zip file, and save it to my local hard disk. I happened to have a list of over 1000 data set names that I wanted to get... so I just needed to loop through them.
FWIW, the "faking a form post" part of this, which is really the core of what I'm doing, is based on the following in the pgp_general archives:
http://marc.theaimsgroup.com/?l=php-general&m=101899239727991&w=2
You can search for this by searching the archives for the term "asphttp". ASPHTTP is a tool for ASP that does the same thing... only it costs money, and this little function is free! How cool is that?
Here's the script (got it working, BTW).
Chip
<? /*--- PHP Script --------------*/ $data = array("dataset1", "dataset2", ... , "dataset1000");
//Loop through each value in the array, POSTING data, and downloading // the dataset to the hard drive. foreach($data as $a) { //Since this script is going to take a long time to execute // we need to set the max time limit to some really high // number so that it doesn't time out. This probably needs // to be done on the web_server as well (e.g. the def time-out // in IIS is 300 seconds). set_time_limit(120000);
//The next two variables make up the location of the resource // that you will be posting to. This is basically what would // appear in the ACTION section of a FORM element. In this case: // http://www.someserver.com/cgi-bin/some_script.pl $host="www.someserver.com; $path="/cgi-bin/some_script.pl";
//The next line makes up the 'data to send' in the form. Apparently // if you start the string with a "&", this will use the POST method, // while if you start with a "?" it will use the GET method (or at // least it's acting like it's doing one or the other). $data_to_send = "&myDataSetName=" . $a . "&FormVar1=Value1&FormVar2=Value2"; PostToHost($host, $path, $data_to_send); }
function PostToHost($host, $path, $data_to_send) { //This part of the function creates a file that essentially POSTs the // $data_to_send information to the $host . $path location, and retrieves // the information into a variable called $returnData $returnData=""; $fp = fsockopen($host,80); fputs($fp, "POST $path HTTP/1.1\n"); fputs($fp, "Host: $host\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\n"); fputs($fp, "Content-length: ".strlen($data_to_send)."\n"); fputs($fp, "Connection: close\n\n"); fputs($fp, $data_to_send);
//Loop through the variable $returnData line-by-line. In this case, // I'm searching for a keyword. The name of the resulting file is always // on a line like this: // YOURFTPFILENAME = some_file_name_xxxx.xxxx //Once I hit this line, I want to save the entire line into a variable // called $filename, and break out of the loop. while(!feof($fp)) { $returnData=fgets($fp, 128); $filename = strstr($returnData, 'YOURFTPFILENAME'); if ($filename) break; }
//Use some simple string parsing functions to strip out the "YOURFTPFILENAME = " // part of the filename. $filename = substr($filename, 18); $filename = trim($filename);
//Now, I'm going to connect to and read the file that was created. In this case // it is always saved to the same location, so all I need to do is specify the // file name. The file will be read into a variable called $contents. $host = "http://www.someserver.com/ftp_downloads/images/"; $fp2 = fopen($host . $filename, "rb+"); $contents = fread ($fp2, 25000000); //use some rediculously large number in fread // to ensure that you get the whole thing.
//make a file to write to on the local system, and dump $contents into the new // file. $fp3 = fopen("D:\\myFiles\\SomeDirectory\\" . $filename, "w"); fputs($fp3, $contents);
//close all of the documents fclose($fp); fclose($fp2); fclose($fp3); } /*---- End of Script ---------------*/ ?>
> -----Original Message-----
> From: Bogdan Stancescu [mailto:mgv
canad.ro]
> Sent: Thursday, August 22, 2002 10:29 PM
> To: php-general
lists.php.net
> Subject: [PHP] Re: Automatic Download using URL, HELP!
>
>
> Just out of curiousity, how did you ever get PHP to prompt you where to
> save a file? Could you post a more complete code sample?
>
> Bogdan
attached mail follows:
Thanks for everyones help yesterday but nI have come up against a problem (as I am new). I have created my document as detailed below with notes. I can see from the form that I have connected to the server, accessed the correct database, created the statment and executed it. The problem is how to display the information - as far as I can understand from yesterday if the result is 0 then the villa is available. So what I need to do is if the result = 0 display villa available and if the result is greater than 0 then display villa not available . I know that the variables are getting to the query as if I change the echo $result; to $sql; and key in 3 as the id and 2 dates in the form I get the following:
SELECT COUNT(*) FROM bookings WHERE ('2002-04-04') BETWEEN booking_start AND booking_end OR ('2002-04-10')BETWEEN booking_start AND booking_end AND villa_id = ('3')
So, corrcet me if I am wrong but the query is working its just i cannot see anything. I have spent hours on this today, reading books and looking at the list. I hope that once I have done one good script I can then start to understand it and create more :-)
Thanks for all your help
Ray
<html> <body> <?php
if ($submit) {
// open connection to database
$db = mysql_connect("localhost", "matrix", "matrix");
// pick database to use
mysql_select_db("matrix",$db);
// create the SQL statement
$sql = "SELECT COUNT(*) FROM bookings WHERE ('$book_start_date') BETWEEN booking_start AND booking_end OR ('$book_end_date')BETWEEN booking_start AND booking_end AND villa_id = ('$place')";
// execute the SQL statement
$result = mysql_query($sql);
// display the information
echo $result;
} else{
// display form
?> <form method="post" action="<?php echo $PHP_SELF?>"> Villa id number:<input type="Text" name="place"><br> Start date:<input type="Text" name="book_start_date"><br> End date:<input type="Text" name="book_end_date"><br> <input type="Submit" name="submit" value="Search information"> </form> <?php } // end if ?> </body> </html>
attached mail follows:
you need
$query = SELECT COUNT(*) as count FROM bookings WHERE ('2002-04-04') BETWEEN booking_start AND booking_end OR ('2002-04-10')BETWEEN booking_start AND booking_end AND villa_id = ('3')
$villa = mysql_query($query);
while ($result = mysqul_result($villa)) { echo "We have $result[count] villas booked"; }
and do the same again but change the statement to villa_id = 0
Adam
On Mon, 26 Aug 2002, Ray Healy (Data Net Services) wrote:
> Thanks for everyones help yesterday but nI have come up against a problem > (as I am new). I have created my document as detailed below with notes. I > can see from the form that I have connected to the server, accessed the > correct database, created the statment and executed it. The problem is how > to display the information - as far as I can understand from yesterday if > the result is 0 then the villa is available. So what I need to do is if the > result = 0 display villa available and if the result is greater than 0 then > display villa not available . I know that the variables are getting to the > query as if I change the echo $result; to $sql; and key in 3 as the id and > 2 dates in the form I get the following: > > SELECT COUNT(*) FROM bookings WHERE ('2002-04-04') BETWEEN booking_start AND > booking_end OR ('2002-04-10')BETWEEN booking_start AND booking_end AND > villa_id = ('3') > > So, corrcet me if I am wrong but the query is working its just i cannot see > anything. I have spent hours on this today, reading books and looking at the > list. I hope that once I have done one good script I can then start to > understand it and create more :-) > > Thanks for all your help > > > Ray > > > <html> > <body> > <?php > > if ($submit) { > > // open connection to database > > $db = mysql_connect("localhost", "matrix", "matrix"); > > // pick database to use > > mysql_select_db("matrix",$db); > > // create the SQL statement > > $sql = "SELECT COUNT(*) FROM bookings WHERE ('$book_start_date') BETWEEN > booking_start AND booking_end OR ('$book_end_date')BETWEEN booking_start AND > booking_end AND villa_id = ('$place')"; > > // execute the SQL statement > > $result = mysql_query($sql); > > // display the information > > echo $result; > > } else{ > > // display form > > ?> > <form method="post" action="<?php echo $PHP_SELF?>"> > Villa id number:<input type="Text" name="place"><br> > Start date:<input type="Text" name="book_start_date"><br> > End date:<input type="Text" name="book_end_date"><br> > <input type="Submit" name="submit" value="Search information"> > </form> > <?php > } > // end if > ?> > </body> > </html> > > > >
attached mail follows:
Richard Lynch wrote On Saturday, August 24, 2002 4:52 PM To: David Buerer
> >I'm using a php script to stream a microsoft word file to a browser. > > > >I'm sending header("Content-type: {$mimetype[DOC]} \n"); to set the mime > >type to application/msword so that the browser knows how to open the file. > > > > > >However, some users systems are configured to allow the choice of open or > >saveas. The problem is that when the user selects saveas the filename it > >uses is the name of the php script which streams the file, not the actual > >filename of the file. How do I set this filename?
> Alas, different browsers do this differently...
> The *BEST* way to do it is to make your link be named the filename you want > them to download:
> Example: > http://uncommonground.com/events.pdf
> This is *really* a PHP script that happens to have a filename of > 'events.pdf'
> I've put this into my .htaccess file to force Apache to parse events.pdf as > PHP:
> <Files events.pdf> > ForceType application/x-httpd-php > </Files>
> So Apache "knows" it's a PHP file and PHP spews out valid PDF content and > the browser never even "sees" .php anywhere, so the browser thinks it's just > getting a static PDF file.
> If you have a zillion files to link to, you might want to consider:
> Creating "broken" links to http://example.com/index/nonexistent.doc *BUT* > you have a file named 'index' and a ForceType like above to make Apache > parse it as PHP, and inside 'index' you do:
> <?php > # Use $path_info to determine what file they wish to download. > # NOTE: It's going to be $_ENV['path_info'] or $_SERVER['path_info'] or > something like that now... > # Use phpinfo() to figure out what it is... >?>
> Or, if that sounds too "tricky" just put the filename into the link, even > though it looks "bogus":
> http://example.com/download.php/whatever.doc?filename=whatever.doc
> Even though your PHP file is really 'download.php', Apache and PHP don't > care about that extra crap in there '/whatever.doc' and the browsers are so > stupid they think you've got an actual file with that name in it.
> You can also dink with headers involving Content-disposition and something > else I forgot, since IE and Netscape and different versions of each look at > different headers to "decide" what to use for "Save As..." *BUT* there will > always be some minor version of IE or Netscape that doesn't follow their own > rules, and the headers won't work for it. Thus I usually go with the first > option, and don't even give the browser any way to "know" that it's not a > plain old static URL.
I have been struggling with this problem for the last several days. (See my recent post, "Trouble Downloading Files, 8.24.02". The problem I had was mostly with IE. Here is how I solved it. I used the code from the following as the basis of my code: http://www.zend.com/zend/trick/tricks-august-2001.php To make it work in IE, I had to add two lines to the section on "send headers" (See commented lines below). //send headers if(($pc > 1) AND isset($mimetype[$p[$pc - 1]])) { //display file inside browser header("Content-type: " . $mimetype[$p[$pc - 1]] . "\n"); header("Content-disposition: attachment; filename=\"$file\"\n"); // THIS LINE IS ADDED TO GIVE A CHOICE TO OPEN, OR SAVE AS FILENAME. } else { //force download dialog header("Content-type: application/octet-stream\n"); header("Content-disposition: attachment; filename=\"$file\"\n"); } header('Cache-Control: public'); // THIS LINE IS ADDED TO MAKE MSIE WORK AT ALL header("Content-transfer-encoding: binary\n"); header("Content-length: " . filesize($path) . "\n"); //send file contents $fp=fopen($path, "r"); fpassthru($fp);
The Cache-Control header came from comments by php
brayra.com, 04-Apr-2002
12:25, in http://www.php.net/manual/en/function.fpassthru.php
I'm not sure why these additions fixed the problem, but they did. Maybe
someone out there with a better understanding than I can explain. Hope this
helps.
Roger
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]