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. -- 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=arch...@jab.org
Re: catch the error
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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: catch the error
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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: catch the error
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
Re: catch the error
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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: catch the error
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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: [PHP] catch the error
Ashley Sheridan wrote: On Thu, 2009-02-26 at 12:28 -0500, PJ 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 I'd say it was the way you are trying to connect to your database. This is how it's done: $db_host = 'localhost'; $db_user = 'root'; $db_password = ''; $db_name = 'database_name'; $db_connect = mysql_connect($db_host, $db_user, $db_pass); $db_select = mysql_select_db($db_name, $db_connect); You see, first you have to cerate a connection to the database server, then you have to select your database on that connection. In your example, 'biggie' is the name of a server where your database resides, and 'test', well, what can I say? This 4th parameter should be a boolean indicating whether or not a new connection should be made upon successive calls to mysql_connect. Ash www.ashleysheridan.co.uk OK, I see my error...understood and fixed... but it still does not work. But I did have an error - the include was wrong - missing ../ Something is till amiss... the include configuration works, this does not? Why? ? //include (../lib/db1.php);// Connect to database $db_host = 'biggie'; $db_user = 'myuser'; $db_pass = 'my_pwd'; $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=arch...@jab.org
Re: catch the error
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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: catch the error
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=arch...@jab.org
Re: catch the error
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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: catch the error
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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
RE: catch the error
-Original Message- From: PJ [mailto:af.gour...@videotron.ca] Sent: Thursday, February 26, 2009 12:28 PM To: php-gene...@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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: [PHP] Re: catch the error
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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: catch the error
Jerry Schwartz wrote: -Original Message- From: PJ [mailto:af.gour...@videotron.ca] Sent: Thursday, February 26, 2009 12:28 PM To: php-gene...@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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: [PHP] Re: catch the error
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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: [PHP] Re: catch the error
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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
Re: catch the error [OFF TOPIC]
Gentlemen, my opinion is that this post is OFF TOPIC, let's don't wade into the PHP world here, let's keep this list clean and focused on MySQL. If the insert works from console and not from PHP probably is PHP related problem and there are thousands of lists on PHP. This is the most professional list on MySQL, let's keep it on MySQL. Phil, this is my humble opinion. Regards, Claudio Nanni PJ 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. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org
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? -- 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=arch...@jab.org
Re: [PHP] Re: catch the error
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 -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/mysql?unsub=arch...@jab.org