This is a classified ads table which contains all the item's information.
The item's "id" is received on this delete page using
. It's being sent by - delete_picture.php?id=$id
A query takes place which grabs the image_name from the database based on the id. Then it unlinks the images in the image/ and image/thumbs folders with this image_name. So the id variable is working, at least to this point.
Then it is suppose to perform this delete query: - $sql = "DELETE image_name,b_width,b_height,t_width,t_height
-
FROM ads WHERE id='".$id."'";
-
$result = mysql_query($sql);
But this part is not working. Is there any obvious reason why?
6 1745 dlite922 1,584
Recognized Expert Top Contributor
Ya you're delete is wrong.
See Manual: http://dev.mysql.com/doc/refman/5.0/en/delete.html
From what it looks like, you seem to select the image fields of the ads table to hopefully just delete those columns, and not the entire record.
That's now how MySQL works, a record must always have the same number of fields as the table allows although they can contain nothing (empty string, or NULL value)
Remember, Sanitize your inputs if I were to call your delete.php file like so
delete.php?id=1 ';DELETE FROM ads;
what do you think will happen? SQL Injection.
Good luck,
Dan
Markus 6,050
Recognized Expert Expert @DavidPr
Add 'or die(mysql_error ());' to your mysql query to see if you a generating any errors. -
$result = mysql_query(...) or die(mysql_error());
-
How would I sanitize that?
original
$sql = "DELETE image_name,b_wi dth,b_height,t_ width,t_height
FROM ads WHERE id='".$id."'";
$result = mysql_query($sq l);
your delete query is wrong
may be -
-
$sql = "DELETE FROM ads WHERE id='".$id."' ";
-
$result = mysql_query($sql);
-
-
I found that UPDATE worked better than DELETE in this instance. - $name = $_POST['name'];
-
$address1 = $_POST['address1'];
-
$address2 = $_POST['address2'];
-
$phone = $_POST['phone'];
-
$cell = $_POST['cell'];
-
-
// variables may have a value or they may be empty
-
-
query="UPDATE address_book SET
-
name='$name',
-
address1='$address1',
-
address2='$address2',
-
phone='$phone',
-
cell='$cell'
-
WHERE id='$id'";
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Andrew DeFaria |
last post by:
I created the following .sql file to demonstrate a problem I'm having.
According to the manual:
If |ON DELETE CASCADE| is specified, and a row in the parent table
is deleted, then InnoDB automatically deletes also all those rows in
the child table whose foreign key values are equal to the referenced
key value in the parent row.
However:
|
by: Stephen |
last post by:
I have got an event below to remove items from an arraylist and then to
rebind the arraylist to the datagrid subsequently deleting the appropriate
row. My problem is that my code makes sense and I think my logic seems fine
but when I click the button on my datagrid nothing seems to happen. Have you
any idea where Im going wrong. Was thinking it might have something to do
with my page load/ postback but not really sure. Can someone please...
|
by: Darin |
last post by:
I have a table that I want to delete specific records from based on
data in other tables. I'm more familiar with Access '97, but am now
using 2003, but the database is in 2000 format. In '97, I think I
could have easily done this using joins, but I kept getting "could not
delete from specified tables" errors. Some google searching has
indicated I need to use a subquery. After many failed attempts with
different approaches, I finally...
|
by: Wannabe |
last post by:
I am using ASP.Net 2.0 and have a gridview on my page. I have everything
working except the delete command. The page reloads except the row I am
trying to delete is still there. I believe it is something really easy, but I
cannot see it. The stored procedue works when run in QA. Can someone tell me
what I am doing wrong/missing that is keeping the delete command from working
in the gridview? Thank you.
I am trying to delete a row out of...
|
by: Anil Gupte |
last post by:
Private Sub mnu2Exit_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnu2Exit.Click
Dim fDir As String = Path.GetDirectoryName(L3Global.VideoFileName)
File.Delete(L3Global.VideoFileName)
' The following is not working - reports directory not empty exception
' Directory.Delete(fDir)
| |
by: Jon Slaughter |
last post by:
Is it safe to remove elements from an array that foreach is working on?
(normally this is not the case but not sure in php) If so is there an
efficient way to handle it? (I could add the indexes to a temp array and
delete afterwards if necessary but since I'm actually working in a nested
situation this could get a little messy. I guess I could set there values to
null and remove them afterwards?
Thanks,
Jon
|
by: Premal |
last post by:
Hi,
I tried to make delete operator private for my class. Strangely it is
giving me error if I compile that code in VC++.NET. But it compiles
successfully on VC++6.o. Can anybody give me inputs about it. I wanted
that on my class delete should not work. Object pointer should be
deleted using my function only which is taking care of reference count
for particular class.
Thanx in advance for your inputs.
|
by: Will |
last post by:
Can someone help with code to delete multiple columns from an excel
spreadsheet? I know which columns I need to delete. The code below will
delete a single column but I'm not sure how to delete multiple columns. I'm
tried experimenting with Dim rg As Excel.Range = xlSheet.Columns("B, D, G,
K, L") but no joy. Thanks in advance
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
|
by: busterbaxter |
last post by:
Hi All,
I got a multiple delete working here but for some reason I occassionally get this error. The way the delete works is there is a text box where the user enters the quantity to delete. If it is blank it will delete 1 item. It never fails when I delete just 1 item but if I delete more than one item it fails but only some times. Here is the error:
"Run-time error '2046':
The command or action 'DeleteRecord' isn't available now."...
|
by: wangers16 |
last post by:
I have the following code in my website and it is supposed to delete a user account along with all associated records, however it doesn't delete any of the records, the function is working, beacuse I also have a logout function that gets called afterwards that is working, it just seems to be skipping the delete commands.
Here is my code:
function delacc(){
$retrievedusr = $_COOKIE;
$dsql1 = "DELETE FROM mpw_3_5_test_dbase_users...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |