Christianboygenius Posted March 10, 2010 Share Posted March 10, 2010 <?php $user="********"; $password="******"; $database="************"; $title=$_POST['title']; $keywords=$_POST['keywords']; $desc=$_POST['desc']; $category=$_POST['category']; $url=$_POST['url']; mysql_connect(sql313.000space.com,$user,$password); @mysql_select_db($database) or die("Oops! We cannot connect to the database at this time."); $query="INSTERT INTO roms VALUES ('','$title','$keywords','$desc','$category','$url')"; mysql_query($query); mysql_close(); ?> I have the table already set up and I hope that it can connect right. I just don't know why it is not inserting the values into the actually table. I'm really bad Sorry. My host is 000space.com and I used PhpMyAdmin to set up the database. I have basically everything set up, just can't get the code right. Thanks for your help! Christianboygenius Quote Link to comment Share on other sites More sharing options...
schilly Posted March 10, 2010 Share Posted March 10, 2010 <?php $user="********"; $password="******"; $database="************"; $title=$_POST['title']; $keywords=$_POST['keywords']; $desc=$_POST['desc']; $category=$_POST['category']; $url=$_POST['url']; mysql_connect("sql313.000space.com",$user,$password); @mysql_select_db($database) or die("Oops! We cannot connect to the database at this time."); $query="INSTERT INTO roms (title,keywords,desc,category,url) VALUES ('$title','$keywords','$desc','$category','$url')"; mysql_query($query) or die("ERROR: $query - " . mysql_error()); mysql_close(); ?> Note your db hostname is quotes. Also you need to define your fields in the INSERT query. Change (title,keywords,desc,category,url) to whatever your fields are name in your table. You don't need to input the id if it is auto incremented. I assumed that was the blank '' you had in your query. Quote Link to comment Share on other sites More sharing options...
litebearer Posted March 10, 2010 Share Posted March 10, 2010 also (may be just a typo here but...) INSTERT should be INSERT Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.