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("<P>Error performing 1st query: " .
mysql_error() . "</P>");
exit();
}
?>
>
> That should fix the problem.
>
> On Thu, Feb 26, 2009 at 12:46 PM, PJ <[email protected]> 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 <[email protected]> wrote:
>>>
>>>> What is wrond with this file? same identical insert works from console
>>>> but not from this file :-(
>>>>
>>>> <html>
>>>> <head>
>>>> <title>Untitled</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("<P>Error 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 --- [email protected]
>>>> 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/[email protected]
>>>>
>>>>
>>>>
>> --
>>
>> Phil Jourdan --- [email protected]
>> http://www.ptahhotep.com
>> http://www.chiccantine.com
>>
>>
>
>
--
Phil Jourdan --- [email protected]
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