RE: [PHP] Re: catch the error

2009-02-27 Thread Boyd, Todd M.
 -Original Message-
 From: Chris [mailto:dmag...@gmail.com]
 Sent: Thursday, February 26, 2009 6:38 PM
 To: Boyd, Todd M.
 Cc: PHP General list
 Subject: Re: [PHP] Re: catch the error
 
 Boyd, Todd M. wrote:
  -Original Message-
  From: Chris [mailto:dmag...@gmail.com]
  Sent: Thursday, February 26, 2009 4:16 PM
  To: Boyd, Todd M.
  Cc: PJ; PHP General list
  Subject: Re: [PHP] Re: catch the error
 
 
  In examples sent to you, people foolishly replaced your $db var
 with
  $db_connect ONLY FOR PART OF THE SCRIPT. You've defined your
  database
  connection as $db_connect in some versions of the source, but then
  you
  reference $db (without _connect) in your mysql_select call in that
  same
  source.
 
  $db = mysql_connect([option list here]); # -- this code
  instantiates
  a
  connection
  mysql_select_db([some name], $db); # notice how $db is here?
  $result = mysql_query([some query], $db); # it's here, too!
 
  $db becomes your resource link when you use mysql_connect. That
  resource
  link must then be passed to your mysql functions. Otherwise, they
  have
  no idea which database connection you are attempting to use.
  RTFM?
 
  If no connection is specified, the last one is used.
 
  It is an optional argument (only *really* needed when you have
  multiple
  connections in the same script).
 
  RTF E-mail I sent?
 
  He had used $db_connect instead of $db. $db_connect hadn't been set
 to
  anything. He was specifying a connection, but it was null. Unless it
  falls back to the last connection used in the case of an empty
 variable,
  then this was most likely (read: proven to be) the problem.
 
 The last two emails I saw (no I haven't read the whole thread) were:
 
   $db = mysql_connect($db_host, $db_user, $db_pass);
 mysql_select_db($db_name,$db);
 
 snip
 
 $result1 = mysql_query($sql1,$db);
 
 and
 
   $db = mysql_connect($db_host, $db_user, $db_pass);
   mysql_select_db($db_name,$db);
 
 which have the right variables.
 
 Plus I was picking on the you must do this - using the link
 identifier
 is an optional thing as I already said.

Yes, it was solved before I replied. I just wanted to point out why it
worked in the situations that it did and why it did not work in the
situations that it did not. As the OP had been staring at it for too
long, all of the code started to blur together. :)

Anyway, it's a moot point now. I think the information you provided
about the link identifier was solid advice... I was just trying to point
out that using two different variables when specifying the link
identifier in mysql functions was what gave him so much guff.


// Todd

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



[PHP] Re: catch the error

2009-02-26 Thread Darryle Steplight
Hi PJ,
Could it be that you have //include (lib/db1.php);  commented
out? Try uncommenting that line and see what happens. The error
message will always print because the query is never executing
properly if you have the db connections file commented out.

On Thu, Feb 26, 2009 at 12:28 PM, PJ af.gour...@videotron.ca wrote:
 What is wrond with this file? same identical insert works from console
 but not from this file :-(

 html
 head
    titleUntitled/title
 /head

 body
 ?
 //include (lib/db1.php);    // Connect to database
 mysql_connect('biggie', 'user', 'password', 'test');
 $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
       mysql_error() . /P);
  exit();
 }
 ?

 /body
 /html

 Seems to be good to print out the error message, but that's all. db not
 written.

 --

 Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:    http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com



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



[PHP] Re: catch the error

2009-02-26 Thread PJ
It is commented out because I am using mysql_connect
I don't think it would be good to use both, since the db1 references
another db. But even when I use the db1.php and change the database and
table, I get the same error message.

But what I did miss is my typo in What is wrond with this file? :-)
 Hi PJ,
 Could it be that you have //include (lib/db1.php);  commented
 out? Try uncommenting that line and see what happens. The error
 message will always print because the query is never executing
 properly if you have the db connections file commented out.

 On Thu, Feb 26, 2009 at 12:28 PM, PJ af.gour...@videotron.ca wrote:
 What is wrond with this file? same identical insert works from console
 but not from this file :-(

 html
 head
titleUntitled/title
 /head

 body
 ?
 //include (lib/db1.php);// Connect to database
 mysql_connect('biggie', 'user', 'password', 'test');
 $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
   mysql_error() . /P);
  exit();
 }
 ?

 /body
 /html

 Seems to be good to print out the error message, but that's all. db not
 written.

 --

 Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:  
  http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com





-- 

Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com

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



[PHP] Re: catch the error

2009-02-26 Thread Jim Lyons
what's the error message?

On Thu, Feb 26, 2009 at 11:46 AM, PJ af.gour...@videotron.ca wrote:

 It is commented out because I am using mysql_connect
 I don't think it would be good to use both, since the db1 references
 another db. But even when I use the db1.php and change the database and
 table, I get the same error message.




-- 
Jim Lyons
Web developer / Database administrator
http://www.weblyons.com


[PHP] Re: catch the error

2009-02-26 Thread Darryle Steplight
ok, well if that's the case then do this

$db = mysql_connect('biggie', 'user', 'password', 'test');


That should fix the problem.

On Thu, Feb 26, 2009 at 12:46 PM, PJ af.gour...@videotron.ca wrote:
 It is commented out because I am using mysql_connect
 I don't think it would be good to use both, since the db1 references
 another db. But even when I use the db1.php and change the database and
 table, I get the same error message.

 But what I did miss is my typo in What is wrond with this file? :-)
 Hi PJ,
 Could it be that you have //include (lib/db1.php);  commented
 out? Try uncommenting that line and see what happens. The error
 message will always print because the query is never executing
 properly if you have the db connections file commented out.

 On Thu, Feb 26, 2009 at 12:28 PM, PJ af.gour...@videotron.ca wrote:
 What is wrond with this file? same identical insert works from console
 but not from this file :-(

 html
 head
    titleUntitled/title
 /head

 body
 ?
 //include (lib/db1.php);    // Connect to database
 mysql_connect('biggie', 'user', 'password', 'test');
 $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
       mysql_error() . /P);
  exit();
 }
 ?

 /body
 /html

 Seems to be good to print out the error message, but that's all. db not
 written.

 --

 Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:
  http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com





 --

 Phil Jourdan --- p...@ptahhotep.com
 http://www.ptahhotep.com
 http://www.chiccantine.com


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



[PHP] Re: catch the error

2009-02-26 Thread Ricardo Dias Marques
Hi PJ,

On Thu, Feb 26, 2009 at 17:28, PJ af.gour...@videotron.ca wrote:

 What is wrond with this file? same identical insert works from console
 but not from this file :-(

 [snip]

 ?
 //include (lib/db1.php);    // Connect to database
 mysql_connect('biggie', 'user', 'password', 'test');
 $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
       mysql_error() . /P);
  exit();
 }
 ?

I haven't coded in PHP for a long time, but I think that your problem
is in this line:

$result1 = mysql_query($sql1,$db);

Up to that point, $db (that should point to a database link
identifier) is not defined. You probably want to assign the
mysql_connect result to that $db variable.


So, I think that you will solve your problem by changing your
mysql_connect line FROM the current form:

mysql_connect('biggie', 'user', 'password', 'test');

... TO this one:

$db = mysql_connect('biggie', 'user', 'password', 'test');


Am I right?

Cheers,
Ricardo Dias Marques
lists AT ricmarques DOT net

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



[PHP] Re: catch the error

2009-02-26 Thread PJ
Jim Lyons wrote:
 what's the error message?
it's in the script/// Error performing query: of Error performing 1st
query: - whatever I input.
But I had an error in the include location... that's fixed and it works,
but not the rest as corrected:
?
//include (../lib/db1.php);// Connect to database

$db_host = 'biggie';
$db_user = 'root';
$db_pass = 'gu...@#$';
$db_name = 'biblane';

$db_connect = mysql_connect($db_host, $db_user, $db_pass);
$db_select = mysql_select_db($db_name, $db_connect);

$sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
$result1 = mysql_query($sql1,$db);
if (!$result1) {
  echo(PError performing 1st query:  .
   mysql_error() . /P);
  exit();
}
?


 On Thu, Feb 26, 2009 at 11:46 AM, PJ af.gour...@videotron.ca
 mailto:af.gour...@videotron.ca wrote:

 It is commented out because I am using mysql_connect
 I don't think it would be good to use both, since the db1 references
 another db. But even when I use the db1.php and change the
 database and
 table, I get the same error message.




 -- 
 Jim Lyons
 Web developer / Database administrator
 http://www.weblyons.com


