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
https://forums.phpfreaks.com/topic/194811-help-me/
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
https://forums.phpfreaks.com/topic/194811-help-me/#findComment-1024364
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.