Jump to content

will this work


gotornot

Recommended Posts

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
Share on other sites

$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
Share on other sites

$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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.