-- 

Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com

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



[PHP] Re: catch the error

2009-02-26 Thread PJ
Ricardo Dias Marques wrote:
 Hi PJ,

 On Thu, Feb 26, 2009 at 17:28, PJ af.gour...@videotron.ca wrote:

   
 What is wrond with this file? same identical insert works from console
 but not from this file :-(

 [snip]

 ?
 //include (lib/db1.php);// Connect to database
 mysql_connect('biggie', 'user', 'password', 'test');
 $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
   mysql_error() . /P);
  exit();
 }
 ?
 

 I haven't coded in PHP for a long time, but I think that your problem
 is in this line:

 $result1 = mysql_query($sql1,$db);

 Up to that point, $db (that should point to a database link
 identifier) is not defined. You probably want to assign the
 mysql_connect result to that $db variable.


 So, I think that you will solve your problem by changing your
 mysql_connect line FROM the current form:

 mysql_connect('biggie', 'user', 'password', 'test');

 .. TO this one:

 $db = mysql_connect('biggie', 'user', 'password', 'test');


 Am I right?
Partly. I had an error in the location of the include. Ashley corrected 
the rest but it only works with the include. Not as whown below
?
//include (../lib/db1.php);// Connect to database

$db_host = 'biggie';
$db_user = 'root';
$db_pass = 'gu...@#$';
$db_name = 'biblane';

$db_connect = mysql_connect($db_host, $db_user, $db_pass);
$db_select = mysql_select_db($db_name, $db_connect);

$sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
$result1 = mysql_query($sql1,$db);
if (!$result1) {
  echo(PError performing 1st query:  .
   mysql_error() . /P);
  exit();
}
?

-- 

Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


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



[PHP] Re: catch the error

2009-02-26 Thread PJ
Darryle Steplight wrote:
 ok, well if that's the case then do this

 $db = mysql_connect('biggie', 'user', 'password', 'test');
   
Ashley pointed out that the 4th parameter is not right - belongs in
mysql_select_db. Here it is corrected: (but it still does not work)

?
//include (../lib/db1.php);// Connect to database

$db_host = 'biggie';
$db_user = 'my_user';
$db_pass = 'my_pass';
$db_name = 'biblane';

$db_connect = mysql_connect($db_host, $db_user, $db_pass);
$db_select = mysql_select_db($db_name, $db_connect);

$sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
$result1 = mysql_query($sql1,$db);
if (!$result1) {
  echo(PError performing 1st query:  .
   mysql_error() . /P);
  exit();
}
?

 That should fix the problem.

 On Thu, Feb 26, 2009 at 12:46 PM, PJ af.gour...@videotron.ca wrote:
   
 It is commented out because I am using mysql_connect
 I don't think it would be good to use both, since the db1 references
 another db. But even when I use the db1.php and change the database and
 table, I get the same error message.

 But what I did miss is my typo in What is wrond with this file? :-)
 
 Hi PJ,
 Could it be that you have //include (lib/db1.php);  commented
 out? Try uncommenting that line and see what happens. The error
 message will always print because the query is never executing
 properly if you have the db connections file commented out.

 On Thu, Feb 26, 2009 at 12:28 PM, PJ af.gour...@videotron.ca wrote:
   
 What is wrond with this file? same identical insert works from console
 but not from this file :-(

 html
 head
titleUntitled/title
 /head

 body
 ?
 //include (lib/db1.php);// Connect to database
 mysql_connect('biggie', 'user', 'password', 'test');
 $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
   mysql_error() . /P);
  exit();
 }
 ?

 /body
 /html

 Seems to be good to print out the error message, but that's all. db not
 written.

 --

 Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:
  http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com


 
 --

 Phil Jourdan --- p...@ptahhotep.com
 http://www.ptahhotep.com
 http://www.chiccantine.com

 

   


-- 

Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


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



Re: [PHP] Re: catch the error

2009-02-26 Thread Andrew Ballard
What does this output?

?
//include (../lib/db1.php);// Connect to database

$db_host = 'biggie';
$db_user = 'root';
$db_pass = 'gu...@#$';
$db_name = 'biblane';

$db_connect = mysql_connect($db_host, $db_user, $db_pass);

if (!is_resource($db_connect)) {
echo 'p$db_connect is not a valid resource: ' . mysql_error() . '/p';
exit();
}

if (!mysql_select_db($db_name, $db_connect)) {
echo pUnable to select $db_name:  . mysql_error() . '/p';
exit();
}

$sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');

$result1 = mysql_query($sql1,$db);

if (!is_resource($result1)) {
echo pError performing 1st query:  . mysql_error() . /p;
exit();
} else {
echo 'p' . mysql_affected_rows() . 'row(s) affected by last
statement/p';
exit();
}
?

Andrew

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



[PHP] Re: catch the error

2009-02-26 Thread Darryle Steplight
Hi PJ,
   $db_host = 'biggie';
$db_user = 'root';
$db_pass = 'gu...@#$';
$db_name = 'biblane';



Everyone here is trying to help you and that's cool, but EVERYONE on
this list may not be so nice. The above credentials is definitely the
type of information you want to keep private, unless you don't mind
people potentially accessing your database tables and doing whatever
they like with them.

I suggest doing something like
$db_host = 'localhost;
$db_user = 'foo';
$db_pass= ''bar;
$db_name =''xx;

if you are going to post it on the list.

On Thu, Feb 26, 2009 at 1:22 PM, PJ af.gour...@videotron.ca wrote:
 Ricardo Dias Marques wrote:
 Hi PJ,

 On Thu, Feb 26, 2009 at 17:28, PJ af.gour...@videotron.ca wrote:


 What is wrond with this file? same identical insert works from console
 but not from this file :-(

 [snip]

 ?
 //include (lib/db1.php);    // Connect to database
 mysql_connect('biggie', 'user', 'password', 'test');
 $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
       mysql_error() . /P);
  exit();
 }
 ?


 I haven't coded in PHP for a long time, but I think that your problem
 is in this line:

 $result1 = mysql_query($sql1,$db);

 Up to that point, $db (that should point to a database link
 identifier) is not defined. You probably want to assign the
 mysql_connect result to that $db variable.


 So, I think that you will solve your problem by changing your
 mysql_connect line FROM the current form:

 mysql_connect('biggie', 'user', 'password', 'test');

 .. TO this one:

 $db = mysql_connect('biggie', 'user', 'password', 'test');


 Am I right?
 Partly. I had an error in the location of the include. Ashley corrected
 the rest but it only works with the include. Not as whown below
 ?
 //include (../lib/db1.php);    // Connect to database

 $db_host = 'biggie';
 $db_user = 'root';
 $db_pass = 'gu...@#$';
 $db_name = 'biblane';

 $db_connect = mysql_connect($db_host, $db_user, $db_pass);
 $db_select = mysql_select_db($db_name, $db_connect);

 $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
       mysql_error() . /P);
  exit();
 }
 ?

 --

 Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:    http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com



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



Re: [PHP] Re: catch the error

2009-02-26 Thread Ashley Sheridan
On Thu, 2009-02-26 at 13:34 -0500, Darryle Steplight wrote:
 Hi PJ,
