Jump to content

John V

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Everything posted by John V

  1. 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', '[email protected]', '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!
  2. I tried that and a whole bunch of things, but still can't get it to work
  3. Hi, I'm trying to create a table in PHP. I can use phpmyadmin to do it but I can't create it in PHP. I even copied the code generated in phpmyadmin and it still didn't work. Here is the code I wrote: <?php mysql_connect("localhost", "familyon_john", "woosha") or die(mysql_error()); echo "Connected to MySQL<br />"; mysql_select_db("familyon_blog") or die(mysql_error()); echo "Connected to Database"; // Create a MySQL table in the selected database $query="CREATE TABLE `familyon_blog`.`test3` ( `day2` DATE NOT NULL , `age` INT NOT NULL , `name` VARCHAR( 7 ) NOT NULL , PRIMARY KEY ( `day2` ) ) TYPE=MyISAM" or die(mysql_error()); echo "Table Created!"; ?> This is the code I copied from phpmyadmin: CREATE TABLE `familyon_blog`.`test` ( `home` VARCHAR( 20 ) NOT NULL , `address` VARCHAR( 30 ) NOT NULL ) ENGINE = MYISAM I looked at the post by Drags111 and incorporated those changes, but it still didn't work. Here is the output I get when I run the script: Connected to MySQL Connected to DatabaseYou have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 7 Thanks for any help you can give me!
×
×
  • 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.