php-general Digest 4 Mar 2005 11:29:18 -0000 Issue 3318
Topics (messages 209948 through 209968):
What is the 'cli' interface.
209948 by: Daniel Guerrier
209952 by: Jay Blanchard
209953 by: Jochem Maas
Re: [noob] can't submit simple form, need help
209949 by: Jay Blanchard
209950 by: Warren Vail
209951 by: Jochem Maas
Re: Authentication fails - problem line found
209954 by: John Swartzentruber
Re: Document root, preferred way to find it???
209955 by: Tom Rogers
209958 by: Leif Gregory
Re: Preventing data from being reposted?
209956 by: pmpa
209957 by: pmpa
which class it is?
209959 by: yangshiqi
209963 by: Jochem Maas
209966 by: yangshiqi
209967 by: yangshiqi
209968 by: anirudh dutt
email attach and contain message together
209960 by: agung.prematours.com
209964 by: Jochem Maas
upload and resize image script
209961 by: p80
Re: mysql problems
209962 by: Jed R. Brubaker
Re: Read From COM1 port
209965 by: Kim Madsen
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 ---
I am getting this error using ezpublish to import RSS
feeds. Does anyone know what this means.
PHP is currently using the 'apache2handler' interface.
Make sure it is using the 'cli' interface.
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
--- Begin Message ---
[snip]
Make sure it is using the 'cli' interface.
[/snip]
Command Line Interface
--- End Message ---
--- Begin Message ---
Daniel Guerrier wrote:
I am getting this error using ezpublish to import RSS
feeds. Does anyone know what this means.
if you want to ask a new question then dont reply to an existing
post. post a new message.
PHP is currently using the 'apache2handler' interface.
Make sure it is using the 'cli' interface.
Command Line Interpreter. it a special 'kind' of php that built
specifically to be used on the cmdline (e.g. DOS on windows,
bash on linux, etc)
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
--- End Message ---
--- Begin Message ---
[snip]
any idea why this simple peace of code is not working?
// code that will be executed if the form has been submitted:
$submit_post=$_REQUEST['submit'];
if ($submit_post=='yes')
[/snip]
Probably because $_REQUEST['submit'] !== 'yes'
print_r($_REQUEST); to see the array
--- End Message ---
--- Begin Message ---
> $submit_post=$_REQUEST['submit'];
>
> if ($submit_post=='yes') {
looks like the value in your form is not 'yes' but 'submit'
>
> <p><input type="submit" name="submit" value="submit" /> </p>
>
if this is not it, perhaps we should see more.
Warren Vail
--- End Message ---
--- Begin Message ---
p80 wrote:
any idea why this simple peace of code is not working?
now lets see:
1. <?php
2. // code that will be executed if the form has been submitted:
3. $submit_post=$_REQUEST['submit'];
4.
5. if ($submit_post=='yes') {
$submit_post will never equal 'yes' because your submit buttons value is
'submit' and its name is also 'submit', the POST value is are overwriting
the GET value (thats default order for php anyway)
removing the name attribute of the submit button should do the trick.
6.
7. // connect to the database
8. // (you may have to adjust the hostname,username or password)
9.
10. include "db.php";
11.
12.
13. $result=MYSQL_QUERY("INSERT INTO machines
14. (description_fr) ".
15. "VALUES ('$form_description_en')");
you might want to sanitize $form_description_en before sticking it in your
query like that. see http://php.net/mysql_escape_string
16. $bob = $img->image_name;
who is bob... why are you trying to get the property of
a non-existent object? php will have a fatal one on this.
17.
18. #$thumbdata = addslashes(fread(fopen('.thumb/$bob', "r")));
19.
20.
21.
22.
23. $id= mysql_insert_id();
24.
25. print "query success!";
26. echo "$form_description_en";
the quotes around the var above are a waste of cpu.
the following will do:
echo $form_description_en;
27. MYSQL_CLOSE();
28.
29. }
30.
31.
32. ?>
33.
34. <form method="post" action="test.php?submit=yes"
enctype="multipart/form-data" />
35. Description:<br />
36. <textarea name="form_description_en" id="form_description_en" rows="4"
cols="40"></textarea><br />
37.
38. <p><input type="submit" name="submit" value="submit" /> </p>
39.
40. </form>
http://hashphp.org/pastebin?pid=1880
thanx in advance
--- End Message ---
--- Begin Message ---
I stripped down my original script until it started receiving POST data,
then I kept modifying it until I figured out where the problem was. I
found it, but I'm still as clueless as every.
To summarize: I have a form that posts to the same script that contains
the form. In its original state, when the script is called after I
submit the form data, the $_POST[] data is completely empty and the
_SERVER variable that indicates the type of data is set to "GET".
In the script is the following code:
if (IsSet($_POST["action"])) {
// $action = $_POST["action"];
} else {
$action = $_GET["action"];
}
Normally the second line is not commented. When I comment out that line,
then the $_POST array has all of the data I would expect it to. When it
is not commented, then it does not work.
Just to make sure that I am really confused, this bit of code is *after*
the call to var_dump($_POST), but *before* the code that creates the form.
Does anyone have any ideas about why setting this variable has such a
large and seemingly unrelated affect?
--- End Message ---
--- Begin Message ---
Hi,
Thursday, March 3, 2005, 11:54:48 AM, you wrote:
A> If I'm reading you correctly, then a truly transportable include might look
like
A> this:
A> $doc_root= (isset($_SERVER['path_translated'])?
A> $_SERVER['path_translated'] :
A> $_SERVER['document_root'];
Exactly
--
regards,
Tom
--- End Message ---
--- Begin Message ---
Hello Richard,
Thursday, March 3, 2005, 1:15:38 PM, you wrote:
RL> include_path
In the php.ini? But wouldn't that affect every virtual host on the
server? Meaning I'd have to put all the includes for every virtual
host in the same place?
Cheers,
Leif Gregory
--
TB Lists Moderator (and fellow registered end-user)
PCWize Editor / ICQ 216395 / PGP Key ID 0x7CD4926F
Web Site <http://www.PCWize.com>
--- End Message ---
--- Begin Message ---
Hi!
If I understand you correctly, I hope this helps:
<?
// file.php
ob_start();
session_start();
If (!isset($_SESSION['login'])){
If ( !( isset($_POST['name']) && isset($_POST['password']) &&
trim($_POST['name'])!="" && trim($_POST['password'])!="" ) ){
?>
<form method="post" action="file.php">
<input type="text" name="name">
<input type="password" name="password">
</form>
<?
}
else {
if (trim($_POST['name'])=="yourname" &&
trim($_POST['password'])=="yourpassword"){
$_SESSION['login']=$_POST['name'];
Header("Location file.php");
}
else {
// wrong data.
Header("Location file.php");
}
}
}
else {
$name=$_SESSION['login'];
echo "You are logged as ".$name;
}
?>
There are probably some errors I haven't run the code.
Pedro.
-----Mensagem original-----
De: rory walsh [mailto:[EMAIL PROTECTED]
Enviada: quinta-feira, 3 de Mar�o de 2005 12:01
Para: [email protected]
Assunto: [PHP] Preventing data from being reposted?
Is there anyway I can prevent data from being reposted when I hit the
back button on my browser? When I hit back I get a message from my
browser asking do I want to repost the data, can I prevent this window
from appearing?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Sorry, Wrong Reply!!
My mistake :(
---------------------------------------------
Hi!
If I understand you correctly, I hope this helps:
<?
// file.php
ob_start();
session_start();
If (!isset($_SESSION['login'])){
If ( !( isset($_POST['name']) && isset($_POST['password']) &&
trim($_POST['name'])!="" && trim($_POST['password'])!="" ) ){
?>
<form method="post" action="file.php">
<input type="text" name="name">
<input type="password" name="password">
</form>
<?
}
else {
if (trim($_POST['name'])=="yourname" &&
trim($_POST['password'])=="yourpassword"){
$_SESSION['login']=$_POST['name'];
Header("Location file.php");
}
else {
// wrong data.
Header("Location file.php");
}
}
}
else {
$name=$_SESSION['login'];
echo "You are logged as ".$name;
}
?>
There are probably some errors I haven't run the code.
Pedro.
-----Mensagem original-----
De: rory walsh [mailto:[EMAIL PROTECTED]
Enviada: quinta-feira, 3 de Mar�o de 2005 12:01
Para: [email protected]
Assunto: [PHP] Preventing data from being reposted?
Is there anyway I can prevent data from being reposted when I hit the
back button on my browser? When I hit back I get a message from my
browser asking do I want to repost the data, can I prevent this window
from appearing?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
I have a question that how to get the class name, which is initialized by
other class or function.
For example:
Class a
{
Function a(){}
}
Class b
{
Function b()
{
$a= new a;
...
}
}
How can I get class b's name in a?
Best regards,
Yang Shiqi
--- End Message ---
--- Begin Message ---
yangshiqi wrote:
I have a question that how to get the class name, which is initialized by
other class or function.
...
How can I get class b's name in a?
you have the get_class() function,
you have the __CLASS__ constant....
can you give an example of a situation where you are having
trouble of retrieving the className of a subclassed object (or class)?
Best regards,
Yang Shiqi
--- End Message ---
--- Begin Message ---
class DebugHelper
{
var $_str;
function do($string)
(
//here I want to know which class called this function do to
trace the bug.
$this->_str .= $string;
)
function show()
{
return $this->_str;
}
}
class B
{
function B()
{
$debug = &new DebugHelper;
$debug->do('here');
...
}
}
Best regards,
Yang Shiqi
-----Original Message-----
From: Jochem Maas [mailto:[EMAIL PROTECTED]
Sent: Friday, March 04, 2005 4:43 PM
To: yangshiqi
Cc: [email protected]
Subject: Re: [PHP] which class it is?
yangshiqi wrote:
> I have a question that how to get the class name, which is initialized by
> other class or function.
>
...
>
>
> How can I get class b's name in a?
>
you have the get_class() function,
you have the __CLASS__ constant....
can you give an example of a situation where you are having
trouble of retrieving the className of a subclassed object (or class)?
>
>
>
>
> Best regards,
>
> Yang Shiqi
>
>
>
>
>
>
>
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
And I do not want all my classes to inherit the debughelper.
Best regards,
Yang Shiqi
-----Original Message-----
From: yangshiqi [mailto:[EMAIL PROTECTED]
Sent: Friday, March 04, 2005 5:41 PM
To: 'Jochem Maas'
Cc: '[email protected]'
Subject: RE: [PHP] which class it is?
class DebugHelper
{
var $_str;
function do($string)
(
//here I want to know which class called this function do to
trace the bug.
$this->_str .= $string;
)
function show()
{
return $this->_str;
}
}
class B
{
function B()
{
$debug = &new DebugHelper;
$debug->do('here');
...
}
}
Best regards,
Yang Shiqi
-----Original Message-----
From: Jochem Maas [mailto:[EMAIL PROTECTED]
Sent: Friday, March 04, 2005 4:43 PM
To: yangshiqi
Cc: [email protected]
Subject: Re: [PHP] which class it is?
yangshiqi wrote:
> I have a question that how to get the class name, which is initialized by
> other class or function.
>
...
>
>
> How can I get class b's name in a?
>
you have the get_class() function,
you have the __CLASS__ constant....
can you give an example of a situation where you are having
trouble of retrieving the className of a subclassed object (or class)?
>
>
>
>
> Best regards,
>
> Yang Shiqi
>
>
>
>
>
>
>
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
On Fri, 4 Mar 2005 17:41:01 +0800, yangshiqi <[EMAIL PROTECTED]> wrote:
> class DebugHelper
> {
> var $_str;
> function do($string)
> (
> //here I want to know which class called this function do to
> trace the bug.
> $this->_str .= $string;
> )
> function show()
> {
> return $this->_str;
> }
> }
>
> class B
> {
> function B()
> {
> $debug = &new DebugHelper;
> $debug->do('here');
> ...
> }
> }
create a debug function (public) and use get_class. call that in the
debug function. when u want to do the debugging, use it with the obj
as parameter, maybe $this will work when u're in the class, otherwise,
use the object aka class instance variable.
u may wanna pass by reference and make it const (won't have to use
more memory for it...since it's task with it is small and read-only)
from http://php.net/get_class
[quote]
Example 1. Using get_class()
<?php
class foo {
function foo()
{
// implements some logic
}
function name()
{
echo "My name is " , get_class($this) , "\n";
}
}
// create an object
$bar = new foo();
// external call
echo "Its name is " , get_class($bar) , "\n";
// internal call
$bar->name();
?>
The above example will output:
Its name is foo
My name is foo
[/quote]
--
]#
Anirudh Dutt
...pilot of the storm who leaves no trace
like thoughts inside a dream
--- End Message ---
--- Begin Message ---
Hi all
I have the problem which I would like to send email with contain and
attachment ( excel file) together not just a part.
What should I do with the term please help
here the part of the code I use :
<?php
$boundary = '-----=' . md5( uniqid ( rand() ) );
$to = $HTTP_POST_VARS['email']. ', ';
$to .= $HTTP_POST_VARS['email2']. ', ';
$to .= $HTTP_POST_VARS['email3']. ', ';
$to .= $HTTP_POST_VARS['email4']. ', ';
$to .= $HTTP_POST_VARS['email5'];
$subject = $HTTP_POST_VARS['subject'];
$message = $HTTP_POST_VARS['message'];
$headers = "MIME-Version: 1.0\r \n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r \n";
$headers .= "X-Priority: 3\r \n";
$headers .= "X-MSMail-Priority: High\r \n";
$headers .= "From: Batukaru Team <[EMAIL PROTECTED]>\r \n";
$headers .= "Bcc: [EMAIL PROTECTED]";
$headers .= "Content-Type: application/xls\r \n";
$headers .= "Content-Transfer-Encoding: base64\n";
$headers .= "Content-Disposition: attachment; filename=test.xls\r \n";
$path = "test.xls";
$fp = fopen($path, 'r');
do //we loop until there is no data left
{
$data = fread($fp, 8192);
if (strlen($data) == 0) break;
$content .= $data;
} while (true);
$content_encode = chunk_split(base64_encode($content));
$headers .= $content_encode . "\n";
$headers .= "--" . $boundary . "\n";
regards.
agung
--- End Message ---
--- Begin Message ---
[EMAIL PROTECTED] wrote:
Hi all
I have the problem which I would like to send email with contain and
attachment ( excel file) together not just a part.
What should I do with the term please help
phpmailer.sourceforge.net
either save yourself the trouble of doing it yourself,
or use their code to figure out how to get it to work....
phpmailer is a really neat class, and a piece of cake to use.
...
--- End Message ---
--- Begin Message ---
hey all
I'm looking for a simple script that would upload an image and resize it to
thumbnail using a form to upload the picture. anyone has a good script for
that?
thanx in advance
Pat
--- End Message ---
--- Begin Message ---
Thank you both for your responces.
Unfotuantely there is no form that instantiates this action. So the double
submit (while a good idea), is not possible.
As for some sample code, it is part of a rather complicated system that
makes a number of changes but essentailly what is going on is this:
1. Grab all items that we need to do some shipping stuff to.
2. Foreach through the items, giving each item number to a function to
assign it to a customer and create a mailling label.
That simple!
The interesting this is this - the duplicate record is inserted into the
mailing labels queue. I can see it long before I grab the data for output to
labels. Moreover, I can tell that the problem isn't in the original item
select statement because the function (executed for each item) would have
created different insert times in the database based on the now( ).
More ideas?
Thanks!
"Jed R. Brubaker" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi all -
>
> I could use a lead on a problem. I just don't know where to start.
>
> I have a PHP script that populates a database table. No big deal. It
> creates mailing labels. However, a weird things keeps happening - every
> once in a while, a query is run twice. It is the same query, same
> information, even the same time (there is a now() in the query - and it is
> identical).
>
> So the question is a simple one - is this a PHP problem or a MySQL
> problem? Or somewhere in the MySQL extension? And how would I know?
>
> There is one clue to this otherwise vague problem. I believe that this
> predominantly happens when the database is under an above average load.
>
> I would appreciate any help that I might be able to get.
>
> Thank you.
--- End Message ---
--- Begin Message ---
From: Richard Lynch [mailto:[EMAIL PROTECTED]
Sent: 3. march 2005 20:56
>> $fp = fopen("COM1", "rwb");
> You might try this:
> $input = fopen("COM1", "rb");
> $output = fopen("COM1", "wb");
> Use $output to write, and $input to read.
On a windows one would have to close the connection every time then since that
OS only allow _one_ connection to the serial ports.
> Another possibility would be to check the manual...
I�ve been it around, as I wrote in the first mail, but something must have been
misspelled by me, cause I took the example from fgetc:
$fp = fopen("COM1", "w+b");
while (false !== ($char = fgetc($fp))) {
echo ".$char";
}
And nothing happened, so I figured that the switch might me locked somehow, I
turned it off and on again and suddenly all the start up info from the switch
was shown on my screen. I now use the example as a wrapper:
// open connection
$fp = fopen("COM1", "w+b");
// listen for output from $fp
while (false !== ($char = fgetc($fp))) {
// save chars in buffer, if NOT returns or newlines
if($char != "\r" && $char != "\n") {
$buffer .= $char;
// We need to know if things went wrong
if(trim($buffer) == "Error")
$response[] = "Error";
// execute commands
if(trim($buffer) == "SecOff >") {
$command = "$Sec[$SecOff]\r\n";
fwrite($fp, $command);
print "writing: $command\n";
$SecOff++;
$buffer = "";
}
}
I�m working on it as we speak, this is just a part of the script. It�s so nice
to have a break through finally :-)
> I don't thing 'rwb' is the correct way to fopen for read/write access.
> 'wb+' would be a better answer, I think.
I know, that�s how I�ve done it. During try&fail tests I�ve tried like
everything. My mistake to not check the code properly before mailing it here...
Have a nice weekend out there :o)
--
Sincerly
Kim Madsen
Systemdeveloper / ComX - http://www.comx.dk
--- End Message ---