Jump to content

[SOLVED] A simple question


npsari

Recommended Posts

How can i delete a specific row from a mySQL table

I want to delete Image2 (or make the value of it is nothing, NULL)

 

<?php

$con = mysql_connect("localhost","name","password");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("npsari_other", $con);

 

mysql_query("DELETE Image2 FROM ads WHERE ID='$ID'");

 

mysql_close($con);

 

?>

 

Is this code right, because it doesnt work

Link to comment
Share on other sites

<?php
$con = mysql_connect("localhost","name","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("npsari_other", $con);

mysql_query("DELETE FROM ads WHERE ID='$ID'");

mysql_close($con);

?> 

 

That would delete the row where the id = $id. I'm not sure what the "Image2" part is referring too?

Link to comment
Share on other sites

Hey Thorpe...

 

ID and Image2 come from a link (They work fine)

 

hmm, does it have to do with this:

 

mysql_query("UPDATE ads SET Image1= '$Image2' WHERE ID = '$ID'");
mysql_query("DELETE Image2 FROM ads WHERE ID='$ID'");

 

Because I rename Image1 to Image2 just before i delete Image2

Link to comment
Share on other sites

Sorry, didn't notice that. Mutley was right, your query should be....

 

mysql_query("DELETE FROM ads WHERE ID='$ID'");

 

However, unless you have register_globals enabled (which you should'nt) you'd need to change it to....

 

mysql_query("DELETE FROM ads WHERE ID='{$_GET['ID']}'");

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.