Help inserting values in MySQL (provided code)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
CKEANEDesign
Forum Newbie
Posts: 19
Joined: Thu Mar 26, 2009 8:04 am

Help inserting values in MySQL (provided code)

Post by CKEANEDesign »

Code: Select all

$value = mysql_query("INSERT INTO Accounts (AccountName, FirstName, LastName, Age, City, State, Country) 
VALUES ('Ckeane17', 'Cory', 'Keane', '18', 'Chicago', 'IL', 'United States')");
if ($value)
 {
 echo('information inserted')
 }
 else
 {
 echo(mysql_error())
 }
Is there smething I'm doing wrong here? it wont post an error nor will it post "information inserted.."

Oh and how can I check my MySQL database to see what databases and tables are in my local host server?

Thanks a lot guys
User avatar
CKEANEDesign
Forum Newbie
Posts: 19
Joined: Thu Mar 26, 2009 8:04 am

Re: Help inserting values in MySQL (provided code)

Post by CKEANEDesign »

Nevermind! Found my mistake. I should doublecheck next time. Sorry.

Code: Select all

 
// Insert values into table
mysql_select_db("Users", $con);
$value = "INSERT INTO Accounts (AccountName, FirstName, LastName, Age, City, State, Country) 
VALUES ('Ckeane17', 'Cory', 'Keane', '18', 'Chicago', 'IL', 'United States')";
if (mysql_query($value,$con))
 {
 echo("information inserted");
 }
 else
 {
 echo(mysql_error());
 }
Post Reply