OK I have a database, games table filled with games and embed field is a directory path. I need a php script that will search my db of 3000 check if the directory or file exits in my /games/ dir. if the file or directory which the file would be in is not there then remove that entity or id or game from my database.
I apologize for not being very descriptive. I was having trouble putting what I would like in words.
any way I am using mysql database. My problem is that I imported 3000 some odd games into my arcade website using a plugin that downloads the game.zip file, extracts the zip and makes a new dir in /games/game-name and changes the embed field in my db to the new location of the game files. the problem lies in an error that the plugin didn't download the game.zip and now I have games in my db that don't have a game dir or file. but the embed says /games/game-name in the db but there is no such dir.
I do hope this clears things up. I was hoping for some guidance because I can not learn enough php to make this on my own at the moment however if I see it I will understand. writing code is much more difficult than reading code for me.
You could use
The PHP Data Objects (PDO) extension to access the games table in your database.
PHP Directory functions and PHP Filesystem functions to list your /games/ dir.
What DB do you use? MySQL? PostgreSQL? SQL Server? Part of the code will change depending on what database are you using
Related
So I have my own webserver now and am hosting a website. I have made a basic screenshot to FTP. It copies the link once uploaded and I'm going to be adding randomized folders e.g /push/eqw8/woeqwe.jpg like puush does.
However, this is not my question. I was wondering how I would be able to grab all folders and images from those folders and create a table like this http://puu.sh/oEyfP/783483492c.png or http://puush.me/account in order from upload date. And then it shows in oderder of date uploaded.
I just wanted to do this because I feel more secure and its a fun project doing it.
How would I get about making this.
can you tell me like what I need to do in words?
I'm not good with web development and only good with languages like c# and such.
Learning php and html atm and its pretty basic but I still need time to learn.
At first it depends on your php skills about how much you can think / do in php.
The main thing you need here to order the files / folders by date or manage them at much professional level , you have to use Mysql database and store Files and Folders information inside the database.
For example , let say you have a Image file extension .jpeg then store it's information about :
Extension File size Parent Folder Uploader id / IP Upload Date Unique random key mime type Random name Original name
And there are many other things you need to consider
Files that are being stored by users should be scanned and non executable from the browser.
Store them in random folders with random names so no body can find the way to the file.
You can use javascript/ ajax for uploading multiple files at the same time.
You can make the files non executable by removing their extensions and saving them inside a folder without their original names and save their original names and extensions inside the database along with random string name and the folder name where it was stored so your system can identify the file and you can show your users the file and then on download you can replace the name with original one along with extension.
this is a one of my projects i have created , if you want you can check it out: Buckty
About any other information you need , you can ask me below in comment.
I am doing something rather complex here (for me at least), and I'm not sure where to look in terms of resources. I don't need anyone to write this for me, maybe just a link where I can find a tutorial?
I have a folder on my website that holds all the articles on that site. I also have a MySql database that holds a table of contents for the articles. Right now I have to manually edit the MySql database every time I upload a new directory. I was wondering if I am able to automate this with PHP.
Each of the articles is a separate subdirectory with an index.html file inside of it, along with any subpages and images. How do I detect when a new article has been uploaded to the main folder, find out the location of said article, as well as read an XML (or JSON? I'm not sure yet, which do you suggest?) file inside the article directory that defines the Name of the article, the data it was created, and other information and log all that to the Mysql Database?
This code must not log an article twice, as the information within the database will be picked up by another script that will display a list of all my articles.
i am wondering if the idea I have is even do-able, or does it need to be thrown away? If it is possible, are there any resources that offer tutorials on things related to this?
I am starting a recruitment consultancy and sooner or later we would be dealing with many applicant résumés or CV (curriculum vitae). I am building a simple application with PHP and MySQL (target server to be windows) to let applicant upload CV on our website. Currently I would be restricting upload files to be only MS Word docs and MAX size 500 KB.
Now my question is around two operations which would be performed on these files.
Search content inside these files on specific key words to find relevant skills matching resumes.
Then serve these files to our employers either through download file link or email the resumes to them.
Coming straight to the questions
Do I store the actual files on File System and perform Windows search on them?
Or I only insert the content in to the MySQL blob/cblob, perform search on the table and then serve the content from the table itself to the employer.
Or I Store the file on File System and also insert the content in mysql blob. Search the content in mysql and serve the file from File System.
I am of the opinion that once the number of résumés reaches thousands, the Windows search would be extremely slow but then I search on internet and find that it is not advisable to store huge amount of file contents in a database.
So I just need your suggestion on the approach I should adopt in light of the assumption that at some point of time we would be storing and retrieving thousands of resumes.
Thanks in advance for your help.
One option, a hybrid: Index the resumes into a db, but store a filesystem path as the location. When you get a hit in the db and want to retrieve the resume, get it off the file system via the path indicated in the db.
What you want is a fulltext index of the documents. This tends to be a job for e.g. Solr (see this cross reference on StackOverflow: How do I index documents in Solr). The database would keep a reference to the file on the disk. You should not try to save blob data to an innodb table that does not run on the barracuda format using row_format=dynamic. Please refer to the MySQL performance blog for further details on the Blob storage in innodb topic.
A friend of mine told me that saving images in the database is not much of a good idea. Instead save it to the directory and then save it's name in the database and when I want to display the images in the browser I'm just going to use the name in the database to find the picture. Can anyone please guide me on how to do this starting from scratch?
Any help would be much appreciated.
By the way I am using php and MySQL.
Do two things:
accept more answers, here's how: https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work
read this tutorial: http://articles.sitepoint.com/article/php-gallery-system-minutes
What is it exactly that you don't know how to do? Your question seems to contain its own answer:
set up a directory for images, accessible to your web server
copy some image files in there
go to phpmyadmin and create a table with a filename field, for example of type varchar 100
store the image filenames in the table
write a php script that fetches image names and displays the HTML to load the images
What is the best way to store documents that saves space? By letting user documents to be stored in phpmyadmin db or by creating folders and letting user upload documents there?
I want to allow scans like pdf and images and also word docs and .txt files.
Also, how will i go about uploading documents? Any tutorials i can use? New to this.
Thanks!
phpmyadmin, is an script that lets you edit\add\etc mysql db's its not a db. Depending on the type of documents, and what you plan to do with them I would always say store them in the file system, you can store there name\path in the db.
file upload tutorial: Handling file uploads