gotornot Posted September 21, 2009 Share Posted September 21, 2009 $delq = "DELETE FROM '$tablename' WHERE id='$id'"; will this work? Link to comment https://forums.phpfreaks.com/topic/175031-will-this-work/ 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 Link to comment https://forums.phpfreaks.com/topic/175031-will-this-work/#findComment-922456 Share on other sites More sharing options...
gotornot Posted September 21, 2009 Author Share Posted September 21, 2009 hmm its not inserting Link to comment https://forums.phpfreaks.com/topic/175031-will-this-work/#findComment-922462 Share on other sites More sharing options...
p2grace Posted September 21, 2009 Share Posted September 21, 2009 Inserting? It's not an insert query. Link to comment https://forums.phpfreaks.com/topic/175031-will-this-work/#findComment-922464 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 Link to comment https://forums.phpfreaks.com/topic/175031-will-this-work/#findComment-922473 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. Link to comment https://forums.phpfreaks.com/topic/175031-will-this-work/#findComment-922476 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(); Link to comment https://forums.phpfreaks.com/topic/175031-will-this-work/#findComment-922478 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 Link to comment https://forums.phpfreaks.com/topic/175031-will-this-work/#findComment-922563 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. Link to comment https://forums.phpfreaks.com/topic/175031-will-this-work/#findComment-922573 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.