php-general Digest 11 Oct 2004 06:03:41 -0000 Issue 3046
Topics (messages 199117 through 199148):
Re: http 411 error with cURL
199117 by: Nick Wilson
Re: no reload
199118 by: Ron
199119 by: Gal
199123 by: Ron
199131 by: M. Sokolewicz
php and print
199120 by: Bruno Santos
199126 by: Greg Donald
199127 by: Harlequin
textarea vs. type="text" data difference?
199121 by: Sam Smith
199124 by: Sam Smith
199125 by: Greg Donald
199130 by: Minuk Choi
199132 by: Sam Smith
Re: PHP (anti) crash policy?
199122 by: Jason Wong
Re: Help:Multi Page form using session variables
199128 by: Stuart Felenstein
Re: sending SMS messages to mobile phones from PHP
199129 by: SunTan.co.uk
199148 by: Sagar C Nannapaneni
PHP gurus...how are they doing this?
199133 by: Mag
199134 by: John Holmes
forms/variables/create database
199135 by: bigmark
199136 by: Minuk Choi
Re: forms
199137 by: bigmark
199139 by: Michal Migurski
(null)
199138 by: php-list.xenonsolutions.com
Decoding mail attachments
199140 by: Dave
install /setup script
199141 by: bigmark
I need help figuring out something
199142 by: Brent Clements
PEAR::Auth
199143 by: 22
If statement question...
199144 by: GH
199145 by: M. Sokolewicz
199146 by: M. Sokolewicz
Parse Error --- can not solve at this time... please assit
199147 by: GH
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 ---
* and then Manuel Lemos declared....
> >>http://www.phpclasses.org/httpclient
> >
> >
> >Would you mind giving a very brief example? - I have that class, but not
> >sure how to integrate it with my curl POST function? - much thx..
>
> Just take a look at the test_http_post.php example . It just passes some
> parameters to the class to make a POST request. The class only uses Curl
> if you want to make a SSL request and fsockopen with SSL support is not
> available.
Yeah, i did look at that, it's all mixed in with html, and quite frankly
it's not particularly readable (at least for me) I'll stick with curl
for now, but thanks for taking time to show me an alternative ;-)
--
Nick W
--- End Message ---
--- Begin Message ---
Thanx,
but... don't the headers control the browser's caching?
Gal wrote:
add the following headers.
Important: Make sure they are located in your script before you print to
the browser !!!
<?php
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
?>
Cheers,
Gal
Ron wrote:
Hi,
In working locally (Linux, Apache/2.0.49, PHP4.3.4) I can not reload
the scipt pages.
When I hit the reload button, the same page is displayed.
I tried to use another browser - and it seems the page is cached on
the server side.
Any clue how to disable that?
Cheers,
Ron
--- End Message ---
--- Begin Message ---
Yes, they do control the browsers cache.
You can use the Mozilla "Live HTTP Headers" extension to see what do you
send/recieve.
Check http://livehttpheaders.mozdev.org
Very good tool.
Cheers,
Gal
Ron wrote:
Thanx,
but... don't the headers control the browser's caching?
Gal wrote:
add the following headers.
Important: Make sure they are located in your script before you print
to the browser !!!
<?php
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
?>
Cheers,
Gal
Ron wrote:
Hi,
In working locally (Linux, Apache/2.0.49, PHP4.3.4) I can not reload
the scipt pages.
When I hit the reload button, the same page is displayed.
I tried to use another browser - and it seems the page is cached on
the server side.
Any clue how to disable that?
Cheers,
Ron
--- End Message ---
--- Begin Message ---
Yes - my problem *was* on the server side, and not on the client.
I don't know what the problem was, but the files were in a soft linked
folder. I moved them to my apache docroot and it solved the problem.
Thanx,
Ron
Gal wrote:
Yes, they do control the browsers cache.
You can use the Mozilla "Live HTTP Headers" extension to see what do you
send/recieve.
Check http://livehttpheaders.mozdev.org
Very good tool.
Cheers,
Gal
Ron wrote:
Thanx,
but... don't the headers control the browser's caching?
Gal wrote:
add the following headers.
Important: Make sure they are located in your script before you print
to the browser !!!
<?php
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
?>
Cheers,
Gal
Ron wrote:
Hi,
In working locally (Linux, Apache/2.0.49, PHP4.3.4) I can not reload
the scipt pages.
When I hit the reload button, the same page is displayed.
I tried to use another browser - and it seems the page is cached on
the server side.
Any clue how to disable that?
Cheers,
Ron
--- End Message ---
--- Begin Message ---
Usually such things aren't cached implicitly on the server side.
However, they are very often cached by your ISP! That cache is hard to
circumvent, and the difference between the two is unnoticable for a
normal user.
When you change the path, then, of course, they are treated as new
files, and your ISP will, again, re-cache them, unless specific headers
(pragma or cache-control) are set.
Ron wrote:
Yes - my problem *was* on the server side, and not on the client.
I don't know what the problem was, but the files were in a soft linked
folder. I moved them to my apache docroot and it solved the problem.
Thanx,
Ron
Gal wrote:
Yes, they do control the browsers cache.
You can use the Mozilla "Live HTTP Headers" extension to see what do
you send/recieve.
Check http://livehttpheaders.mozdev.org
Very good tool.
Cheers,
Gal
Ron wrote:
Thanx,
but... don't the headers control the browser's caching?
Gal wrote:
add the following headers.
Important: Make sure they are located in your script before you
print to the browser !!!
<?php
// Date in the past
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
// HTTP/1.0
header("Pragma: no-cache");
?>
Cheers,
Gal
Ron wrote:
Hi,
In working locally (Linux, Apache/2.0.49, PHP4.3.4) I can not
reload the scipt pages.
When I hit the reload button, the same page is displayed.
I tried to use another browser - and it seems the page is cached on
the server side.
Any clue how to disable that?
Cheers,
Ron
--- End Message ---
--- Begin Message ---
Hello.
Is possible to php to send information to the printer, or just print the
page i want in the browser
and is the user who press the print button ??
does php have any printing functions ??
cheers
Bruno Santos
--- End Message ---
--- Begin Message ---
On Sun, 10 Oct 2004 20:17:43 +0100, Bruno Santos <[EMAIL PROTECTED]> wrote:
> Is possible to php to send information to the printer, or just print the
> page i want in the browser
> and is the user who press the print button ??
> does php have any printing functions ??
Sure, echo(), print(), sprintf().. just to name a few.
But what you want is javascript. Try google.
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
--- End Message ---
--- Begin Message ---
Bruno
I'm still rather new to PHP so I use client side Java:
[CODE]
<!-- Print Page -->
<p>Click Here To Print This Page: <a href="javascript:window.print()"><img
src="../images/Icon_Printer.gif" border="0" alt="Print This Page"></a></p>
[/CODE]
That may be os use to you...
--
-----------------------------
Michael Mason
Arras People
www.arraspeople.co.uk
-----------------------------
"Bruno Santos" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello.
>
> Is possible to php to send information to the printer, or just print the
> page i want in the browser
> and is the user who press the print button ??
> does php have any printing functions ??
>
> cheers
>
> Bruno Santos
--- End Message ---
--- Begin Message ---
I have a form with both textarea and text type fields.
I submit it and do some processing on identical data and get different
results.
What's up with that.
Thank you.
--- End Message ---
--- Begin Message ---
##The data is the same. I've been up a long time.
BUT something is still very weird.
Doc1.php (loaded in web browser)
//contents of Doc1.php
include functions.php
include formProcessor.php
include form.php
Calling the "protectText()" function in "functions.php" from
"formProcessor.php" with data posted from "form.php" works on data posted
from textarea fields but does NOT on data posted from type="text".
//contents of functions.php ONLY works on textarea fields
The fundtion in function.php is:
function protectText($tv) {
$tv = stripslashes($tv);
$tv = str_replace("\"","[QT]",$tv);
$tv = str_replace("\r","<br>",$tv);
return $tv;
}
BUT if I put the same function in "formprocessor.php" it works!??
//contents of formprocessor.php THIS works on both
function TSTprotectText($tv) {
$tv = stripslashes($tv);
$tv = str_replace("\"","[QT]",$tv);
$tv = str_replace("\r","<br>",$tv);
return $tv;
}
TSTprotectText($_POST['field']);
Now how can that be?
> Can you be a little more specific on what differences you get?
>
> I normally use textarea for multi-line data and input type="text" for one
> line, short data... the only difference you might encounter that I can think
> off the top of my head is maybe line break?
>
>
> ----- Original Message -----
> From: "Sam Smith" <[EMAIL PROTECTED]>
> To: "PHP" <[EMAIL PROTECTED]>
> Sent: Sunday, October 10, 2004 3:28 PM
> Subject: [PHP] textarea vs. type="text" data difference?
>
>
>>
>> I have a form with both textarea and text type fields.
>>
>> I submit it and do some processing on identical data and get different
>> results.
>>
>> What's up with that.
>>
>> Thank you.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
--- End Message ---
--- Begin Message ---
On Sun, 10 Oct 2004 12:28:53 -0700, Sam Smith <[EMAIL PROTECTED]> wrote:
> I have a form with both textarea and text type fields.
>
> I submit it and do some processing on identical data and get different
> results.
>
> What's up with that.
No idea since you didn't post any code.
--
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/
--- End Message ---
--- Begin Message ---
Okay, so in other words...
//Doc1.php
include functions.php //this file contains the function definition for
"protectText()"
include formProcessor.php //this file contains the code that calls
"protectText()"
include form.php //this file gets the form data from user
By any chance, are ANY of the include files classes? I'm not 100%
sure(unless you put up some more code), but it sounds like it's maybe a
scope error... especially if you define the function in formProcessor and it
works fine...
-Minuk
----- Original Message -----
From: "Sam Smith" <[EMAIL PROTECTED]>
To: "PHP" <[EMAIL PROTECTED]>
Sent: Sunday, October 10, 2004 4:25 PM
Subject: Re: [PHP] textarea vs. type="text" data difference?
##The data is the same. I've been up a long time.
BUT something is still very weird.
Doc1.php (loaded in web browser)
//contents of Doc1.php
include functions.php
include formProcessor.php
include form.php
Calling the "protectText()" function in "functions.php" from
"formProcessor.php" with data posted from "form.php" works on data posted
from textarea fields but does NOT on data posted from type="text".
//contents of functions.php ONLY works on textarea fields
The fundtion in function.php is:
function protectText($tv) {
$tv = stripslashes($tv);
$tv = str_replace("\"","[QT]",$tv);
$tv = str_replace("\r","<br>",$tv);
return $tv;
}
BUT if I put the same function in "formprocessor.php" it works!??
//contents of formprocessor.php THIS works on both
function TSTprotectText($tv) {
$tv = stripslashes($tv);
$tv = str_replace("\"","[QT]",$tv);
$tv = str_replace("\r","<br>",$tv);
return $tv;
}
TSTprotectText($_POST['field']);
Now how can that be?
Can you be a little more specific on what differences you get?
I normally use textarea for multi-line data and input type="text" for one
line, short data... the only difference you might encounter that I can
think
off the top of my head is maybe line break?
----- Original Message -----
From: "Sam Smith" <[EMAIL PROTECTED]>
To: "PHP" <[EMAIL PROTECTED]>
Sent: Sunday, October 10, 2004 3:28 PM
Subject: [PHP] textarea vs. type="text" data difference?
I have a form with both textarea and text type fields.
I submit it and do some processing on identical data and get different
results.
What's up with that.
Thank you.
--
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 ---
htmlentities!
Thanks a lot for taking the time but it was just my nubie error.
What had me going all off in the wrong direction was textarea fields don't
need htmlentities to display quotes correctly like a text field does.
you know like this: value="some text" with important info"
Displays in textarea fine but in type=text of course you get
"some text
What a female dog.
> Okay, so in other words...
>
> //Doc1.php
>
> include functions.php //this file contains the function definition for
> "protectText()"
> include formProcessor.php //this file contains the code that calls
> "protectText()"
> include form.php //this file gets the form data from user
>
> By any chance, are ANY of the include files classes? I'm not 100%
> sure(unless you put up some more code), but it sounds like it's maybe a
> scope error... especially if you define the function in formProcessor and it
> works fine...
>
> -Minuk
>
> ----- Original Message -----
> From: "Sam Smith" <[EMAIL PROTECTED]>
> To: "PHP" <[EMAIL PROTECTED]>
> Sent: Sunday, October 10, 2004 4:25 PM
> Subject: Re: [PHP] textarea vs. type="text" data difference?
>
>
>>
>> ##The data is the same. I've been up a long time.
>>
>> BUT something is still very weird.
>>
>> Doc1.php (loaded in web browser)
>> //contents of Doc1.php
>> include functions.php
>> include formProcessor.php
>> include form.php
>>
>> Calling the "protectText()" function in "functions.php" from
>> "formProcessor.php" with data posted from "form.php" works on data posted
>> from textarea fields but does NOT on data posted from type="text".
>>
>> //contents of functions.php ONLY works on textarea fields
>> The fundtion in function.php is:
>> function protectText($tv) {
>> $tv = stripslashes($tv);
>> $tv = str_replace("\"","[QT]",$tv);
>> $tv = str_replace("\r","<br>",$tv);
>> return $tv;
>> }
>>
>> BUT if I put the same function in "formprocessor.php" it works!??
>>
>> //contents of formprocessor.php THIS works on both
>> function TSTprotectText($tv) {
>> $tv = stripslashes($tv);
>> $tv = str_replace("\"","[QT]",$tv);
>> $tv = str_replace("\r","<br>",$tv);
>> return $tv;
>> }
>>
>> TSTprotectText($_POST['field']);
>>
>> Now how can that be?
>>
>>
>>> Can you be a little more specific on what differences you get?
>>>
>>> I normally use textarea for multi-line data and input type="text" for one
>>> line, short data... the only difference you might encounter that I can
>>> think
>>> off the top of my head is maybe line break?
>>>
>>>
>>> ----- Original Message -----
>>> From: "Sam Smith" <[EMAIL PROTECTED]>
>>> To: "PHP" <[EMAIL PROTECTED]>
>>> Sent: Sunday, October 10, 2004 3:28 PM
>>> Subject: [PHP] textarea vs. type="text" data difference?
>>>
>>>
>>>>
>>>> I have a form with both textarea and text type fields.
>>>>
>>>> I submit it and do some processing on identical data and get different
>>>> results.
>>>>
>>>> What's up with that.
>>>>
>>>> Thank you.
>>>>
>>>> --
>>>> 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 ---
On Friday 01 October 2004 21:06, Christophe Chisogne wrote:
> but here's what my apache logrotate config looks like:
Try httplog, it's a very nice replacement for logrotate.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
Everyone can be taught to sculpt: Michelangelo would have had to be
taught how ___not to. So it is with the great programmers.
*/
--- End Message ---
--- Begin Message ---
I meant to say that I'm on PHP 4.3.8, apache 1.3
Global Variables are on.
If you read below for each form element (textbox,
menu) I've set a value of value= "<?php echo
$_SESSION['ListingName']; ?>">
I believe that is not setting the session variable but
merely grabbing the input from the user.
So what I can't find out after digging through books
and googling, is how / where to actually declare the
variable.
Seems most of the examples use a variable that is set
already by the programmer, not by the user.
Stuart
--- Stuart Felenstein <[EMAIL PROTECTED]> wrote:
> I cant figure out if I'm doing something wrong or my
> web server is:
> I have a multi page form that will span 5, now I'm
> just trying to get it too 3 pages working.
> If I go from Page 1 direct to Page 3, then the
> variables print out fine on Page 3. If I go Page 1
> then Page 2 and then to Page 3, only Page2 variables
> print out on 3.
>
> I must be missing something ?
>
>
> Page1: excerpt:
>
> <?php
> session_start();
> ?>
>
> <?php
> print "<p>Welcome, your session ID is
> ".session_id()."</p>\n\n";
> ?>
>
> <div>
> <form name="form1" id="form1" method="post"
> action="TestMulti2.php">
> <table width="419" border="1" align="center"
> cellpadding="2" cellspacing="2">
> <tr>
> <td width="227"><div align="right">Listing
> Name</div></td>
> <td width="172"><input name="ListingName"
> type="text" id="ListingName" value="<?php echo
> $_SESSION['ListingName']; ?>"></td>
>
> Page 2:
>
> <?php
> session_start();
>
> if ( empty( $_SESSION['l_industry'] ) ) {
> $_SESSION['l_industry']=array();
> }
>
> if ( is_array( $_REQUEST['LurkerIndustry'] ) ) {
> $_SESSION['l_industry'] = array_unique(
> array_merge( $_SESSION['l_industry'],
> $_REQUEST['LurkerIndustry'] )
> );
> }
> if ( empty( $_SESSION['l_tterm'] ) ) {
> $_SESSION['l_tterm']=array();
> }
>
> if ( is_array( $_REQUEST['LurkerTaxTerm'] ) ) {
> $_SESSION['l_tterm'] = array_unique(
> array_merge( $_SESSION['l_tterm'],
> $_REQUEST['LurkerTaxTerm'] )
> );
> }
> ?>
>
> Page 3:
>
> <?php
> session_start();
> ?>
> <?php
> print "<p>Welcome, your session ID is
> ".session_id()."</p>\n\n";
> ?>
>
> <?php
> echo "\$ListingName = ".$ListingName."<br/>";
> echo "\$AltP1 = ".$AltP1." <br/>";
> echo "\$AltP2 = ".$AltP2." <br/>";
> echo "\$Pgr = ".$Pgr." <br/>";
> echo "\$El2 = ".$El2." <br/>";
> echo "\$El3 = ".$El3." <br/>";
> echo "\$LurkerEdu = ".$LurkerEdu."<br/>";
> echo "\$LurkerAuth = ".$LurkerAuth." <br/>";
> echo "\$LurkerExperience = ".$LurkerExperience."
> <br/>";
> echo "\$LurkerLevel = ".$LurkerLevel." <br/>";
> echo "\$LurkerSecurity = ".$LurkerSecurity." <br/>";
>
> echo $LurkerIndustry['0']."<br />";
> echo $LurkerIndustry['1']."<br />";
> echo $LurkerIndustry['2']."<br />";
> echo $LurkerIndustry['3']."<br />";
> echo $LurkerIndustry['4']."<br />";
> echo $LurkerTaxTerm['0']."<br />";
> echo $LurkerTaxTerm['1']."<br />";
> echo $LurkerTaxTerm['2']."<br />";
> ?>
>
>
> Thank you
> Stuart
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Thanks. Your SMS service looks ideal for what I need but how do I make an
HTTP request from PHP to kapow?
Can I just use fopen()?
Please can you give a PHP example.
> We operate an SMS Gateway service (http://www.kapow.co.uk/) which would do
> exactly what you need.
> It's been reliably sending SMS since 1995 - and MANY of our clients use
PHP.
>
> What you'd probably want to do is make an HTTP Get / Post request directly
> from your script to our servers, alternatively you can use our
Email-to-SMS
> interface and then just generate an email.
>
> Using either method with PHP should get you up and running in a few
minutes.
--- End Message ---
--- Begin Message ---
You can use SMSTERM
/sagar
----- Original Message -----
From: "SunTan.co.uk" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, October 10, 2004 7:38 PM
Subject: [PHP] sending SMS messages to mobile phones from PHP
> Hi there,
>
> I want my website to be able to send me an SMS message to my phone when
> somebody fills our contact form in.
> Does anybody do this already? If so, how?
> I think that I need an SMS service but I'm not sure what one is or how
much
> it'll cost us.
> Please advise.
>
> [EMAIL PROTECTED]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
--- End Message ---
--- Begin Message ---
Hi,
Am totally puzzled as to how they are doing this.
The site is at
http://www.teeniesxxx.com/madtgp/submit.php (please
note its an adult site so you might not want to go
there, also note I am in NO way connected with that
site...AT ALL)
once a person submits a site, they are doing 2 things
that totally puzzle me,
1.showing the number of "outgoing links"
2. counting the number of linked to pictures (eg:
href='blah.jpg') and movies (eg: href='blah,mpg') and
also giving the size of each movie (this i figured
out) and the resulation!!
I would like to do the same thing for a cartoon site,
can anybody tell me where to begin or some sample
code?
Thanks,
Mag
=====
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
__________________________________
Do you Yahoo!?
Y! Messenger - Communicate in real time. Download now.
http://messenger.yahoo.com
--- End Message ---
--- Begin Message ---
Mag wrote:
once a person submits a site, they are doing 2 things
that totally puzzle me,
1.showing the number of "outgoing links"
Middle man. You have them click on a link containing an ID, increment
the counter for that ID, then forward them to the requested link.
2. counting the number of linked to pictures (eg:
href='blah.jpg') and movies (eg: href='blah,mpg') and
also giving the size of each movie (this i figured
out) and the resulation!!
Can as easy as a regex match for ".jpg" or ".mpg".
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
--- End Message ---
--- Begin Message ---
hi, does anyone know why this is not working, i have married 2 pieces of
code together and i have no idea what im doing--any help is appreciated.
I get an error that says it cant find the host--$host so obviusly its not
passing it from the form.
/////////////////////////////////////////
<?php
$host = $_POST['host'];
$user = $_POST['user'];
$pass = $_POST['pass'];
$db_name = $_POST['db-name'];
$link = mysql_connect('$host', '$user', '$pass');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
if (mysql_create_db('db_name')) {
echo "Database created successfully\n";
} else {
echo 'Error creating database: ' . mysql_error() . "\n";
}
?>
/////////////////////////////////////////////
--- End Message ---
--- Begin Message ---
try this :
$link = mysql_connect($host, $user, $pass);
Note : No SINGLE quotes.
In PHP, quotations are as follows
$host = 'localhost';
$a = '$host';
$b = "$host";
echo $a;
that prints $host
echo $b;
that prints localhost.
HTH
-Minuk
----- Original Message -----
From: "bigmark" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, October 10, 2004 10:23 PM
Subject: [PHP] forms/variables/create database
hi, does anyone know why this is not working, i have married 2 pieces of
code together and i have no idea what im doing--any help is appreciated.
I get an error that says it cant find the host--$host so obviusly its not
passing it from the form.
/////////////////////////////////////////
<?php
$host = $_POST['host'];
$user = $_POST['user'];
$pass = $_POST['pass'];
$db_name = $_POST['db-name'];
$link = mysql_connect('$host', '$user', '$pass');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
if (mysql_create_db('db_name')) {
echo "Database created successfully\n";
} else {
echo 'Error creating database: ' . mysql_error() . "\n";
}
?>
/////////////////////////////////////////////
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Thanks-- i got that going-GREAT ! now i have a form that creates the
database and tables, any ideas how i can get this info to change the
connect_db file so that it doesnt have to be done manually.
"Minuk Choi" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> try this :
>
> $link = mysql_connect($host, $user, $pass);
>
> Note : No SINGLE quotes.
>
> In PHP, quotations are as follows
>
> $host = 'localhost';
> $a = '$host';
> $b = "$host";
>
> echo $a;
>
> that prints $host
>
> echo $b;
>
> that prints localhost.
>
> HTH
> -Minuk
>
>
> ----- Original Message -----
> From: "bigmark" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, October 10, 2004 10:23 PM
> Subject: [PHP] forms/variables/create database
>
>
> > hi, does anyone know why this is not working, i have married 2 pieces of
> > code together and i have no idea what im doing--any help is appreciated.
> > I get an error that says it cant find the host--$host so obviusly its
not
> > passing it from the form.
> >
> > /////////////////////////////////////////
> > <?php
> > $host = $_POST['host'];
> > $user = $_POST['user'];
> > $pass = $_POST['pass'];
> > $db_name = $_POST['db-name'];
> >
> >
> > $link = mysql_connect('$host', '$user', '$pass');
> > if (!$link) {
> > die('Could not connect: ' . mysql_error());
> > }
> >
> > if (mysql_create_db('db_name')) {
> > echo "Database created successfully\n";
> > } else {
> > echo 'Error creating database: ' . mysql_error() . "\n";
> > }
> > ?>
> > /////////////////////////////////////////////
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
--- End Message ---
--- Begin Message ---
Thanks-- i got that going-GREAT ! now i have a form that creates the
database and tables, any ideas how i can get this info to change the
connect_db file so that it doesnt have to be done manually.
See fopen(), fwrite(), and fclose():
http://php.net/manual/en/ref.filesystem.php
Not sure exactly what you're doing, but having PHP (via http) use a
mysql account with create privileges and write your configuration files
is a gaping security hole - fine for a
personal/internal/ephemeral/testing project, but terrible security
practice for any application or site that faces the outside world.
------------------------------------------------------
michal migurski- contact info, blog, and pgp key:
sf/ca http://mike.teczno.com/contact.html
--- End Message ---
--- Begin Message ---
Thanks to all of you for your explanation of my method. Minuk, thanks for
the detailed explanation, it really helps me understand what I'm doing
wrong.
Now I have one more problem. When the $children array is empty, it returns a
10 instead of a 0. Why is that? Here's the method again with the recommended
improvements you guys provided:
function get_children($parent) {
// FORMULA: rgt value of first child + 1 = left value of second
child
// check rgt value of parent against each child (rgt + 1).
// If rgt valueof child plus 1 equals rgt value of parent
then
// that child is the last child of the parent.
$parent_coord = tree::get_item_coord($parent);
$descendants = $this->get_descendants($parent);
$children = array();
for ($i = 0; $i < count($descendants); $i++) {
if ((empty($children)) && (($parent_coord['0']['lft'] + 1) ==
$descendants[$i]['lft'])) {
$children[] = $descendants[$i]; // found first child
}
elseif (($children[count($children)-1]['rgt'] + 1 ==
$descendants[$i]['lft']) && $children[count($children)-1]['rgt'] + 1 !=
$parent_coord['0']['rgt']) {
$children[] = $descendants[$i]; // find next children
}
}
if (count($children)>0) {
return $children;
} else {
return 0;
}
}
----------------------------------------------------------------------------
-----Original Message-----
From: Minuk Choi [mailto:[EMAIL PROTECTED]
Sent: Sunday, October 10, 2004 1:55 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP]
I can tell you from a quick glance that you have the following case
function X()
{
if ()
{
$children=...
}
elseif ()
{
$children=...
}
return $children;
}
Have you tried giving $children an initial value, such as
function X()
{
$children = array();
if ()
{
$children[]=...
}
elseif ()
{
$children[]=...
}
if (count($children)>0)
return $children;
return 0;
}
I may be getting a head of myself, but the
$children[]=...
line adds the $descendants into the ARRAY variable, $children. Unless I'm
wrong, you MUST declare $children as an ARRAY FIRST(see first line of the
function, "$children=array();")
Secondly, if you want the function to return 0 if no $descendant entries are
added to $children, you must check to see if the $children ARRAY is EMPTY.
if (count($children)>0)
return $children;
that line basically says if ARRAY variable $children has more than 0
elements, return that ARRAY.
Finally,
return 0;
if the ARRAY variable $children has 0 elements(count($children) returns the
number of elements in ARRAY variable, $children), "return $children" is NOT
executed. The next line is "return 0".
This is a lazy way of writing the following :
if (count($children)>0)
return $children;
else
return 0;
If it seems like I'm explaining too much, it's because from the code
snipplet you provided, it sounds like you're a novice to PHP... and you did
write, '...explain this error to me'. :-P
Hope This Helps
-Minuk
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, October 09, 2004 10:29 PM
Subject: [PHP]
> Hello everyone,
>
> I'm hoping you guys can help me with this error. Here's what I'm getting:
>
> Notice: Undefined variable: children in
> L:\localhost\catalog\catalog_0.1.0\includes\classes\tree.class.php on line
> 58
>
> This error occurs only when the class's method outputs $children as having
> a
> value of zero. Below is the class. I want it to return zero but I don't
> want
> this error. Do I need to change my error settings in my php.ini file? The
> error level is currently set to E_ALL and I'm using PHP 5.0.1. If at all
> possible, I want to keep this error setting at high because I want
> everything to be coded strictly. What did I do wrong in my class and how
> can
> I fix it to where it doesn't output an error when a class's method returns
> a
> value of zero? Here's the class:
>
> function get_children($parent) {
> $parent_coord = tree::get_item_coord($parent);
> $descendants = $this->get_descendants($parent);
> for ($i = 0; $i < count($descendants); $i++) {
> if ((empty($children)) && (($parent_coord['0']['lft'] + 1) ==
> $descendants[$i]['lft'])) {
> $children[] = $descendants[$i]; // found first child
> }
> elseif (($children[count($children)-1]['rgt'] + 1 ==
> $descendants[$i]['lft']) && $children[count($children)-1]['rgt'] + 1 !=
> $parent_coord['0']['rgt']) {
> $children[] = $descendants[$i]; // find next children
> }
> }
> return $children;
> }
>
>
> Thanks in advance to anyone that can explain this error to me.
>
> Nilaab
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--- End Message ---
--- Begin Message ---
Hi
I am having trouble running the example from:
http://www.theukwebdesigncompany.co...code-module.php
Am running PHP5.0.2 running on a windows XP box.
I've setup the test email message as:
PHP Code:
$input = "Return-Path: <[EMAIL PROTECTED]>
Delivered-To: [EMAIL PROTECTED]
Received: (qmail 4400 invoked from network); 6 Mar 2003 18:13:52 -0000
Received: from unknown (HELO localhost) ([EMAIL PROTECTED])
by localhost with SMTP; 6 Mar 2003 18:13:52 -0000
X-Flags: 0000
Delivered-To: GMX delivery to [EMAIL PROTECTED]
<!-- snip snip -->"
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
$params['input'] = $input;
// do the decode
$structure = Mail_mimeDecode::decode($params);
// save the attachment as a file.
foreach ($structure->parts as $part) {
// only save if an attachment
if (isset($part->disposition) and ($part->disposition=='attachment')) {
// open file
$fp = fopen($part->ctype_parameters['filename'], 'w');
// write body
fwrite($fp, $part->body);
// close file
fclose($fp);
}
}
I've included the correct PEAR file..and all quotation marks are escaped
properly in the $input. However I get the following message:
Fatal error: Using $this when not in object context in
c:\php5\PEAR\Mail\mimeDecode.php on line 168
Is this PHP5 being buggy? I need to run in 5 as I'm using simpleXML. In the
bigger picture all I want to decode is XML attached files.
Kind Regards
Dave.
--- End Message ---
--- Begin Message ---
Thanks for the help with the createdb and tables form, now can anyone help
with changing the config.php
(ie: host,user,password) via a form also-- so that it doesnt have to be done
manually within the config script.
Basically i want an install/setup page with all the form elements--
Hostname-
username-
Password-
Choose database name-
Then it installs the database and tables then redirects to the main site
page and the config.php is already configured for them
BigMark
--- End Message ---
--- Begin Message ---
I'm trying to write text to an image but some parts of the text should be in italics.
For instance, I have the following string.
$string = "This is a [i]test[/i] string that [i]has[/i] some parts in [i]italics[/i]"
How do I display that on an image using the image functions with php but display the
parts between [i][/i] in italics?
How would you guy's do it?
Thanks,
Brent
--- End Message ---
--- Begin Message ---
Concerning PEAR::Auth
I can't tune interaction between PEAR::Auth and MySQL.
Typical code
<?php
$dbtype = 'mysql';
$dbhost = 'localhost';
$dbuser = '';
$dbpass = '';
$dbname = "cosmos";
$dsn = "$dbtype://$dbuser:[EMAIL PROTECTED]/$dbname";
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);
require_once "Auth/Auth.php";
function loginFunction(){
echo "<form method=\"post\" action=\"" . $_SERVER['PHP_SELF'] . "\">";
echo "<input type=\"text\" name=\"username\">";
echo "<input type=\"password\" name=\"password\">";
echo "<input type=\"submit\">";
echo "</form>";
}
$a = new Auth("DB", $dsn, "loginFunction");
$a->start();
if ($a->getAuth()){
echo "OK";
}
?>
With typical SQL statement:
CREATE TABLE auth(
username VARCHAR(50) default '' NOT NULL,
password VARCHAR(32) default '' NOT NULL,
PRIMARY KEY (username),
KEY (password));
I tried:
INSERT INTO auth VALUES ('qq', 'pp');
after submitting the login form the process buzzes on the procedure start();
I tried too:
INSERT INTO auth VALUES ('qq', PASSWORD('pp'));
I tried (using phpMyAdmin):
GRANT SELECT , INSERT , UPDATE , DELETE , CREATE , INDEX , ALTER ON * . *
TO "qq"@ localhost" WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR
0 MAX_UPDATES_PER_HOUR 0 ;
But process buzzes on the procedure start() as before;
How to set username and password?
Vlad Alivanov
--- End Message ---
--- Begin Message ---
I would like to know how I can code the the following conditional
check.... if the $_GET['api'] does not exist, or is either set and has
no length or is set and is not an integer.
I am drawing a blank on the if statement to use....
--- End Message ---
--- Begin Message ---
Gh wrote:
I would like to know how I can code the the following conditional
check.... if the $_GET['api'] does not exist, or is either set and has
no length or is set and is not an integer.
I am drawing a blank on the if statement to use....
if(!isset($_GET['api'] || strlen($_GET['api']) == 0 ||
!is_numeric($_GET['api'])) {
// do something
}
--- End Message ---
--- Begin Message ---
M. Sokolewicz wrote:
Gh wrote:
I would like to know how I can code the the following conditional
check.... if the $_GET['api'] does not exist, or is either set and has
no length or is set and is not an integer.
I am drawing a blank on the if statement to use....
I meant to say the following (notice the added brace ;))
if(!isset($_GET['api']) || strlen($_GET['api']) == 0 ||
!is_numeric($_GET['api'])) {
// do something
}
--- End Message ---
--- Begin Message ---
With the following code, I am getting the following message....
Parse error: parse error, expecting `')'' in
/var/www/html/cert/admin_template.php on line 30
Line 30 Reads as follows:
foreach($admin_get_options_result as $api => $file, $desc)
Can any one please assist.
***************ENTIRE CODE STARTING AT LINE 1 FOLLOWS *************
<html>
<head>
<title>ADMINISTRATION SCREEN</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?PHP
require 'mod/db_access.php';
echo 'this is a test of the system';
if(!isset($_GET['api']) || (isset($_GET['api']) &&
((strlen(trim(urldecode($_GET['api']))) == 0) ||
(!is_int($_GET['api'])))))
$_GET['api']=0;
if($_GET['api'] == 0)
{
$admin_get_options_query_text = "Select * from Adminpage";
$admin_get_options_results_reference =
mysql_query($admin_get_options_query_text,$db_access) or die("Admin
Get Options: ". mysql_error());
$admin_get_options_result =
mysql_fetch_assoc($admin_get_options_result_reference);
if(mysql_num_rows($admin_get_options_results_reference)>0)
{
?>
<table width="600">
<TR> <TD> Link </TD> <TD> DESCRIPTION </TD></TR>
<?PHP
foreach($admin_get_options_result as $api => $file, $desc)
{
echo '<TR> <TD>';
echo '<a href="#?api'.urlencoded($api).'"> Click Here
</a> </td>';
echo '<TD>'.$desc.'</TD></TR>';
}
?>
</table>
<?PHP
}
}
else
{
$admin_get_page_query_text = "Select * from Adminpage Where
adminpageid = $_GET['api'] LIMIT 1";
$admin_get_page_results_reference =
mysql_query($admin_get_page_query_text,$db_access) or die("Admin Get
Page: ". mysql_error());
$admin_get_page_result = mysql_fetch_row($admin_get_page_result_reference);
if (mysql_num_rows($admin_get_page_results_reference) > 0)
{
require "mod/admin/".trim(strtolower($admin_get_page_result[1]));
}
else
{
echo "ERROR: Invalid Admin Page Requested <br>";
echo 'Please Try Again ... <a href="admin_template.php?api=0"> Click
Here </a>';
}
}
?>
</body>
</html>
--- End Message ---