$db_host = 'biggie';
 $db_user = 'root';
 $db_pass = 'gu...@#$';
 $db_name = 'biblane';
 
 
 
 Everyone here is trying to help you and that's cool, but EVERYONE on
 this list may not be so nice. The above credentials is definitely the
 type of information you want to keep private, unless you don't mind
 people potentially accessing your database tables and doing whatever
 they like with them.
 
 I suggest doing something like
 $db_host = 'localhost;
 $db_user = 'foo';
 $db_pass= ''bar;
 $db_name =''xx;
 
 if you are going to post it on the list.
 
 On Thu, Feb 26, 2009 at 1:22 PM, PJ af.gour...@videotron.ca wrote:
  Ricardo Dias Marques wrote:
  Hi PJ,
 
  On Thu, Feb 26, 2009 at 17:28, PJ af.gour...@videotron.ca wrote:
 
 
  What is wrond with this file? same identical insert works from console
  but not from this file :-(
 
  [snip]
 
  ?
  //include (lib/db1.php);// Connect to database
  mysql_connect('biggie', 'user', 'password', 'test');
  $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
  $result1 = mysql_query($sql1,$db);
  if (!$result1) {
   echo(PError performing 1st query:  .
mysql_error() . /P);
   exit();
  }
  ?
 
 
  I haven't coded in PHP for a long time, but I think that your problem
  is in this line:
 
  $result1 = mysql_query($sql1,$db);
 
  Up to that point, $db (that should point to a database link
  identifier) is not defined. You probably want to assign the
  mysql_connect result to that $db variable.
 
 
  So, I think that you will solve your problem by changing your
  mysql_connect line FROM the current form:
 
  mysql_connect('biggie', 'user', 'password', 'test');
 
  .. TO this one:
 
  $db = mysql_connect('biggie', 'user', 'password', 'test');
 
 
  Am I right?
  Partly. I had an error in the location of the include. Ashley corrected
  the rest but it only works with the include. Not as whown below
  ?
  //include (../lib/db1.php);// Connect to database
 
  $db_host = 'biggie';
  $db_user = 'root';
  $db_pass = 'gu...@#$';
  $db_name = 'biblane';
 
  $db_connect = mysql_connect($db_host, $db_user, $db_pass);
  $db_select = mysql_select_db($db_name, $db_connect);
 
  $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
  $result1 = mysql_query($sql1,$db);
  if (!$result1) {
   echo(PError performing 1st query:  .
mysql_error() . /P);
   exit();
  }
  ?
 
  --
 
  Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com
 
 
  --
  MySQL General Mailing List
  For list archives: http://lists.mysql.com/mysql
  To unsubscribe:http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com
 
 
 
I agree. I wouldn't trust me at all! ;)


Ash
www.ashleysheridan.co.uk


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



[PHP] RE: catch the error

2009-02-26 Thread Jerry Schwartz


-Original Message-
From: PJ [mailto:af.gour...@videotron.ca]
Sent: Thursday, February 26, 2009 12:28 PM
To: php-general@lists.php.net; MySql
Subject: catch the error

What is wrond with this file? same identical insert works from console
but not from this file :-(

html
head
titleUntitled/title
/head

body
?
//include (lib/db1.php);// Connect to database
mysql_connect('biggie', 'user', 'password', 'test');
$sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
$result1 = mysql_query($sql1,$db);
if (!$result1) {
  echo(PError performing 1st query:  .
   mysql_error() . /P);
  exit();
}
?

/body
/html

Seems to be good to print out the error message, but that's all. db not
written.

[JS] You need

  $db = mysql_connect('biggie', 'user', 'password', 'test');

--

Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/mysql?unsub=jschwa...@the-
infoshop.com





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



Re: [PHP] Re: catch the error

2009-02-26 Thread Darryle Steplight
Additionally regarding the error handling , add this to the op of your script.

ini_set(display_errors,true);
error_reporting(E_STRICT|E_ALL);

and post the output of your error message.

On Thu, Feb 26, 2009 at 1:40 PM, Ashley Sheridan
a...@ashleysheridan.co.uk wrote:
 On Thu, 2009-02-26 at 13:34 -0500, Darryle Steplight wrote:
 Hi PJ,
    $db_host = 'biggie';
 $db_user = 'root';
 $db_pass = 'gu...@#$';
 $db_name = 'biblane';



 Everyone here is trying to help you and that's cool, but EVERYONE on
 this list may not be so nice. The above credentials is definitely the
 type of information you want to keep private, unless you don't mind
 people potentially accessing your database tables and doing whatever
 they like with them.

 I suggest doing something like
 $db_host = 'localhost;
 $db_user = 'foo';
 $db_pass= ''bar;
 $db_name =''xx;

 if you are going to post it on the list.

 On Thu, Feb 26, 2009 at 1:22 PM, PJ af.gour...@videotron.ca wrote:
  Ricardo Dias Marques wrote:
  Hi PJ,
 
  On Thu, Feb 26, 2009 at 17:28, PJ af.gour...@videotron.ca wrote:
 
 
  What is wrond with this file? same identical insert works from console
  but not from this file :-(
 
  [snip]
 
  ?
  //include (lib/db1.php);    // Connect to database
  mysql_connect('biggie', 'user', 'password', 'test');
  $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
  $result1 = mysql_query($sql1,$db);
  if (!$result1) {
   echo(PError performing 1st query:  .
        mysql_error() . /P);
   exit();
  }
  ?
 
 
  I haven't coded in PHP for a long time, but I think that your problem
  is in this line:
 
  $result1 = mysql_query($sql1,$db);
 
  Up to that point, $db (that should point to a database link
  identifier) is not defined. You probably want to assign the
  mysql_connect result to that $db variable.
 
 
  So, I think that you will solve your problem by changing your
  mysql_connect line FROM the current form:
 
  mysql_connect('biggie', 'user', 'password', 'test');
 
  .. TO this one:
 
  $db = mysql_connect('biggie', 'user', 'password', 'test');
 
 
  Am I right?
  Partly. I had an error in the location of the include. Ashley corrected
  the rest but it only works with the include. Not as whown below
  ?
  //include (../lib/db1.php);    // Connect to database
 
  $db_host = 'biggie';
  $db_user = 'root';
  $db_pass = 'gu...@#$';
  $db_name = 'biblane';
 
  $db_connect = mysql_connect($db_host, $db_user, $db_pass);
  $db_select = mysql_select_db($db_name, $db_connect);
 
  $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
  $result1 = mysql_query($sql1,$db);
  if (!$result1) {
   echo(PError performing 1st query:  .
        mysql_error() . /P);
   exit();
  }
  ?
 
  --
 
  Phil Jourdan --- p...@ptahhotep.com
    http://www.ptahhotep.com
    http://www.chiccantine.com
 
 
  --
  MySQL General Mailing List
  For list archives: http://lists.mysql.com/mysql
  To unsubscribe:    http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com
 
 

 I agree. I wouldn't trust me at all! ;)


 Ash
 www.ashleysheridan.co.uk



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



Re: [PHP] Re: catch the error

2009-02-26 Thread 9el
But the question is PJ, have you got it out of errors yet? :)

www.twitter.com/nine_L
www.lenin9l.wordpress.com
---
Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get
a Free CD of Ubuntu mailed to your door without any cost. Visit :
www.ubuntu.com
--


2009/2/27 Ashley Sheridan a...@ashleysheridan.co.uk

 On Thu, 2009-02-26 at 13:34 -0500, Darryle Steplight wrote:
  Hi PJ,
 $db_host = 'biggie';
  $db_user = 'root';
  $db_pass = 'gu...@#$';
  $db_name = 'biblane';
 
 
 
  Everyone here is trying to help you and that's cool, but EVERYONE on
  this list may not be so nice. The above credentials is definitely the
  type of information you want to keep private, unless you don't mind
  people potentially accessing your database tables and doing whatever
  they like with them.
 
  I suggest doing something like
  $db_host = 'localhost;
  $db_user = 'foo';
  $db_pass= ''bar;
  $db_name =''xx;
 
  if you are going to post it on the list.
 
  On Thu, Feb 26, 2009 at 1:22 PM, PJ af.gour...@videotron.ca wrote:
   Ricardo Dias Marques wrote:
   Hi PJ,
  
   On Thu, Feb 26, 2009 at 17:28, PJ af.gour...@videotron.ca wrote:
  
  
   What is wrond with this file? same identical insert works from
 console
   but not from this file :-(
  
   [snip]
  
   ?
   //include (lib/db1.php);// Connect to database
  

 mysql_connect('biggie', 'user', 'password', 'test') or die(Error
connecting DB.mysql_error());
  $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');

$result1 = mysql_query($sql1,$db) or die(PError performing 1st query: 
.mysql_error() . /P);

  ?
 
 
  I haven't coded in PHP for a long time, but I think that your problem
  is in this line:
 
  $result1 = mysql_query($sql1,$db);
 
  Up to that point, $db (that should point to a database link
  identifier) is not defined. You probably want to assign the
  mysql_connect result to that $db variable.
 
 
  So, I think that you will solve your problem by changing your
  mysql_connect line FROM the current form:
 
  mysql_connect('biggie', 'user', 'password', 'test');
 
  .. TO this one:
 
  $db = mysql_connect('biggie', 'user', 'password', 'test');
 
 
  Am I right?
  Partly. I had an error in the location of the include. Ashley corrected
  the rest but it only works with the include. Not as whown below
  ?
  //include (../lib/db1.php);// Connect to database
 
  $db_host = 'biggie';
  $db_user = 'root';
  $db_pass = 'gu...@#$';
  $db_name = 'biblane';
 
  $db_connect = mysql_connect($db_host, $db_user, $db_pass);
  $db_select = mysql_select_db($db_name, $db_connect);
 
  $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
  $result1 = mysql_query($sql1,$db);
  if (!$result1) {
   echo(PError performing 1st query:  .
mysql_error() . /P);
   exit();
  }
  ?
 
  --
 
  Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com
 
 
  --
  MySQL General Mailing List
  For list archives: http://lists.mysql.com/mysql
  To unsubscribe:
http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com
 
 


 I agree. I wouldn't trust me at all! ;)


 Ash
 www.ashleysheridan.co.uk


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




[PHP] Re: catch the error

2009-02-26 Thread PJ
Jerry Schwartz wrote:
   
 -Original Message-
 From: PJ [mailto:af.gour...@videotron.ca]
 Sent: Thursday, February 26, 2009 12:28 PM
 To: php-general@lists.php.net; MySql
 Subject: catch the error

 What is wrond with this file? same identical insert works from console
 but not from this file :-(

 html
 head
titleUntitled/title
 /head

 body
 ?
 //include (lib/db1.php);// Connect to database
 mysql_connect('biggie', 'user', 'password', 'test');
 $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
   mysql_error() . /P);
  exit();
 }
 ?

 /body
 /html

 Seems to be good to print out the error message, but that's all. db not
 written.

 
 [JS] You need

   $db = mysql_connect('biggie', 'user', 'password', 'test');

   
 --

 Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql?unsub=jschwa...@the-
 infoshop.com
 





   
I think the problem here has been that this is such a basic operation
and most of us just are too busy with more complicated stuff...that we
didn't catch it...

?
//include (../lib/db1.php);// Connect to database

$db_host = '';
$db_user = '';
$db_pass = '';
$db_name = '';


$db = mysql_connect($db_host, $db_user, $db_pass);   
mysql_select_db($db_name,$db);

$sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
$result1 = mysql_query($sql1,$db);
if (!$result1) {
  echo(PError performing 3st query:  .
   mysql_error() . /P);
 
}
echo $sql1;
echo br /;
echo $db_select;
exit();
?
anyway, I am learning a lot...
thanks, guys... you're all great...
I have lots more coming...  :-D

-- 

Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


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



Re: [PHP] Re: catch the error

2009-02-26 Thread PJ
Ashley Sheridan wrote:
 On Thu, 2009-02-26 at 13:34 -0500, Darryle Steplight wrote:
   
 Hi PJ,
$db_host = 'biggie';
 $db_user = 'root';
 $db_pass = 'gu...@#$';
 $db_name = 'biblane';



 Everyone here is trying to help you and that's cool, but EVERYONE on
 this list may not be so nice. The above credentials is definitely the
 type of information you want to keep private, unless you don't mind
 people potentially accessing your database tables and doing whatever
 they like with them.

 I suggest doing something like
 $db_host = 'localhost;
 $db_user = 'foo';
 $db_pass= ''bar;
 $db_name =''xx;

 if you are going to post it on the list.

 On Thu, Feb 26, 2009 at 1:22 PM, PJ af.gour...@videotron.ca wrote:
 
 Ricardo Dias Marques wrote:
   
 Hi PJ,

 On Thu, Feb 26, 2009 at 17:28, PJ af.gour...@videotron.ca wrote:


 
 What is wrond with this file? same identical insert works from console
 but not from this file :-(

 [snip]

 ?
 //include (lib/db1.php);// Connect to database
 mysql_connect('biggie', 'user', 'password', 'test');
 $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
   mysql_error() . /P);
  exit();
 }
 ?

   
 I haven't coded in PHP for a long time, but I think that your problem
 is in this line:

 $result1 = mysql_query($sql1,$db);

 Up to that point, $db (that should point to a database link
 identifier) is not defined. You probably want to assign the
 mysql_connect result to that $db variable.


 So, I think that you will solve your problem by changing your
 mysql_connect line FROM the current form:

 mysql_connect('biggie', 'user', 'password', 'test');

 .. TO this one:

 $db = mysql_connect('biggie', 'user', 'password', 'test');


 Am I right?
 
 Partly. I had an error in the location of the include. Ashley corrected
 the rest but it only works with the include. Not as whown below
 ?
 //include (../lib/db1.php);// Connect to database

 $db_host = 'biggie';
 $db_user = 'root';
 $db_pass = 'gu...@#$';
 $db_name = 'biblane';

 $db_connect = mysql_connect($db_host, $db_user, $db_pass);
 $db_select = mysql_select_db($db_name, $db_connect);

 $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
   mysql_error() . /P);
  exit();
 }
 ?

 --

 Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com


   
 I agree. I wouldn't trust me at all! ;)


 Ash
 www.ashleysheridan.co.uk


   
