Jump to content

Problems using PHP/MySql on a host server


John V

Recommended Posts

Hi,

 

I'm very new to PHP/MySql and this is probably a complex question with a very simple answer.  I have two hosts, godaddy and hostican and have the identical problem on both.  I've successfully set up a database with tables.  I've inserted data into the table.  But I've done this all through cPanels.  When I try to do it through PHP the script seems to work but the results (new tables, inserted data) doesn't show up when I go back to cPanels and look for them.

 

Here is the code (I don't know how to get the bbcode buttons in, sorry!):

 

<?php

//Connect To Database

$hostname='xxxx';

$username='xxxx';

$password='xxxx';

$dbname='xxxx';

$usertable='xxx';

$yourfield = 'xxxx';

 

mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');

echo "Connected to MySQL<br />";

mysql_select_db($dbname);

echo "Connected to Database<br />";

 

// Attempt to insert something into database

$query="INSERT INTO `comments` (`day`, `name`, `email`, `url`, `comment`)

VALUES ('2007-21-12', 'Nancy Vogel', 'sathren@gmail.com', 'faasdkl.com', 'thisasdfa test')"

or die(mysql_error()); 

 

 

echo "Data Entered!";

 

?>

 

And here is the output:

 

Connected to MySQL

Connected to Database

Data Entered!

 

Thanks for any help you can give me!

Link to comment
Share on other sites

$query="INSERT INTO `comments` (`day`, `name`, `email`, `url`, `comment`)
VALUES ('2007-21-12', 'Nancy Vogel', 'sathren@gmail.com', 'faasdkl.com', 'thisasdfa test')"
or die(mysql_error());  

 

should be

 

$query=mysql_query("INSERT INTO `comments` (`day`, `name`, `email`, `url`, `comment`) VALUES ('2007-21-12', 'Nancy Vogel', 'sathren@gmail.com', 'faasdkl.com', 'thisasdfa test')")
or die(mysql_error());  

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.