Vivid Lust Posted August 26, 2008 Share Posted August 26, 2008 Ok, heres the following script which I have written: <form method="post" action="addfeedback.php"> Seller Name<br /> <input type="text" name="seller" /><br /><br /> Feedback Rating<br /> <select name="select"> <option value="Select" name="s_elect">Select</option> <option value="Positive" name="positive">Positive</option> <option value="Neutral" name="neutral">Neutral</option> <option value="Negative" name="negative">Negative</option> </select><br /><br /> Feedback<br /> <textarea name="feedback" cols="45" rows="5"></textarea><br /><br /> <input type="subMit" value="Send Feedback" /> </form> <?php //get database info $dbhost = 'localhost'; $dbuser = '--'; $dbpass = '--'; //connect to mysql $link = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); //get form data $seller = $_POST['seller'];; $select = $_POST['select']; $feedback = $_POST['feedback']; //connect to database mysql_select_db(deazysse_ebay,$link) or die ('Error connecting to mysql') or die(mysql_error()); //checks if table exists (checks if seller exists also) $check = mysql_query('SELECT * FROM $seller LIMIT 0,1'); if ($check){ //if the seller does exist do this... echo "table exists"; }else{ //if the seller doesn't exist do this... mysql_query("create table $seller ('id' int() primary key auto_increment, 'rating' varchar(30), 'feedback' varchar(250))"); echo "didnt exist, now created"; echo $seller; } ?> The problem is that when submitting the form with any information, I get: didnt exist, now createdtest Which I should expect to get if the table didnt already exist and now has been made. However there is no table created in my database. Any help please? Thanks loads if you can help! Link to comment https://forums.phpfreaks.com/topic/121374-creating-database-problem-php-not-mysql/ Share on other sites More sharing options...
Mchl Posted August 26, 2008 Share Posted August 26, 2008 Does your $dbuser have privileges to create tables? Use if (!mysql_query("create table $seller ('id' int() primary key auto_increment, 'rating' varchar(30), 'feedback' varchar(250))")) { echo mysql_error(); } to echo any errors occuring when running this query. Link to comment https://forums.phpfreaks.com/topic/121374-creating-database-problem-php-not-mysql/#findComment-625797 Share on other sites More sharing options...
Vivid Lust Posted August 26, 2008 Author Share Posted August 26, 2008 Thanks, i got this error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''id' int() primary key auto_increment, 'rating' varchar(30), 'feedback' varchar(' at line 1didnt exist, now I dont know what it means tho... anyone help? XD Link to comment https://forums.phpfreaks.com/topic/121374-creating-database-problem-php-not-mysql/#findComment-625798 Share on other sites More sharing options...
Mchl Posted August 26, 2008 Share Posted August 26, 2008 Try using ` insted of ' around column names Link to comment https://forums.phpfreaks.com/topic/121374-creating-database-problem-php-not-mysql/#findComment-625810 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.