Yeah very stupid of me...but I found the error: see if you can catch it:
?
//include (../lib/db1.php);// Connect to database

$db_host = 'xxx';
$db_user = 'xxx;
$db_pass = 'xxx';
$db_name = 'xxx';


$db = mysql_connect($db_host, $db_user, $db_pass);   
mysql_select_db($db_name,$db);

$sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
$result1 = mysql_query($sql1,$db);
if (!$result1) {
  echo(PError performing 3st query:  .
   mysql_error() . /P);
 
}
echo $sql1;
echo br /;
echo $db_select;
exit();
?

-- 

Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


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



Re: [PHP] Re: catch the error

2009-02-26 Thread Ashley Sheridan
On Thu, 2009-02-26 at 13:56 -0500, PJ wrote:
 Ashley Sheridan wrote:
  On Thu, 2009-02-26 at 13:34 -0500, Darryle Steplight wrote:

  Hi PJ,
 $db_host = 'biggie';
  $db_user = 'root';
  $db_pass = 'gu...@#$';
  $db_name = 'biblane';
 
 
 
  Everyone here is trying to help you and that's cool, but EVERYONE on
  this list may not be so nice. The above credentials is definitely the
  type of information you want to keep private, unless you don't mind
  people potentially accessing your database tables and doing whatever
  they like with them.
 
  I suggest doing something like
  $db_host = 'localhost;
  $db_user = 'foo';
  $db_pass= ''bar;
  $db_name =''xx;
 
  if you are going to post it on the list.
 
  On Thu, Feb 26, 2009 at 1:22 PM, PJ af.gour...@videotron.ca wrote:
  
  Ricardo Dias Marques wrote:

  Hi PJ,
 
  On Thu, Feb 26, 2009 at 17:28, PJ af.gour...@videotron.ca wrote:
 
 
  
  What is wrond with this file? same identical insert works from console
  but not from this file :-(
 
  [snip]
 
  ?
  //include (lib/db1.php);// Connect to database
  mysql_connect('biggie', 'user', 'password', 'test');
  $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
  $result1 = mysql_query($sql1,$db);
  if (!$result1) {
   echo(PError performing 1st query:  .
mysql_error() . /P);
   exit();
  }
  ?
 

  I haven't coded in PHP for a long time, but I think that your problem
  is in this line:
 
  $result1 = mysql_query($sql1,$db);
 
  Up to that point, $db (that should point to a database link
  identifier) is not defined. You probably want to assign the
  mysql_connect result to that $db variable.
 
 
  So, I think that you will solve your problem by changing your
  mysql_connect line FROM the current form:
 
  mysql_connect('biggie', 'user', 'password', 'test');
 
  .. TO this one:
 
  $db = mysql_connect('biggie', 'user', 'password', 'test');
 
 
  Am I right?
  
  Partly. I had an error in the location of the include. Ashley corrected
  the rest but it only works with the include. Not as whown below
  ?
  //include (../lib/db1.php);// Connect to database
 
  $db_host = 'biggie';
  $db_user = 'root';
  $db_pass = 'gu...@#$';
  $db_name = 'biblane';
 
  $db_connect = mysql_connect($db_host, $db_user, $db_pass);
  $db_select = mysql_select_db($db_name, $db_connect);
 
  $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
  $result1 = mysql_query($sql1,$db);
  if (!$result1) {
   echo(PError performing 1st query:  .
mysql_error() . /P);
   exit();
  }
  ?
 
  --
 
  Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com
 
 
  --
  MySQL General Mailing List
  For list archives: http://lists.mysql.com/mysql
  To unsubscribe:http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com
 
 

  I agree. I wouldn't trust me at all! ;)
 
 
  Ash
  www.ashleysheridan.co.uk
 
 

 Yeah very stupid of me...but I found the error: see if you can catch it:
 ?
 //include (../lib/db1.php);// Connect to database
 
 $db_host = 'xxx';
 $db_user = 'xxx;
 $db_pass = 'xxx';
 $db_name = 'xxx';
 
 
 $db = mysql_connect($db_host, $db_user, $db_pass);   
 mysql_select_db($db_name,$db);
 
 $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
   echo(PError performing 3st query:  .
mysql_error() . /P);
  
 }
 echo $sql1;
 echo br /;
 echo $db_select;
 exit();
 ?
 
 -- 
 
 Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com
 
 
