Re: [PHP] Can anyone tell me why this code doesn't insert anything?

2004-02-23 Thread Richard Davey
Hello Brian,

Monday, February 23, 2004, 5:11:55 PM, you wrote:

BD> $query = "INSERT INTO invoices
BD> ('ip','total','creation','first_name','email','session','last_name')
BD> VALUES 
BD> ('0.0.0.0','0.00',NOW(),'Bob','[EMAIL PROTECTED]','12345','Smith')";

You shouldn't wrap the column names in quotes. Try:

$query = "INSERT INTO invoices (ip, total, creation, first_name,
email, session, last_name) VALUES ...

If that doesn't work there is probably an error between the query, the
query data and the SQL table structure. Post the SQL table layout so
the values can be checked.

-- 
Best regards,
 Richard Davey
 http://www.phpcommunity.org/wiki/296.html

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



Re: [PHP] Can anyone tell me why this code doesn't insert anything?

2004-02-23 Thread BAO RuiXian


Brian Dunning wrote:

On Feb 23, 2004, at 9:18 AM, BAO RuiXian wrote:

Have you tried to insert the same SQL statement manually, i.e., not 
via your php scirpt?


I did the insert in phpmyadmin & copied & pasted the SQL that it 
generated, and it's the same, so I'm left scratching my head big time.
How about from command line?

Please keep the discussion on the list.

Best

Bao

- Brian



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


Re: [PHP] Can anyone tell me why this code doesn't insert anything?

2004-02-23 Thread Jason Wong
On Tuesday 24 February 2004 01:11, Brian Dunning wrote:
> This inserts nothing into the database, but returns no error that I can
> see. How come? What's wrong with it?

mysql_error()

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
Some scholars are like donkeys, they merely carry a lot of books.
-- Folk saying
*/

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



Re: [PHP] Can anyone tell me why this code doesn't insert anything?

2004-02-23 Thread Adam Voigt
Change your query line to this:

$result = mysql_query($query) or die(mysql_error());

What does it output?


On Mon, 2004-02-23 at 12:11, Brian Dunning wrote:
> This inserts nothing into the database, but returns no error that I can 
> see. How come? What's wrong with it?
> 
> $dbname = "my_database";
> $dbconnection = mysql_connect("mysql05.powweb.com","my_user","my_pass");
> mysql_select_db($dbname, $dbconnection);
> $query = "INSERT INTO invoices 
> ('ip','total','creation','first_name','email','session','last_name') 
> VALUES 
> ('0.0.0.0','0.00',NOW(),'Bob','[EMAIL PROTECTED]','12345','Smith')";
> $result = mysql_query($query);
-- 

Adam Voigt
[EMAIL PROTECTED]

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



Re: [PHP] Can anyone tell me why this code doesn't insert anything?

2004-02-23 Thread BAO RuiXian


Brian Dunning wrote:

This inserts nothing into the database, but returns no error that I 
can see. How come? What's wrong with it?

$dbname = "my_database";
$dbconnection = mysql_connect("mysql05.powweb.com","my_user","my_pass");
mysql_select_db($dbname, $dbconnection);
$query = "INSERT INTO invoices 
('ip','total','creation','first_name','email','session','last_name') 
VALUES ('0.0.0.0','0.00',NOW(),'Bob','[EMAIL PROTECTED]','12345','Smith')";
$result = mysql_query($query);
Have you tried to insert the same SQL statement manually, i.e., not via 
your php scirpt?

Best

Bao

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


RE: [PHP] Can anyone tell me why this code doesn't insert anything?

2004-02-23 Thread Sam Masiello

What happens if you echo out $query to the browser window and try to
copy and paste the query into  a command line mysql session (be sure to
connect to the database using the same authentication credentials that
you have in the script)?  Does it work?

--Sam


Brian Dunning wrote:
> This inserts nothing into the database, but returns no error that I
> can see. How come? What's wrong with it?
> 
> $dbname = "my_database";
> $dbconnection =
> mysql_connect("mysql05.powweb.com","my_user","my_pass");
> mysql_select_db($dbname, $dbconnection); $query = "INSERT INTO
> invoices
> ('ip','total','creation','first_name','email','session','last_name')
> VALUES
> ('0.0.0.0','0.00',NOW(),'Bob','[EMAIL PROTECTED]','12345','Smith')";
> $result = mysql_query($query); 

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



[PHP] Can anyone tell me why this code doesn't insert anything?

2004-02-23 Thread Brian Dunning
This inserts nothing into the database, but returns no error that I can 
see. How come? What's wrong with it?

$dbname = "my_database";
$dbconnection = mysql_connect("mysql05.powweb.com","my_user","my_pass");
mysql_select_db($dbname, $dbconnection);
$query = "INSERT INTO invoices 
('ip','total','creation','first_name','email','session','last_name') 
VALUES 
('0.0.0.0','0.00',NOW(),'Bob','[EMAIL PROTECTED]','12345','Smith')";
$result = mysql_query($query);

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