Vivid Lust Posted September 3, 2008 Share Posted September 3, 2008 Here's part of a piece of code where I check if a table exists, if it doesn't then it creates it, if(!(mysql_query("SELECT * FROM $seller"))) { //doesn't exist then... $sql2 = "CREATE TABLE p" . $id . "( id int(6) primary key NOT NULL auto_increment, `site` VARCHAR( 30 ), `ts` TIMESTAMP( 50 ), `success` VARCHAR( 5 ) )"; mysql_query( $sql2, $link ) or die( mysql_error() ); } else{ //does exist then... echo "already exists!!"; } The problem is that the script keeps on echoing "Table 'p1' already exists" (as the $id = 1); and it doesn't echo "already exists!!" like I want it to... Any help on fixing this??? Thanks! Quote Link to comment Share on other sites More sharing options...
discomatt Posted September 3, 2008 Share Posted September 3, 2008 Can we make the assumption that $seller = 'p'.$id ? If not, I really don't get what your script is doing. Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted September 3, 2008 Share Posted September 3, 2008 I have to question why you'd want to create a new table for each ID. You almost certainly shouldn't be doing this. You might want to read up on database normalisation. Quote Link to comment Share on other sites More sharing options...
Vivid Lust Posted September 3, 2008 Author Share Posted September 3, 2008 I changed seller to id (as it was meant to be that XD); although still the same thing happens :s And id, as in user id... help? Quote Link to comment Share on other sites More sharing options...
discomatt Posted September 3, 2008 Share Posted September 3, 2008 Echo your query and try it in the SQL console. Make sure the query is as you expect. Quote Link to comment Share on other sites More sharing options...
Vivid Lust Posted September 3, 2008 Author Share Posted September 3, 2008 Yeah, query works Quote Link to comment Share on other sites More sharing options...
discomatt Posted September 3, 2008 Share Posted September 3, 2008 Both? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.