$db_user has not had the string terminated. pray tell was that the
answer you were looking for?!


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Re: catch the error

2009-02-26 Thread PJ
Here's the working code...
?
//include (../lib/db1.php);// Connect to database

$db_host = '';
$db_user = '';
$db_pass = '';
$db_name = '';


$db = mysql_connect($db_host, $db_user, $db_pass);   
mysql_select_db($db_name,$db);

$sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
$result1 = mysql_query($sql1,$db);
if (!$result1) {
  echo(PError performing 3st query:  .
   mysql_error() . /P);
 
}
echo $sql1;
echo br /;
echo $db_select;
exit();
?
This works fine either as is or using the include... :-)


9el wrote:
 But the question is PJ, have you got it out of errors yet? :)

 www.twitter.com/nine_L http://www.twitter.com/nine_L
 www.lenin9l.wordpress.com http://www.lenin9l.wordpress.com
 ---
 Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get
 a Free CD of Ubuntu mailed to your door without any cost. Visit :
 www.ubuntu.com http://www.ubuntu.com
 --


 2009/2/27 Ashley Sheridan a...@ashleysheridan.co.uk
 mailto:a...@ashleysheridan.co.uk

 On Thu, 2009-02-26 at 13:34 -0500, Darryle Steplight wrote:
  Hi PJ,
 $db_host = 'biggie';
  $db_user = 'root';
  $db_pass = 'gu...@#$';
  $db_name = 'biblane';
 
 
 
  Everyone here is trying to help you and that's cool, but EVERYONE on
  this list may not be so nice. The above credentials is
 definitely the
  type of information you want to keep private, unless you don't mind
  people potentially accessing your database tables and doing whatever
  they like with them.
 
  I suggest doing something like
  $db_host = 'localhost;
  $db_user = 'foo';
  $db_pass= ''bar;
  $db_name =''xx;
 
  if you are going to post it on the list.
 
  On Thu, Feb 26, 2009 at 1:22 PM, PJ af.gour...@videotron.ca
 mailto:af.gour...@videotron.ca wrote:
   Ricardo Dias Marques wrote:
   Hi PJ,
  
   On Thu, Feb 26, 2009 at 17:28, PJ af.gour...@videotron.ca
 mailto:af.gour...@videotron.ca wrote:
  
  
   What is wrond with this file? same identical insert works
 from console
   but not from this file :-(
  
   [snip]
  
   ?
   //include (lib/db1.php);// Connect to database
  

  mysql_connect('biggie', 'user', 'password', 'test') or die(Error
 connecting DB.mysql_error());
   $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
  
 $result1 = mysql_query($sql1,$db) or die(PError performing 1st
 query:  .mysql_error() . /P);

   ?
  
  
   I haven't coded in PHP for a long time, but I think that your problem
   is in this line:
  
   $result1 = mysql_query($sql1,$db);
  
   Up to that point, $db (that should point to a database link
   identifier) is not defined. You probably want to assign the
   mysql_connect result to that $db variable.
  
  
   So, I think that you will solve your problem by changing your
   mysql_connect line FROM the current form:
  
   mysql_connect('biggie', 'user', 'password', 'test');
  
   .. TO this one:
  
   $db = mysql_connect('biggie', 'user', 'password', 'test');
  
  
   Am I right?
   Partly. I had an error in the location of the include. Ashley
 corrected
   the rest but it only works with the include. Not as whown below
   ?
   //include (../lib/db1.php);// Connect to database
  
   $db_host = 'biggie';
   $db_user = 'root';
   $db_pass = 'gu...@#$';
   $db_name = 'biblane';
  
   $db_connect = mysql_connect($db_host, $db_user, $db_pass);
   $db_select = mysql_select_db($db_name, $db_connect);
  
   $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
   $result1 = mysql_query($sql1,$db);
   if (!$result1) {
echo(PError performing 1st query:  .
 mysql_error() . /P);
exit();
   }
   ?
  
   --
  
   Phil Jourdan --- p...@ptahhotep.com mailto:p...@ptahhotep.com
 http://www.ptahhotep.com
 http://www.chiccantine.com
  
  
   --
   MySQL General Mailing List
   For list archives: http://lists.mysql.com/mysql
   To unsubscribe:  
  http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com
  
  
 

 I agree. I wouldn't trust me at all! ;)


 Ash
 www.ashleysheridan.co.uk http://www.ashleysheridan.co.uk


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




-- 

Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com

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



Re: [PHP] Re: catch the error

2009-02-26 Thread PJ
Ashley Sheridan wrote:
 On Thu, 2009-02-26 at 13:56 -0500, PJ wrote:
   
 Ashley Sheridan wrote:
 
 On Thu, 2009-02-26 at 13:34 -0500, Darryle Steplight wrote:
   
   
 Hi PJ,
$db_host = 'biggie';
 $db_user = 'root';
 $db_pass = 'gu...@#$';
 $db_name = 'biblane';



 Everyone here is trying to help you and that's cool, but EVERYONE on
 this list may not be so nice. The above credentials is definitely the
 type of information you want to keep private, unless you don't mind
 people potentially accessing your database tables and doing whatever
 they like with them.

 I suggest doing something like
 $db_host = 'localhost;
 $db_user = 'foo';
 $db_pass= ''bar;
 $db_name =''xx;

 if you are going to post it on the list.

 On Thu, Feb 26, 2009 at 1:22 PM, PJ af.gour...@videotron.ca wrote:
 
 
 Ricardo Dias Marques wrote:
   
   
 Hi PJ,

 On Thu, Feb 26, 2009 at 17:28, PJ af.gour...@videotron.ca wrote:


 
 
 What is wrond with this file? same identical insert works from console
 but not from this file :-(

 [snip]

 ?
 //include (lib/db1.php);// Connect to database
 mysql_connect('biggie', 'user', 'password', 'test');
 $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
   mysql_error() . /P);
  exit();
 }
 ?

   
   
 I haven't coded in PHP for a long time, but I think that your problem
 is in this line:

 $result1 = mysql_query($sql1,$db);

 Up to that point, $db (that should point to a database link
 identifier) is not defined. You probably want to assign the
 mysql_connect result to that $db variable.


 So, I think that you will solve your problem by changing your
 mysql_connect line FROM the current form:

 mysql_connect('biggie', 'user', 'password', 'test');

 .. TO this one:

 $db = mysql_connect('biggie', 'user', 'password', 'test');


 Am I right?
 
 
 Partly. I had an error in the location of the include. Ashley corrected
 the rest but it only works with the include. Not as whown below
 ?
 //include (../lib/db1.php);// Connect to database

 $db_host = 'biggie';
 $db_user = 'root';
 $db_pass = 'gu...@#$';
 $db_name = 'biblane';

 $db_connect = mysql_connect($db_host, $db_user, $db_pass);
 $db_select = mysql_select_db($db_name, $db_connect);

 $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
   mysql_error() . /P);
  exit();
 }
 ?

 --

 Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com


   
   
 I agree. I wouldn't trust me at all! ;)


 Ash
 www.ashleysheridan.co.uk


   
   
 Yeah very stupid of me...but I found the error: see if you can catch it:
 ?
 //include (../lib/db1.php);// Connect to database

 $db_host = 'xxx';
 $db_user = 'xxx;
 $db_pass = 'xxx';
 $db_name = 'xxx';


 $db = mysql_connect($db_host, $db_user, $db_pass);   
 mysql_select_db($db_name,$db);

 $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
   echo(PError performing 3st query:  .
mysql_error() . /P);
  
 }
 echo $sql1;
 echo br /;
 echo $db_select;
 exit();
 ?

 -- 

 Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com


 
 $db_user has not had the string terminated. pray tell was that the
 answer you were looking for?!


 Ash
 www.ashleysheridan.co.uk


   
No. Damn those typos!

What seems to have made it work is just

$db = mysql_connect($db_host, $db_user, $db_pass);   
mysql_select_db($db_name,$db);

not using mysql_select in a string
but would you use it in a string? how  why?

-- 

Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


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



RE: [PHP] Re: catch the error

2009-02-26 Thread Boyd, Todd M.
 -Original Message-
 From: PJ [mailto:af.gour...@videotron.ca]
 Sent: Thursday, February 26, 2009 1:16 PM
 To: a...@ashleysheridan.co.uk
 Cc: Darryle Steplight; Ricardo Dias Marques;
