How to generate unique codes in PHP?

Where do I put down the codes that create a talbe in mysql using php?

  • Do I create a new php file and name it with anything I want, then input the codes (below) "in" the php file? A table should be created in mysql after I save this php file? <?php // Make a MySQL Connection mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); mysql_select_db("test") or die(mysql_error()); // Create a MySQL table in the selected database mysql_query("CREATE TABLE example( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), age INT)") or die(mysql_error()); echo "Table Created!"; ?>

  • Answer:

    yeah, you should create a file with a php extension and just paste this code there. I have made some corrections... <?php // Make a MySQL Connection $con=mysql_connect("localhost", "admin", "1admin") or die(mysql_error()); mysql_select_db("test",$con) or die(mysql_error()); // Create a MySQL table in the selected database mysql_query("CREATE TABLE example( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), age INT)",$con) or die(mysql_error()); echo "Table Created!"; ?>

Mohammed at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

You can get http://stringsofsound.com/ to build your website for you, they built mine ( http://universityreviews.ca) for a great price and I am really happy with the result.

ari

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.