Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-11 Thread Richard Lynch

Thanks for pointing out the syntax error. I added the space after the -u but
it did not make any difference. It still gives the same result, that is
Success, when it actually fails. What I am trying to figure out is how I
can tell if it failed (did not create the tables)? The $status variable does
not appear to hold the output of the system() function. Anyone know how to
get the output of system, passthru or exec into the $status variable to
check for success or failure?

Analysis  Solutions [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Tue, Jul 09, 2002 at 06:09:36PM -0700, Fargo Lee wrote:
 
  $status = system(mysql -umyuserid -pmypassword mydbname 

?php
  exec(mysql -u myuserid --password=mypassword myddbname ..., $result,
$errorcode);
  echo implode('', $result);
  if ($errorcode){
echo OS Error $errorcode  Use 'man errno' to find meaning, but it's
almost always path/permissions;
  }
?

Oh yeah.  You'll need the full path to mysql, almost for sure.

-- 
Like Music?  http://l-i-e.com/artists.htm
Off-Topic:  What is the moral equivalent of 'cat' in Windows?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-11 Thread Richard Lynch

But if system() thinks it is a success because the command executed, even
though MySQL returns an internal error on the command line, why is'nt the
last line of the MySQL error message stored in the variable as the system()
manual suggests it should be when system() thinks it is a success?

*MAYBE* system() only catches stdout, and not stderr...

Though I doubt it.

Is there a blank line at the end of the MySQL error output when you do it
wrong in the shell?

Use the exec() I just posted and get *ALL* your output, *AND* the actual OS
error (or 0) code returned.

-- 
Like Music?  http://l-i-e.com/artists.htm
Off-Topic:  What is the moral equivalent of 'cat' in Windows?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-10 Thread Fargo Lee

Thanks for pointing me in the right direction. Could not get the output
(success or failure) assigned to a variable in front of the system call but
got it to assign a 0 (success) or 1 (failure) to the return_var argument as
you suggested so I am happy.

?php

system(mysql -u myuserid -pmypassword mydbname  /path/to/mydumpfile.txt,
$status);

if($status == 1){
echo 'Failed';
} else {
echo 'Success';
}

?

What mixed me up and I still don't understand is the manual entry for
system() says ...

Returns the last line of the command output on success, and FALSE on
failure.

When it says it Returns, where does it return this information and how can
it be captured for comparison? The return_var appears to only return a 0 or
a 1. I thought I could capture it by assigning the system call to a variable
in front but that appears to capture nothing on success or failure.

Analysis  Solutions [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Tue, Jul 09, 2002 at 10:59:04PM -0700, Fargo Lee wrote:
 
  Thanks but it still returns Success on a failure. If anyone knows if
it is
  even possible to assign the output of system, passthru or exec to a
variable
  to check for success or failure and how to do it, please advise. The
$status
  variable seems to always be empty on success or failure when I try to
echo
  it.

 The way you set things up, $status is the last line of text returned by
 executing the command.  Add the return_var argument to your system()
 statement.  Take a look at the manual again.
 http://www.php.net/manual/en/function.system.php

 You can only make an accurate if() statement if you know what the values
 are you're expecting.

 Now, do some hacking.  Set up the test to fail.  Echo $status and $return
 to the screen and see what they look like.  Set up the test to succeed.
 What do $status and $return look like then?

 --Dan

 --
PHP classes that make web design easier
 SQL Solution  |   Layout Solution   |  Form Solution
 sqlsolution.info  | layoutsolution.info |  formsolution.info
  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-10 Thread Analysis Solutions

On Tue, Jul 09, 2002 at 11:41:47PM -0700, Fargo Lee wrote:

 got it to assign a 0 (success) or 1 (failure) to the return_var argument as
 you suggested so I am happy.

Good!


 What mixed me up and I still don't understand is the manual entry for
 system() says ...
 
 Returns the last line of the command output on success, and FALSE on
 failure.
 
 When it says it Returns, where does it return this information and how can
 it be captured for comparison?

The thing that's tripping you up is, I believe, executing MySQL programs
at a prompt doesn't produce any visible output.  But, if you executed a
command that returns some output to STDOUT, like ls, you'd see the last
line of output therefrom in the Return.

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] How do I import tables into MySQL from web page ...

2002-07-10 Thread John Holmes

Try using backticks, and you don't need spaces after -u and -p

$result = `MySQL -uuser -ppassword databasename  filename.sql`

Note that if it succeeds, nothing will be returned. Same as when you run
the command on the command line.

---John Holmes...

 -Original Message-
 From: Fargo Lee [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, July 10, 2002 1:27 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] How do I import tables into MySQL from web page ...
 
 Thanks for pointing out the syntax error. I added the space after the
-u
 but
 it did not make any difference. It still gives the same result, that
is
 Success, when it actually fails. What I am trying to figure out is
how I
 can tell if it failed (did not create the tables)? The $status
variable
 does
 not appear to hold the output of the system() function. Anyone know
how to
 get the output of system, passthru or exec into the $status variable
to
 check for success or failure?
 
 Analysis  Solutions [EMAIL PROTECTED] wrote in
message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  On Tue, Jul 09, 2002 at 06:09:36PM -0700, Fargo Lee wrote:
  
   $status = system(mysql -umyuserid -pmypassword mydbname 
 
  You need a space between -u and myuserid
 
  --Dan
 
  --
 PHP classes that make web design easier
  SQL Solution  |   Layout Solution   |  Form Solution
  sqlsolution.info  | layoutsolution.info |  formsolution.info
   T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
   4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409
 
 
 
 --
 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




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-10 Thread Fargo Lee

Yes, on success the command I am issuing does not produce any output on the
command line and thus the $status variable should be blank on success. But
when made to fail MySQL does return an error on the command line yet the
variable does not hold FALSE as the manual suggests it should or anything
else. This suggests, as do a few posts I just noticed in the manual,  that
one cannot assign the output of system() and perhaps passthru() and exec()
to a variable. I think this is only possible using backticks, which I can't
use as this needs to be run in safe mode. So I guess I just need to use the
return_var as you suggested. Thanks!

Analysis  Solutions [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Tue, Jul 09, 2002 at 11:41:47PM -0700, Fargo Lee wrote:

  got it to assign a 0 (success) or 1 (failure) to the return_var argument
as
  you suggested so I am happy.

 Good!


  What mixed me up and I still don't understand is the manual entry for
  system() says ...
 
  Returns the last line of the command output on success, and FALSE on
  failure.
 
  When it says it Returns, where does it return this information and how
can
  it be captured for comparison?

 The thing that's tripping you up is, I believe, executing MySQL programs
 at a prompt doesn't produce any visible output.  But, if you executed a
 command that returns some output to STDOUT, like ls, you'd see the last
 line of output therefrom in the Return.

 --Dan

 --
PHP classes that make web design easier
 SQL Solution  |   Layout Solution   |  Form Solution
 sqlsolution.info  | layoutsolution.info |  formsolution.info
  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-10 Thread Fargo Lee

Thanks that explains why I did not initially have a space after the -u as I
copied the code from another of my applications that used backticks without
reviewing it. It appears that using backticks is also the only way to assign
the output of a command to a variable as system(), passthru() and exec()
don't appear to be able to do this. Unfortunately this snippet of code needs
to be compatible with PHP installations running in safe mode so I can't use
backticks.

John Holmes [EMAIL PROTECTED] wrote in message
021501c22807$a91e42d0$b402a8c0@mango">news:021501c22807$a91e42d0$b402a8c0@mango...
 Try using backticks, and you don't need spaces after -u and -p

 $result = `MySQL -uuser -ppassword databasename  filename.sql`

 Note that if it succeeds, nothing will be returned. Same as when you run
 the command on the command line.

 ---John Holmes...

  -Original Message-
  From: Fargo Lee [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, July 10, 2002 1:27 AM
  To: [EMAIL PROTECTED]
  Subject: Re: [PHP] How do I import tables into MySQL from web page ...
 
  Thanks for pointing out the syntax error. I added the space after the
 -u
  but
  it did not make any difference. It still gives the same result, that
 is
  Success, when it actually fails. What I am trying to figure out is
 how I
  can tell if it failed (did not create the tables)? The $status
 variable
  does
  not appear to hold the output of the system() function. Anyone know
 how to
  get the output of system, passthru or exec into the $status variable
 to
  check for success or failure?
 
  Analysis  Solutions [EMAIL PROTECTED] wrote in
 message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   On Tue, Jul 09, 2002 at 06:09:36PM -0700, Fargo Lee wrote:
   
$status = system(mysql -umyuserid -pmypassword mydbname 
  
   You need a space between -u and myuserid
  
   --Dan
  
   --
  PHP classes that make web design easier
   SQL Solution  |   Layout Solution   |  Form Solution
   sqlsolution.info  | layoutsolution.info |  formsolution.info
T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409
 
 
 
  --
  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




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-10 Thread Analysis Solutions

On Wed, Jul 10, 2002 at 12:14:58PM -0700, Fargo Lee wrote:

 when made to fail MySQL does return an error on the command line yet the
 variable does not hold FALSE as the manual suggests it should or anything
 else.

The behaviour of returning FALSE upon failure has to do with the system()
call not being able to be made due to things like the command itself not
being able to execute, such as when the name of the program is wrong.  
But, since the program in this case actually executed, there's no failure.

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-10 Thread Analysis Solutions

On Wed, Jul 10, 2002 at 12:14:58PM -0700, Fargo Lee wrote:

 This suggests, as do a few posts I just noticed in the manual,  that
 one cannot assign the output of system() and perhaps passthru() and exec()
 to a variable.

I forgot to mention, that's not accurate.  I just ran a test to make sure.  
Got the results just fine.

Just for clarity, here's my test (PHP 4.2.1, NT 4.0):

#   real directory.
#   result:  output shows file list, false no, return 0
#   $output = system('dir c:\books', $return_var);

#   fake directory.
#   result:  output shows nothing, false yes, return 1
   $output = system('dir y:\fake', $return_var);

   echo output: $output;
   echo 'hr /';
   echo 'output false? ' . ( ($output == FALSE) ? 'yes' : 'no' );
   echo 'hr /';
   echo return: $return_var;


--Dan


 I think this is only possible using backticks, which I can't
 use as this needs to be run in safe mode. So I guess I just need to use the
 return_var as you suggested. Thanks!
 
 Analysis  Solutions [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  On Tue, Jul 09, 2002 at 11:41:47PM -0700, Fargo Lee wrote:
 
   got it to assign a 0 (success) or 1 (failure) to the return_var argument
 as
   you suggested so I am happy.
 
  Good!
 
 
   What mixed me up and I still don't understand is the manual entry for
   system() says ...
  
   Returns the last line of the command output on success, and FALSE on
   failure.
  
   When it says it Returns, where does it return this information and how
 can
   it be captured for comparison?
 
  The thing that's tripping you up is, I believe, executing MySQL programs
  at a prompt doesn't produce any visible output.  But, if you executed a
  command that returns some output to STDOUT, like ls, you'd see the last
  line of output therefrom in the Return.
 
  --Dan
 
  --
 PHP classes that make web design easier
  SQL Solution  |   Layout Solution   |  Form Solution
  sqlsolution.info  | layoutsolution.info |  formsolution.info
   T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
   4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-10 Thread Fargo Lee

I ran a few tests as well and the few system commands I tried only saved the
*last* line of the output in a variable on success as the manual suggests it
should - better than nothing - but not the entire output as you seem to
suggest you were able to do and what I have been trying to do.

Analysis  Solutions [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Wed, Jul 10, 2002 at 12:14:58PM -0700, Fargo Lee wrote:
 
  This suggests, as do a few posts I just noticed in the manual,  that
  one cannot assign the output of system() and perhaps passthru() and
exec()
  to a variable.

 I forgot to mention, that's not accurate.  I just ran a test to make sure.
 Got the results just fine.

 Just for clarity, here's my test (PHP 4.2.1, NT 4.0):

 #   real directory.
 #   result:  output shows file list, false no, return 0
 #   $output = system('dir c:\books', $return_var);

 #   fake directory.
 #   result:  output shows nothing, false yes, return 1
$output = system('dir y:\fake', $return_var);

echo output: $output;
echo 'hr /';
echo 'output false? ' . ( ($output == FALSE) ? 'yes' : 'no' );
echo 'hr /';
echo return: $return_var;


 --Dan


  I think this is only possible using backticks, which I can't
  use as this needs to be run in safe mode. So I guess I just need to use
the
  return_var as you suggested. Thanks!
 
  Analysis  Solutions [EMAIL PROTECTED] wrote in
message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   On Tue, Jul 09, 2002 at 11:41:47PM -0700, Fargo Lee wrote:
  
got it to assign a 0 (success) or 1 (failure) to the return_var
argument
  as
you suggested so I am happy.
  
   Good!
  
  
What mixed me up and I still don't understand is the manual entry
for
system() says ...
   
Returns the last line of the command output on success, and FALSE
on
failure.
   
When it says it Returns, where does it return this information and
how
  can
it be captured for comparison?
  
   The thing that's tripping you up is, I believe, executing MySQL
programs
   at a prompt doesn't produce any visible output.  But, if you executed
a
   command that returns some output to STDOUT, like ls, you'd see the
last
   line of output therefrom in the Return.
  
   --Dan
  
   --
  PHP classes that make web design easier
   SQL Solution  |   Layout Solution   |  Form Solution
   sqlsolution.info  | layoutsolution.info |  formsolution.info
T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409
 
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php

 --
PHP classes that make web design easier
 SQL Solution  |   Layout Solution   |  Form Solution
 sqlsolution.info  | layoutsolution.info |  formsolution.info
  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-10 Thread Fargo Lee

But if system() thinks it is a success because the command executed, even
though MySQL returns an internal error on the command line, why is'nt the
last line of the MySQL error message stored in the variable as the system()
manual suggests it should be when system() thinks it is a success?

Analysis  Solutions [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Wed, Jul 10, 2002 at 12:14:58PM -0700, Fargo Lee wrote:
 
  when made to fail MySQL does return an error on the command line yet the
  variable does not hold FALSE as the manual suggests it should or
anything
  else.

 The behaviour of returning FALSE upon failure has to do with the system()
 call not being able to be made due to things like the command itself not
 being able to execute, such as when the name of the program is wrong.
 But, since the program in this case actually executed, there's no failure.

 --Dan

 --
PHP classes that make web design easier
 SQL Solution  |   Layout Solution   |  Form Solution
 sqlsolution.info  | layoutsolution.info |  formsolution.info
  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] How do I import tables into MySQL from web page ...

2002-07-10 Thread Peter

using dan's test below if u add a '/s' like so

 $output = system('dir /s c:\books', $return_var);

you will get all contents os subdir's as well  
how ever i suggest working on a format as this tree's out along the page
so maybe if u add a '/w' after the '/s'as well that will sort of solve that problem .. 

though does create one massive block of filenames in ur browser...

Cheers


 -Original Message-
 From: Fargo Lee [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, 11 July 2002 11:54 AM
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] How do I import tables into MySQL from web page ...
 
 
 I ran a few tests as well and the few system commands I tried 
 only saved the
 *last* line of the output in a variable on success as the manual 
 suggests it
 should - better than nothing - but not the entire output as you seem to
 suggest you were able to do and what I have been trying to do.
 
 Analysis  Solutions [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  On Wed, Jul 10, 2002 at 12:14:58PM -0700, Fargo Lee wrote:
  
   This suggests, as do a few posts I just noticed in the manual,  that
   one cannot assign the output of system() and perhaps passthru() and
 exec()
   to a variable.
 
  I forgot to mention, that's not accurate.  I just ran a test to 
 make sure.
  Got the results just fine.
 
  Just for clarity, here's my test (PHP 4.2.1, NT 4.0):
 
  #   real directory.
  #   result:  output shows file list, false no, return 0
  #   $output = system('dir c:\books', $return_var);
 
  #   fake directory.
  #   result:  output shows nothing, false yes, return 1
 $output = system('dir y:\fake', $return_var);
 
 echo output: $output;
 echo 'hr /';
 echo 'output false? ' . ( ($output == FALSE) ? 'yes' : 'no' );
 echo 'hr /';
 echo return: $return_var;
 
 
  --Dan
 
 
   I think this is only possible using backticks, which I can't
   use as this needs to be run in safe mode. So I guess I just 
 need to use
 the
   return_var as you suggested. Thanks!
  
   Analysis  Solutions [EMAIL PROTECTED] wrote in
 message
   [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
On Tue, Jul 09, 2002 at 11:41:47PM -0700, Fargo Lee wrote:
   
 got it to assign a 0 (success) or 1 (failure) to the return_var
 argument
   as
 you suggested so I am happy.
   
Good!
   
   
 What mixed me up and I still don't understand is the manual entry
 for
 system() says ...

 Returns the last line of the command output on success, and FALSE
 on
 failure.

 When it says it Returns, where does it return this 
 information and
 how
   can
 it be captured for comparison?
   
The thing that's tripping you up is, I believe, executing MySQL
 programs
at a prompt doesn't produce any visible output.  But, if 
 you executed
 a
command that returns some output to STDOUT, like ls, you'd see the
 last
line of output therefrom in the Return.
   
--Dan
   
--
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
 
  --
 PHP classes that make web design easier
  SQL Solution  |   Layout Solution   |  Form Solution
  sqlsolution.info  | layoutsolution.info |  formsolution.info
   T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
   4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-10 Thread Analysis Solutions

On Wed, Jul 10, 2002 at 07:04:58PM -0700, Fargo Lee wrote:
 But if system() thinks it is a success because the command executed, even
 though MySQL returns an internal error on the command line, why is'nt the
 last line of the MySQL error message stored in the variable as the system()
 manual suggests it should be when system() thinks it is a success?

Run the command manually at a shell prompt.  What happens?  Here's what
happens for me on WinNT.  In an error condition, say my password is
invalid, it retuns the error message then a blank line and then I'm back
at the prompt.  So, if system() is true to the manual, that blank line is 
the last line, so it's the one that gets put into the variable.

Put the returned string through ord() and see what you get.  I'll bet it's
10, the ordinal number for a line break.  Hmm...  Maybe not...  Out of
curiosity, I tested it on my system and it came back as 0 (a null string,
but not a null variable).

--Dan

PS:  Please be kind enough to make the effort to appropriately trim the 
messages you're replying to.  Top posting is bad enough.

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-10 Thread Fargo Lee

 Run the command manually at a shell prompt.  What happens?  Here's what
 happens for me on WinNT.  In an error condition, say my password is
 invalid, it retuns the error message then a blank line and then I'm back
 at the prompt.  So, if system() is true to the manual, that blank line is
 the last line, so it's the one that gets put into the variable.


My bad, it is a blank line after the error message on my system too.
I missed the blank line last time, I need some glasses. Thanks.





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] How do I import tables into MySQL from web page ...

2002-07-09 Thread Fargo Lee

Hi, I am trying to import some tables from a dump file into a MySQL database
from a php web page. What is the best way to do this without using backticks
(fpassthru, system, exec or something else) and test for success or failure?
I tried the following and while it works, my test for success or failure
always produces a Success even when I change something to make it fail. I
thought system() outputs the last line of the command on success and FALSE
on failure. Any examples appreciated.

?php

$status = system(mysql -umyuserid -pmypassword mydbname 
/path/to/mydumpfile.txt);

if($status == 'FALSE'){
echo 'Failed';
} else {
echo 'Success';
}

?




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-09 Thread Analysis Solutions

On Tue, Jul 09, 2002 at 06:09:36PM -0700, Fargo Lee wrote:
 
 $status = system(mysql -umyuserid -pmypassword mydbname 

You need a space between -u and myuserid

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-09 Thread Adam Alkins

And also the -p

--
Cheers,
Adam Alkins
http://www.rasadam.com
--

- Original Message - 
From: Analysis  Solutions [EMAIL PROTECTED]
To: PHP List [EMAIL PROTECTED]
Sent: Tuesday, July 09, 2002 11:02 PM
Subject: Re: [PHP] How do I import tables into MySQL from web page ...


 On Tue, Jul 09, 2002 at 06:09:36PM -0700, Fargo Lee wrote:
  
  $status = system(mysql -umyuserid -pmypassword mydbname 
 
 You need a space between -u and myuserid
 
 --Dan
 
 -- 
PHP classes that make web design easier
 SQL Solution  |   Layout Solution   |  Form Solution
 sqlsolution.info  | layoutsolution.info |  formsolution.info
  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409
 
 -- 
 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




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-09 Thread Fargo Lee

Thanks for pointing out the syntax error. I added the space after the -u but
it did not make any difference. It still gives the same result, that is
Success, when it actually fails. What I am trying to figure out is how I
can tell if it failed (did not create the tables)? The $status variable does
not appear to hold the output of the system() function. Anyone know how to
get the output of system, passthru or exec into the $status variable to
check for success or failure?

Analysis  Solutions [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Tue, Jul 09, 2002 at 06:09:36PM -0700, Fargo Lee wrote:
 
  $status = system(mysql -umyuserid -pmypassword mydbname 

 You need a space between -u and myuserid

 --Dan

 --
PHP classes that make web design easier
 SQL Solution  |   Layout Solution   |  Form Solution
 sqlsolution.info  | layoutsolution.info |  formsolution.info
  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-09 Thread Jason Wong

On Wednesday 10 July 2002 13:27, Fargo Lee wrote:
 Thanks for pointing out the syntax error. I added the space after the -u
 but it did not make any difference. It still gives the same result, that is
 Success, when it actually fails. What I am trying to figure out is how I
 can tell if it failed (did not create the tables)? The $status variable
 does not appear to hold the output of the system() function. Anyone know
 how to get the output of system, passthru or exec into the $status variable
 to check for success or failure?

Your test for failure should be:

  if ($status === FALSE)

-- 
Jason Wong - Gremlins Associates - www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
Extreme fear can neither fight nor fly.
-- William Shakespeare, The Rape of Lucrece
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-09 Thread Fargo Lee

Thanks but it still returns Success on a failure. If anyone knows if it is
even possible to assign the output of system, passthru or exec to a variable
to check for success or failure and how to do it, please advise. The $status
variable seems to always be empty on success or failure when I try to echo
it.

Jason Wong [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 On Wednesday 10 July 2002 13:27, Fargo Lee wrote:
  Thanks for pointing out the syntax error. I added the space after the -u
  but it did not make any difference. It still gives the same result, that
is
  Success, when it actually fails. What I am trying to figure out is how
I
  can tell if it failed (did not create the tables)? The $status variable
  does not appear to hold the output of the system() function. Anyone know
  how to get the output of system, passthru or exec into the $status
variable
  to check for success or failure?

 Your test for failure should be:

   if ($status === FALSE)

 --
 Jason Wong - Gremlins Associates - www.gremlins.com.hk
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *

 /*
 Extreme fear can neither fight nor fly.
 -- William Shakespeare, The Rape of Lucrece
 */




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-09 Thread Analysis Solutions

On Wed, Jul 10, 2002 at 01:08:38AM -0400, Adam Alkins wrote:

 From: Analysis  Solutions [EMAIL PROTECTED]
 
  On Tue, Jul 09, 2002 at 06:09:36PM -0700, Fargo Lee wrote:
   
   $status = system(mysql -umyuserid -pmypassword mydbname 
  
  You need a space between -u and myuserid

 And also the -p

Nope.  In order for the password to be considered a password, there should 
be no space between the -p and the password.  Otherwise it gets 
interpreted as the name of the database you want to access.

--Dan

A:  No.
Q:  Is top posting okay?

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How do I import tables into MySQL from web page ...

2002-07-09 Thread Analysis Solutions

On Tue, Jul 09, 2002 at 10:59:04PM -0700, Fargo Lee wrote:

 Thanks but it still returns Success on a failure. If anyone knows if it is
 even possible to assign the output of system, passthru or exec to a variable
 to check for success or failure and how to do it, please advise. The $status
 variable seems to always be empty on success or failure when I try to echo
 it.

The way you set things up, $status is the last line of text returned by
executing the command.  Add the return_var argument to your system() 
statement.  Take a look at the manual again.
http://www.php.net/manual/en/function.system.php

You can only make an accurate if() statement if you know what the values 
are you're expecting.

Now, do some hacking.  Set up the test to fail.  Echo $status and $return
to the screen and see what they look like.  Set up the test to succeed.  
What do $status and $return look like then?

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php