php-general@lists.php.net;
 MySql
 Subject: Re: [PHP] Re: catch the error
 
 Ashley Sheridan wrote:
  On Thu, 2009-02-26 at 13:56 -0500, PJ wrote:
 
  Ashley Sheridan wrote:
 
  On Thu, 2009-02-26 at 13:34 -0500, Darryle Steplight wrote:
 
 
  Hi PJ,
 $db_host = 'biggie';
  $db_user = 'root';
  $db_pass = 'gu...@#$';
  $db_name = 'biblane';
 
 
 
  Everyone here is trying to help you and that's cool, but EVERYONE
 on
  this list may not be so nice. The above credentials is definitely
 the
  type of information you want to keep private, unless you don't
 mind
  people potentially accessing your database tables and doing
 whatever
  they like with them.
 
  I suggest doing something like
  $db_host = 'localhost;
  $db_user = 'foo';
  $db_pass= ''bar;
  $db_name =''xx;
 
  if you are going to post it on the list.
 
  On Thu, Feb 26, 2009 at 1:22 PM, PJ af.gour...@videotron.ca
 wrote:
 
 
  Ricardo Dias Marques wrote:
 
 
  Hi PJ,
 
  On Thu, Feb 26, 2009 at 17:28, PJ af.gour...@videotron.ca
 wrote:
 
 
 
 
  What is wrond with this file? same identical insert works from
 console
  but not from this file :-(
 
  [snip]
 
  ?
  //include (lib/db1.php);// Connect to database
  mysql_connect('biggie', 'user', 'password', 'test');
  $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow',
 '69');
  $result1 = mysql_query($sql1,$db);
  if (!$result1) {
   echo(PError performing 1st query:  .
mysql_error() . /P);
   exit();
  }
  ?
 
 
 
  I haven't coded in PHP for a long time, but I think that your
 problem
  is in this line:
 
  $result1 = mysql_query($sql1,$db);
 
  Up to that point, $db (that should point to a database link
  identifier) is not defined. You probably want to assign the
  mysql_connect result to that $db variable.
 
 
  So, I think that you will solve your problem by changing your
  mysql_connect line FROM the current form:
 
  mysql_connect('biggie', 'user', 'password', 'test');
 
  .. TO this one:
 
  $db = mysql_connect('biggie', 'user', 'password', 'test');
 
 
  Am I right?
 
 
  Partly. I had an error in the location of the include. Ashley
 corrected
  the rest but it only works with the include. Not as whown below
  ?
  //include (../lib/db1.php);// Connect to database
 
  $db_host = 'biggie';
  $db_user = 'root';
  $db_pass = 'gu...@#$';
  $db_name = 'biblane';
 
  $db_connect = mysql_connect($db_host, $db_user, $db_pass);
  $db_select = mysql_select_db($db_name, $db_connect);
 
  $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz',
 '75');
  $result1 = mysql_query($sql1,$db);
  if (!$result1) {
   echo(PError performing 1st query:  .
mysql_error() . /P);
   exit();
  }
  ?
 
  --
 
  Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com
 
 
  --
  MySQL General Mailing List
  For list archives: http://lists.mysql.com/mysql
  To unsubscribe:
 http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com
 
 
 
 
  I agree. I wouldn't trust me at all! ;)
 
 
  Ash
  www.ashleysheridan.co.uk
 
 
 
 
  Yeah very stupid of me...but I found the error: see if you can
 catch it:
  ?
  //include (../lib/db1.php);// Connect to database
 
  $db_host = 'xxx';
  $db_user = 'xxx;
  $db_pass = 'xxx';
  $db_name = 'xxx';
 
 
  $db = mysql_connect($db_host, $db_user, $db_pass);
  mysql_select_db($db_name,$db);
 
  $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz',
 '75');
  $result1 = mysql_query($sql1,$db);
  if (!$result1) {
echo(PError performing 3st query:  .
 mysql_error() . /P);
 
  }
  echo $sql1;
  echo br /;
  echo $db_select;
  exit();
  ?
 
  --
 
  Phil Jourdan --- p...@ptahhotep.com
 http://www.ptahhotep.com
 http://www.chiccantine.com
 
 
 
  $db_user has not had the string terminated. pray tell was that the
  answer you were looking for?!
 
 
  Ash
  www.ashleysheridan.co.uk
 
 
 
 No. Damn those typos!
 
 What seems to have made it work is just
 
 $db = mysql_connect($db_host, $db_user, $db_pass);
 mysql_select_db($db_name,$db);
 
 not using mysql_select in a string
 but would you use it in a string? how  why?

Jesus Christ... everyone on this list must've had a long week, because
you guys are going blind. :D

In examples sent to you, people foolishly replaced your $db var with
$db_connect ONLY FOR PART OF THE SCRIPT. You've defined your database
connection as $db_connect in some versions of the source, but then you
reference $db (without _connect) in your mysql_select call in that same
source.

$db = mysql_connect([option list here]); # -- this code instantiates a
connection
mysql_select_db([some name], $db); # notice how $db is here?
$result = mysql_query([some query], $db); # it's here, too!

$db becomes your resource link when you use mysql_connect. That resource
link must

Re: [PHP] Re: catch the error

