Jump to content

Help me!!


Recommended Posts

<?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

Link to comment
Share on other sites

<?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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.