473,394 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Removing files into a MySQL database using PHP

Hi,

First off I am self learning PHP and MYSQL, which I saw your guide on "Uploading files into a MySQL database using PHP" and this was great guide and responses that had came through.

My question is how do I now remove files from the guide that you have created above,

thanks
Mar 14 '12 #1
12 1804
Dormilich
8,658 Expert Mod 8TB
delete them from the database (using a DELETE query and passing the PK).
Mar 15 '12 #2
Hi Dormilich,
Sorry is PK the primary key?

how would I go about this as I was thinking to create the delete file that is linked in the list_files.php so that when open I can then view the files that I want to download or delete.

thanks for the reply
Mar 15 '12 #3
Dormilich
8,658 Expert Mod 8TB
Sorry is PK the primary key?
correct.

the delete file should do just this, delete the chosen entry from the DB.
all you need in the list_files.php is a link/form that calls the delete script passing it the ID (PK) of the file to be deleted.
Mar 15 '12 #4
Hi again,

I already have linked the delete_file.php to the list_files.php

as for the delete page the code I have done is this:

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. $dbLink = new mysqli('', '', '', '');
  3. if(mysqli_connect_errno()) {
  4. die("MySQL connection failed: ". mysqli_connect_error());
  5.  
  6. $query = "DELETE FROM file WHERE id = ('$id')"; 
  7.  
  8. $result = mysql_query($query); 
  9.  
  10. echo "The data has been deleted."; 
  11. ?>  
which this code said it has deleted but I can still see it on my list files and my database.

thanks for the reply
Mar 15 '12 #5
Dormilich
8,658 Expert Mod 8TB
compare lines #2 and #9. doesn't anything jump to the eye?

PS. enable error reporting/display.
Mar 15 '12 #6
in line two I added have my details and connects to the database, in line nine it executes the query? and finally, how do i enable reporting/display as I am using dreamweaver CS5.5 and PHPMYADMIN
Mar 15 '12 #7
Dormilich
8,658 Expert Mod 8TB
in line two I added have my details and connects to the database, in line nine it executes the query?
and now compare what you have written.

and finally, how do i enable reporting/display
this way. and in the runtime configuration.
Mar 15 '12 #8
Hi,

I am still having the same problem and there is no error detected as far as my friend and has found out for me.

I don't want to be a burden but could you provide the code with comments so that I can understand it and also see where I went wrong please

e.g. I have notice that in line nine I left out the "i" in "mysql_query" however I though this will be the same way as the get_file.php but it removes it.
Mar 15 '12 #9
Dormilich
8,658 Expert Mod 8TB
e.g. I have notice that in line nine I left out the "i" in "mysql_query" however I though this will be the same way as the get_file.php but it removes it.
what get_file.php? (note: I check against Atli's original post)

and that is exactly the point where you have the problem. the mysql extension is in no way compatible to the mysqli extension (though they share a similar, but distinct syntax), i.e. you can't expect mysql run from mysqli (and vice versa). and not having a mysql connection open certainly causes an error when trying to use mysql_query().
Mar 15 '12 #10
Hi,

what I had done is that I made an error on the extension now corrected.

what I want to achieve is that from Atli's post he had done:

form - to upload file
add_file.php - that adds the file to the database
list_files.php - to view the list of files and to download the file
get_file.php - is to gather the data shown in list_files.php

what I want to do is also to include in list_files.php is to delete file.
Mar 15 '12 #11
as you can see in phase three line 37 get_file.php is stated
Mar 15 '12 #12
Hi again,

I was looking at the list-files.php and I was wondering that the headers bring the data forward could i then use "unlink" to remove the file from the database or I did not understand the download phase.
Mar 15 '12 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: menmysql | last post by:
i am getting the following error while connecting mysql database using jsp java.sql.SQLException: Communication link failure: Bad handshake can any one tell what is the actual problem
8
by: menmysql | last post by:
i am not bale to solve this problem since two weeks i am trying to access records from mysql database using jsp. inside this jsp program i wrote all my JDBC code. it is working very nicely and...
9
by: christopher_board | last post by:
Hi all. I am trying to connect to a MySQL Database using PHP on a local machine using locahost. I am using the following code <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass =...
2
by: zalina | last post by:
hai..does anyone have example how to connect to mysql database using c++ language?
1
by: ganeshg | last post by:
Hai All, Please let me know how to insert audio files into mysql database using .net. Thanking you.....
3
by: Suresh P | last post by:
Hi All, I tried to access the mysql database in ODBC using ip address and username/password. It returns, "cannot connect to MySQL server on IP ADDRESS(10060)". This could be related to Firewall...
1
by: nadeenahmed | last post by:
I have Connected to a MySQL Database using a neatbeans editor. Now, I want to use that same database I created earlier on another pc. Can anyone help and tell me how that is done, please? Thank...
6
by: mfaisalwarraich | last post by:
Hi everyone, I am trying to add multiple pinpoint to google map using Lon/Lat. All addresses will be fetched from mysql database using PHP. I have looked at google and searched for it on...
1
by: santhanalakshmi | last post by:
Hi, I wrote some coding, to import excel data in mysql database using PHP Script? But my script, its not all inserting the excel data in mysql database. I don't know, what mistake did i made?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.