2009-02-26 Thread Ashley Sheridan
On Thu, 2009-02-26 at 14:15 -0500, PJ wrote:
 Ashley Sheridan wrote:
  On Thu, 2009-02-26 at 13:56 -0500, PJ wrote:

  Ashley Sheridan wrote:
  
  On Thu, 2009-02-26 at 13:34 -0500, Darryle Steplight wrote:


  Hi PJ,
 $db_host = 'biggie';
  $db_user = 'root';
  $db_pass = 'gu...@#$';
  $db_name = 'biblane';
 
 
 
  Everyone here is trying to help you and that's cool, but EVERYONE on
  this list may not be so nice. The above credentials is definitely the
  type of information you want to keep private, unless you don't mind
  people potentially accessing your database tables and doing whatever
  they like with them.
 
  I suggest doing something like
  $db_host = 'localhost;
  $db_user = 'foo';
  $db_pass= ''bar;
  $db_name =''xx;
 
  if you are going to post it on the list.
 
  On Thu, Feb 26, 2009 at 1:22 PM, PJ af.gour...@videotron.ca wrote:
  
  
  Ricardo Dias Marques wrote:


  Hi PJ,
 
  On Thu, Feb 26, 2009 at 17:28, PJ af.gour...@videotron.ca wrote:
 
 
  
  
  What is wrond with this file? same identical insert works from console
  but not from this file :-(
 
  [snip]
 
  ?
  //include (lib/db1.php);// Connect to database
  mysql_connect('biggie', 'user', 'password', 'test');
  $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
  $result1 = mysql_query($sql1,$db);
  if (!$result1) {
   echo(PError performing 1st query:  .
mysql_error() . /P);
   exit();
  }
  ?
 


  I haven't coded in PHP for a long time, but I think that your problem
  is in this line:
 
  $result1 = mysql_query($sql1,$db);
 
  Up to that point, $db (that should point to a database link
  identifier) is not defined. You probably want to assign the
  mysql_connect result to that $db variable.
 
 
  So, I think that you will solve your problem by changing your
  mysql_connect line FROM the current form:
 
  mysql_connect('biggie', 'user', 'password', 'test');
 
  .. TO this one:
 
  $db = mysql_connect('biggie', 'user', 'password', 'test');
 
 
  Am I right?
  
  
  Partly. I had an error in the location of the include. Ashley corrected
  the rest but it only works with the include. Not as whown below
  ?
  //include (../lib/db1.php);// Connect to database
 
  $db_host = 'biggie';
  $db_user = 'root';
  $db_pass = 'gu...@#$';
  $db_name = 'biblane';
 
  $db_connect = mysql_connect($db_host, $db_user, $db_pass);
  $db_select = mysql_select_db($db_name, $db_connect);
 
  $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
  $result1 = mysql_query($sql1,$db);
  if (!$result1) {
   echo(PError performing 1st query:  .
mysql_error() . /P);
   exit();
  }
  ?
 
  --
 
  Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com
 
 
  --
  MySQL General Mailing List
  For list archives: http://lists.mysql.com/mysql
  To unsubscribe:
  http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com
 
 


  I agree. I wouldn't trust me at all! ;)
 
 
  Ash
  www.ashleysheridan.co.uk
 
 


  Yeah very stupid of me...but I found the error: see if you can catch 
  it:
  ?
  //include (../lib/db1.php);// Connect to database
 
  $db_host = 'xxx';
  $db_user = 'xxx;
  $db_pass = 'xxx';
  $db_name = 'xxx';
 
 
  $db = mysql_connect($db_host, $db_user, $db_pass);   
  mysql_select_db($db_name,$db);
 
  $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
  $result1 = mysql_query($sql1,$db);
  if (!$result1) {
echo(PError performing 3st query:  .
 mysql_error() . /P);
   
  }
  echo $sql1;
  echo br /;
  echo $db_select;
  exit();
  ?
 
  -- 
 
  Phil Jourdan --- p...@ptahhotep.com
 http://www.ptahhotep.com
 http://www.chiccantine.com
 
 
  
  $db_user has not had the string terminated. pray tell was that the
  answer you were looking for?!
 
 
  Ash
  www.ashleysheridan.co.uk
 
 

 No. Damn those typos!
 
 What seems to have made it work is just
 
 $db = mysql_connect($db_host, $db_user, $db_pass);   
 mysql_select_db($db_name,$db);
 
 not using mysql_select in a string
 but would you use it in a string? how  why?
 
 -- 
 
 Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com
 
 
Yeah, you'd typo'd on the variable name. Also, the $ sign doesn't
actually denote a string, but a scaler variable, which can be any type,
complex or simple.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Re: catch the error

2009-02-26 Thread Shawn McKenzie
Boyd, Todd M. wrote:
  Jesus Christ... everyone on this list must've had a long week, because
 you guys are going blind. :D
 
 In examples sent to you, people foolishly replaced your $db var with
 $db_connect ONLY FOR PART OF THE SCRIPT. You've defined your database
 connection as $db_connect in some versions of the source, but then you
 reference $db (without _connect) in your mysql_select call in that same
 source.
 
 $db = mysql_connect([option list here]); # -- this code instantiates a
 connection
 mysql_select_db([some name], $db); # notice how $db is here?
 $result = mysql_query([some query], $db); # it's here, too!
 
 $db becomes your resource link when you use mysql_connect. That resource
 link must then be passed to your mysql functions. Otherwise, they have
 no idea which database connection you are attempting to use.
 
 # BAD:
 $db = mysql_connect([options]);
 $result = mysql_query([some query], $db_connect); # what's $db_connect?
 who knows!
 
 # GOOD:
 $db = mysql_connect([options]);
 $result = mysql_query([some query], $db); # same resource link from
 mysql_connect
 
 See?
 
 HTH,
 
 
 // Todd

Yes, and I would also strongly urge (scream at) PJ, to turn on E_ALL
error reporting in any script he has problems with.

#1 you'll figure out the problem because the errors will tell you
exactly what the problem is undefined variable db_connect, etc...

#2 if you can't figure it out, someone here can easily if you give the
errors.

Virtually every problem you've posted throws an error(s) that will tell
you what the F*** is the problem!

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Re: catch the error

2009-02-26 Thread Chris



In examples sent to you, people foolishly replaced your $db var with
$db_connect ONLY FOR PART OF THE SCRIPT. You've defined your database
connection as $db_connect in some versions of the source, but then you
reference $db (without _connect) in your mysql_select call in that same
source.

$db = mysql_connect([option list here]); # -- this code instantiates a
connection
mysql_select_db([some name], $db); # notice how $db is here?
$result = mysql_query([some query], $db); # it's here, too!

$db becomes your resource link when you use mysql_connect. That resource
link must then be passed to your mysql functions. Otherwise, they have
no idea which database connection you are attempting to use.


RTFM?

If no connection is specified, the last one is used.

It is an optional argument (only *really* needed when you have multiple 
connections in the same script).


--
Postgresql  php tutorials
http://www.designmagick.com/


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



RE: [PHP] Re: catch the error

2009-02-26 Thread Boyd, Todd M.
 -Original Message-
 From: Chris [mailto:dmag...@gmail.com]
 Sent: Thursday, February 26, 2009 4:16 PM
 To: Boyd, Todd M.
 Cc: PJ; PHP General list
 Subject: Re: [PHP] Re: catch the error
 
 
  In examples sent to you, people foolishly replaced your $db var with
  $db_connect ONLY FOR PART OF THE SCRIPT. You've defined your
database
  connection as $db_connect in some versions of the source, but then
 you
  reference $db (without _connect) in your mysql_select call in that
 same
  source.
 
  $db = mysql_connect([option list here]); # -- this code
instantiates
 a
  connection
  mysql_select_db([some name], $db); # notice how $db is here?
  $result = mysql_query([some query], $db); # it's here, too!
 
  $db becomes your resource link when you use mysql_connect. That
 resource
  link must then be passed to your mysql functions. Otherwise, they
 have
  no idea which database connection you are attempting to use.
 
 RTFM?
 
 If no connection is specified, the last one is used.
 
 It is an optional argument (only *really* needed when you have
multiple
 connections in the same script).

RTF E-mail I sent?

He had used $db_connect instead of $db. $db_connect hadn't been set to
anything. He was specifying a connection, but it was null. Unless it
falls back to the last connection used in the case of an empty variable,
then this was most likely (read: proven to be) the problem.

:p

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



Re: [PHP] Re: catch the error

2009-02-26 Thread PJ
Shawn McKenzie wrote:
 Boyd, Todd M. wrote:
   Jesus Christ... everyone on this list must've had a long week, because
   
 you guys are going blind. :D

 In examples sent to you, people foolishly replaced your $db var with
 $db_connect ONLY FOR PART OF THE SCRIPT. You've defined your database
 connection as $db_connect in some versions of the source, but then you
 reference $db (without _connect) in your mysql_select call in that same
 source.

 $db = mysql_connect([option list here]); # -- this code instantiates a
 connection
 mysql_select_db([some name], $db); # notice how $db is here?
 $result = mysql_query([some query], $db); # it's here, too!

 $db becomes your resource link when you use mysql_connect. That resource
 link must then be passed to your mysql functions. Otherwise, they have
 no idea which database connection you are attempting to use.

 # BAD:
 $db = mysql_connect([options]);
 $result = mysql_query([some query], $db_connect); # what's $db_connect?
 who knows!

 # GOOD:
 $db = mysql_connect([options]);
 $result = mysql_query([some query], $db); # same resource link from
 mysql_connect

 See?

 HTH,


 // Todd
 

 Yes, and I would also strongly urge (scream at) PJ, to turn on E_ALL
 error reporting in any script he has problems with.

 #1 you'll figure out the problem because the errors will tell you
 exactly what the problem is undefined variable db_connect, etc...

 #2 if you can't figure it out, someone here can easily if you give the
 errors.

 Virtually every problem you've posted throws an error(s) that will tell
 you what the F*** is the problem!

   
Ok, ok, I understant the frustrations
But, yes, I think that some of the suggestions were rather hastily made
as most of the guys must be very busy and as we are all somewhat normal,
we do make mistakes. I mixed up some suggestions with other errors of
mine and so we had spaghetti. So, now let's kiss and make up... or as
the Italians would say, Amici, come prima. :-)

I'm glad you mention the error reporting and I admit i haven't been
doing much of that. I do not understand how it should be set up or where
I should look for the errors.
I did try
ini_set(display_errors,true);
error_reporting(E_STRICT|E_ALL);
but it meant absolutely nothing. I could not find any logs for mysql or
php errors and none appeared magically in the page.
Perhaps you could steer me to an explanation somewhere. I was able to
save some grief for all as I dif manage to find some guidelines on the
mysql manual site that were pretty helpful.
Thanks for your tolerance of my ignorance - love you all!
PJ

-- 

Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


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



Re: [PHP] Re: catch the error

2009-02-26 Thread PJ
Ashley Sheridan wrote:
 On Thu, 2009-02-26 at 14:15 -0500, PJ wrote:
   
 Ashley Sheridan wrote:
 
 On Thu, 2009-02-26 at 13:56 -0500, PJ wrote:
   
   
 Ashley Sheridan wrote:
 
 
 On Thu, 2009-02-26 at 13:34 -0500, Darryle Steplight wrote:
   
   
   
 Hi PJ,
