PHP try and find the one missing thing!

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

ste19841
New php-forum User
New php-forum User
Posts: 1
Joined: Sat Dec 28, 2013 4:58 am

PHP try and find the one missing thing!

Postby ste19841 » Sat Dec 28, 2013 5:04 am

Hello all,

I have managed to connect my webpage to MySQL but I cannot manage to select any information from my database or insert a table into it. It seems like it is connected but not actually speaking to the database. For instance my code below is throwing up no errors but will not create the table I am asking it to. Any ideas what is wrong with this code?

<?php
$link = mysql_connect('localhost:3306', 'user_admin', 'password', 'mydatabase_databasename');
if (!$link) {
die('Could not connect: ' . mysql_error());
mysql_select_db("mydatabase_databasename" , $link);
}
echo 'connected';
$sql = "CREATE TABLE USERS2
(
ID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(ID),
Username varchar (20),
Password Varchar (20),
First Varchar (20),
Last Varchar (20)
)
";
mysql_query($sql, $link);
?>

Return to “PHP coding => General”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest