gotornot Posted September 21, 2009 Share Posted September 21, 2009 $delq = "DELETE FROM '$tablename' WHERE id='$id'"; will this work? Quote Link to comment Share on other sites More sharing options...
p2grace Posted September 21, 2009 Share Posted September 21, 2009 Yes... as long as you execute the query Quote Link to comment Share on other sites More sharing options...
gotornot Posted September 21, 2009 Author Share Posted September 21, 2009 hmm its not inserting Quote Link to comment Share on other sites More sharing options...
p2grace Posted September 21, 2009 Share Posted September 21, 2009 Inserting? It's not an insert query. Quote Link to comment Share on other sites More sharing options...
gotornot Posted September 21, 2009 Author Share Posted September 21, 2009 i know sorry i meant deleting but if i replace the variable $tablename with the table it works Quote Link to comment Share on other sites More sharing options...
p2grace Posted September 21, 2009 Share Posted September 21, 2009 Are you cleaning the $tablename? $tablename = mysql_real_escape_string($tablename); If it doesn't work, echo mysql_error(); to determine the issue. Quote Link to comment Share on other sites More sharing options...
Alex Posted September 21, 2009 Share Posted September 21, 2009 i know sorry i meant deleting but if i replace the variable $tablename with the table it works You don't need quotes around the table name. $delq = "DELETE FROM $tablename WHERE id='$id'"; $result = mysql_query($delq); echo ($result) ? 'Success' : "Error: " . mysql_error(); Quote Link to comment Share on other sites More sharing options...
5kyy8lu3 Posted September 21, 2009 Share Posted September 21, 2009 $delq = "DELETE FROM '$tablename' WHERE id='$id'"; will this work? as far as I knew, variables don't show up inside single quotes. this is how I make queries (lots of ways of doing it, this is my method) $delq = 'DELETE FROM ' . $TableName . ' WHERE id="' . $id . '"'; try that, i think your variable isn't pasting into the query because you're using single quotes Quote Link to comment Share on other sites More sharing options...
p2grace Posted September 21, 2009 Share Posted September 21, 2009 $delq = "DELETE FROM '$tablename' WHERE id='$id'"; will this work? as far as I knew, variables don't show up inside single quotes. this is how I make queries (lots of ways of doing it, this is my method) $delq = 'DELETE FROM ' . $TableName . ' WHERE id="' . $id . '"'; try that, i think your variable isn't pasting into the query because you're using single quotes In this case the variable will show up within the single quotes because it's wrapped by double quotes. $delq = "DELETE FROM '$tablename' WHERE id='$id'"; will this work? as far as I knew, variables don't show up inside single quotes. this is how I make queries (lots of ways of doing it, this is my method) $delq = 'DELETE FROM ' . $TableName . ' WHERE id="' . $id . '"'; try that, i think your variable isn't pasting into the query because you're using single quotes In this case the variable will display within the single quotes because it's wrapped within a double quote. AlexWD is correct that the single quotes are the problem. 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.