$db_host = 'biggie';
 $db_user = 'root';
 $db_pass = 'gu...@#$';
 $db_name = 'biblane';



 Everyone here is trying to help you and that's cool, but EVERYONE on
 this list may not be so nice. The above credentials is definitely the
 type of information you want to keep private, unless you don't mind
 people potentially accessing your database tables and doing whatever
 they like with them.

 I suggest doing something like
 $db_host = 'localhost;
 $db_user = 'foo';
 $db_pass= ''bar;
 $db_name =''xx;

 if you are going to post it on the list.

 On Thu, Feb 26, 2009 at 1:22 PM, PJ af.gour...@videotron.ca wrote:
 
 
 
 Ricardo Dias Marques wrote:
   
   
   
 Hi PJ,

 On Thu, Feb 26, 2009 at 17:28, PJ af.gour...@videotron.ca wrote:


 
 
 
 What is wrond with this file? same identical insert works from console
 but not from this file :-(

 [snip]

 ?
 //include (lib/db1.php);// Connect to database
 mysql_connect('biggie', 'user', 'password', 'test');
 $sql1 = INSERT INTO example (name, age) VALUES ('Joe Blow', '69');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
   mysql_error() . /P);
  exit();
 }
 ?

   
   
   
 I haven't coded in PHP for a long time, but I think that your problem
 is in this line:

 $result1 = mysql_query($sql1,$db);

 Up to that point, $db (that should point to a database link
 identifier) is not defined. You probably want to assign the
 mysql_connect result to that $db variable.


 So, I think that you will solve your problem by changing your
 mysql_connect line FROM the current form:

 mysql_connect('biggie', 'user', 'password', 'test');

 .. TO this one:

 $db = mysql_connect('biggie', 'user', 'password', 'test');


 Am I right?
 
 
 
 Partly. I had an error in the location of the include. Ashley corrected
 the rest but it only works with the include. Not as whown below
 ?
 //include (../lib/db1.php);// Connect to database

 $db_host = 'biggie';
 $db_user = 'root';
 $db_pass = 'gu...@#$';
 $db_name = 'biblane';

 $db_connect = mysql_connect($db_host, $db_user, $db_pass);
 $db_select = mysql_select_db($db_name, $db_connect);

 $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
  echo(PError performing 1st query:  .
   mysql_error() . /P);
  exit();
 }
 ?

 --

 Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


 --
 MySQL General Mailing List
 For list archives: http://lists.mysql.com/mysql
 To unsubscribe:
 http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com


   
   
   
 I agree. I wouldn't trust me at all! ;)


 Ash
 www.ashleysheridan.co.uk


   
   
   
 Yeah very stupid of me...but I found the error: see if you can catch 
 it:
 ?
 //include (../lib/db1.php);// Connect to database

 $db_host = 'xxx';
 $db_user = 'xxx;
 $db_pass = 'xxx';
 $db_name = 'xxx';


 $db = mysql_connect($db_host, $db_user, $db_pass);   
 mysql_select_db($db_name,$db);

 $sql1 = INSERT INTO test (name, age) VALUES ('Arnie Shwartz', '75');
 $result1 = mysql_query($sql1,$db);
 if (!$result1) {
   echo(PError performing 3st query:  .
mysql_error() . /P);
  
 }
 echo $sql1;
 echo br /;
 echo $db_select;
 exit();
 ?

 -- 

 Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com


 
 
 $db_user has not had the string terminated. pray tell was that the
 answer you were looking for?!


 Ash
 www.ashleysheridan.co.uk


   
   
 No. Damn those typos!

 What seems to have made it work is just

 $db = mysql_connect($db_host, $db_user, $db_pass);   
 mysql_select_db($db_name,$db);

 not using mysql_select in a string
 but would you use it in a string? how  why?

 -- 

 Phil Jourdan --- p...@ptahhotep.com
http://www.ptahhotep.com
http://www.chiccantine.com


 
 Yeah, you'd typo'd on the variable name. Also, the $ sign doesn't
 actually denote a string, but a scaler variable, which can be any type,
 complex or simple.
   
I type too fast and am too speedy... :-)

I'll have to look up about the variables.
Thanks  good night. 'Til the morrow.


-- 

Phil Jourdan --- p...@ptahhotep.com
   http://www.ptahhotep.com
   http://www.chiccantine.com


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



Re: [PHP] Re: catch the error

2009-02-26 Thread Chris

Boyd, Todd M. wrote:

-Original Message-
From: Chris [mailto:dmag...@gmail.com]
Sent: Thursday, February 26, 2009 4:16 PM
To: Boyd, Todd M.
Cc: PJ; PHP General list
Subject: Re: [PHP] Re: catch the error



In examples sent to you, people foolishly replaced your $db var with
$db_connect ONLY FOR PART OF THE SCRIPT. You've defined your

database

connection as $db_connect in some versions of the source, but then

you

reference $db (without _connect) in your mysql_select call in that

same

source.

$db = mysql_connect([option list here]); # -- this code

instantiates

a

connection
mysql_select_db([some name], $db); # notice how $db is here?
$result = mysql_query([some query], $db); # it's here, too!

$db becomes your resource link when you use mysql_connect. That

resource

link must then be passed to your mysql functions. Otherwise, they

have

no idea which database connection you are attempting to use.

RTFM?

If no connection is specified, the last one is used.

It is an optional argument (only *really* needed when you have

multiple

connections in the same script).


RTF E-mail I sent?

He had used $db_connect instead of $db. $db_connect hadn't been set to
anything. He was specifying a connection, but it was null. Unless it
falls back to the last connection used in the case of an empty variable,
then this was most likely (read: proven to be) the problem.


The last two emails I saw (no I haven't read the whole thread) were:

 $db = mysql_connect($db_host, $db_user, $db_pass);
   mysql_select_db($db_name,$db);

snip

   $result1 = mysql_query($sql1,$db);

and

 $db = mysql_connect($db_host, $db_user, $db_pass);
 mysql_select_db($db_name,$db);

which have the right variables.

Plus I was picking on the you must do this - using the link identifier 
is an optional thing as I already said.


--
Postgresql  php tutorials
http://www.designmagick.com/


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



Re: [PHP] Re: catch the error

2009-02-26 Thread 9el
PJ you should be getting Warning errors the way you had the code.

You definitely is a fun lover and enjoy moments. But while coding dont only
think of fastness of coding but also code with logic.

I was going to answer you about the $db but later I found lots response
already came so didn't really dig to get the errors. Look back, see, I asked
if you got rid of the errors :)

Now, if you dont use the  variable in the parameter it will look for the
immediate opened database resource but if you use a variable. THEN it
must contain that required resource thats just OBVIOUS reason. And, your
error reporting should be reporting that. I haven't checked the code. A
funny thing is you are making others think for the things you should be
thinking. I dont say its bad. Its actually good for all of us having some
drill on the basics :D

Regards

Lenin

www.twitter.com/nine_L
www.lenin9l.wordpress.com

On Fri, Feb 27, 2009 at 6:37 AM, Chris dmag...@gmail.com wrote:

 Boyd, Todd M. wrote:

 -Original Message-
 From: Chris [mailto:dmag...@gmail.com]
 Sent: Thursday, February 26, 2009 4:16 PM
 To: Boyd, Todd M.
 Cc: PJ; PHP General list
 Subject: Re: [PHP] Re: catch the error


  In examples sent to you, people foolishly replaced your $db var with
 $db_connect ONLY FOR PART OF THE SCRIPT. You've defined your

 database

 connection as $db_connect in some versions of the source, but then

 you

 reference $db (without _connect) in your mysql_select call in that

 same

 source.

 $db = mysql_connect([option list here]); # -- this code

 instantiates

 a

 connection
 mysql_select_db([some name], $db); # notice how $db is here?
 $result = mysql_query([some query], $db); # it's here, too!

 $db becomes your resource link when you use mysql_connect. That

 resource

 link must then be passed to your mysql functions. Otherwise, they

 have

 no idea which database connection you are attempting to use.

 RTFM?

 If no connection is specified, the last one is used.

 It is an optional argument (only *really* needed when you have

 multiple

 connections in the same script).


 RTF E-mail I sent?

 He had used $db_connect instead of $db. $db_connect hadn't been set to
 anything. He was specifying a connection, but it was null. Unless it
 falls back to the last connection used in the case of an empty variable,
 then this was most likely (read: proven to be) the problem.


 The last two emails I saw (no I haven't read the whole thread) were:

  $db = mysql_connect($db_host, $db_user, $db_pass);
mysql_select_db($db_name,$db);

 snip

$result1 = mysql_query($sql1,$db);

 and

  $db = mysql_connect($db_host, $db_user, $db_pass);
  mysql_select_db($db_name,$db);

 which have the right variables.

 Plus I was picking on the you must do this - using the link identifier is
 an optional thing as I already said.

 --
 Postgresql  php tutorials
 http://www.designmagick.com/


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