Jump to content

$Database Question....


sports

Recommended Posts

Hi there,
In a .php file, when you see the $database variable, and I have a database created called _inv, what do you put here? I tried _inv, and also tried mydomain_inv.

Here is the php file text:

<?
$username="username";
$password="password";
$database="your_database";

$first=$_POST['first'];
$last=$_POST['last'];
$phone=$_POST['phone'];
$mobile=$_POST['mobile'];
$fax=$_POST['fax'];
$email=$_POST['email'];
$web=$_POST['web'];

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query = "INSERT INTO contacts VALUES ('','$first','$last','$phone','$mobile','$fax','$email','$web')";
mysql_query($query);

mysql_close();
?>


I am trying to use a Front Page form to write to the db using the php file.
Here is the Form Text:

<form action="insert.php" method="post">
First Name: <input type="text" name="first"><br>
Last Name: <input type="text" name="last"><br>
Phone: <input type="text" name="phone"><br>
Mobile: <input type="text" name="mobile"><br>
Fax: <input type="text" name="fax"><br>
E-mail: <input type="text" name="email"><br>
Web: <input type="text" name="web"><br>
<input type="Submit">
</form>

Can anyone assist me?
Regards,
Rob
Link to comment
Share on other sites

What are you using to edit the MySQL tables? It should say in there what the name of the database is. If it is, in fact, "_inv", then that's all you should have to put in there.

Remove the @ symbol from the mysql_select_db() function and see if you get any errors.
Link to comment
Share on other sites

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
I tried _inv, and also tried mydomain_inv.
[/quote]

it should be mydomain_inv but, it is only up to the first 8 letters, so for instance, if your domain was abc.com then it would be abc_inv but if it was something longer like reallylongurl.com then it would actually be reallyl_inv
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.