Im trying to use PHP to create a database and its tables and it just aint having it! can anyone tell me wat im doing wrong?
Error:
--------------------------------------------------------------------------------
Warning: Unexpected character in input: ' ' (ASCII=12) state=1 in /home/nemelize/public_html/appy/dbsetup.php on line 46
Warning: Unexpected character in input: ' ' (ASCII=12) state=1 in /home/nemelize/public_html/appy/dbsetup.php on line 54
Warning: Unexpected character in input: ' ' (ASCII=12) state=1 in /home/nemelize/public_html/appy/dbsetup.php on line 62
Warning: Unexpected character in input: ' ' (ASCII=12) state=1 in /home/nemelize/public_html/appy/dbsetup.php on line 70
Access denied for user: '@localhost' to database 'nemelize_nemelization'
--------------------------------------------------------------------------------
Heres my code: I have numbered the lines to make it easier to read.
PHP Code:
32. $dbname = "nemelize_nemelization";
33. $sites_tablename = 'sites';
34. $sites_table_def = "SiteID VARCHAR(4) BINARY NOT NULL AUTO_INCREMENT, ";
35. $sites_table_def .= "SiteTitle TEXT NOT NULL, ";
36. $sites_table_def .= "SiteDescription TEXT NOT NULL, ";
37. $sites_table_def .= "SiteImage VARCHAR(200) NOT NULL, ";
38. $sites_table_def .= "SiteURL VARCHAR(300)NOT NULL, ";
39. $sites_table_def .= "PRIMARY KEY (SiteID)";
40. $logos_tablename = 'logos';
41. $logos_table_def = "LogoID VARCHAR(4) BINARY NOT NULL AUTO_INCREMENT, ";
42. $logos_table_def .= "LogoTitle TEXT NOT NULL, ";
43. $logos_table_def .= "LogoDescription TEXT NOT NULL, ";
44. $logos_table_def .= "LogoImage VARCHAR(200) NOT NULL, ";
45. $logos_table_def .= "LogoURL VARCHAR(300)NOT NULL, ";
46. $logos_table_def .= "PRIMARY KEY (LogoID)";
47. $other_tablename = 'other';
48. $other_table_def = "OtherID VARCHAR(4) BINARY NOT NULL AUTO_INCREMENT, ";
49. $other_table_def .= "OtherTitle TEXT NOT NULL, ";
50. $other_table_def .= "OtherDescription TEXT NOT NULL, ";
51. $other_table_def .= "OtherImage VARCHAR(200) NOT NULL, ";
52. $other_table_def .= "OtherURL VARCHAR(300)NOT NULL, ";
53. $other_table_def .= "PRIMARY KEY (OtherID)";
54. $featured_tablename = 'features';
55. $featured_table_def = "FeaturedID VARCHAR(4) BINARY NOT NULL AUTO_INCREMENT, ";
56. $featured_table_def .= "FeaturedTitle TEXT NOT NULL, ";
57. $featured_table_def .= "FeaturedDescription TEXT NOT NULL, ";
58. $featured_table_def .= "FeaturedImage VARCHAR(200) NOT NULL, ";
59. $featured_table_def .= "FeaturedURL VARCHAR(300)NOT NULL, ";
60. $featured_table_def .= "PRIMARY KEY (FeaturedID)";
61. $link_id = db_connect();
62. if(!$link_id) die(mysql_error());
63. if(!mysql_query("CREATE DATABASE $dbname")) dir(sql_error());
64. echo "Succesfully created database $dbname. <BR>";
65. if(!mysql_select_db($dbname)) die(dql_error());
66. if(!mysql_query("CREATE TABLE $sites_tablename ($sites_tables_def)")) die(sql_error());
67. if(!mysql_query("CREATE TABLE $logos_tablename ($logos_tables_def)")) die(sql_error());
68. if(!mysql_query("CREATE TABLE $other_tablename ($other_tables_def)")) die(sql_error());
69. if(!mysql_query("CREATE TABLE $featured_tablename ($featured_tables_def)")) die(sql_error());
70. echo "Successfully created the $sites_tablename, $logos_tablename, $other_tablename and $featured_tablename tables.";
71. ?>
Help