MySQL Upload Script
Posted by noah (noah), 13 May 2006I have used your script to upload images to a MySQL database, however it doesn't seem to work, I get a little box with an "X" in it and a MySQL error. Any suggestions?
Posted by admin (Graham Ellis), 13 May 2006This is a script that puts together a whole lot of technologies all in the one script, so you need to test and debug section by section, or at the least look at the results on the server when you try to run it but it fails.
My next step in your situation would be to connect into the MySQL database through the MySQL program and check to see whether or not the table had been created, and if it has been corrected whether or not it has the right structure, and if it has the right structure whether it contains rows that look valid.
Looking at your code, I notice that the response page that was on the end of my upload scripts - the HTML generator - is missing. It's also possible that an error in that code (for example the removal of the parameter on the src= in the img tag) would create a problem as you've described it.
Posted by noah (noah), 13 May 2006Thanks, I'll give that a try. I've debugged many times, and most of my scripts fail, I just hoping to fix it. What do you mean about the "img" tag?
Posted by admin (Graham Ellis), 14 May 2006Running your program, I note that you have a warning message that you didn't report on your earlier posts. That's more significant than the broken picture link - you need to fix the problem reported by the messages
Warning: move_uploaded_file(latest.img): failed to open stream: Is a directory in /home/nhwood/public_html/spirf/user/demo.php on line 111
Warning: move_uploaded_file(): Unable to move '/tmp/php4H191S' to 'latest.img' in /home/nhwood/public_html/spirf/user/demo.php on line 111
Which is related to file permissions first - the uploaded image cannot be written to your intermediate directory, and so isn't getting to the database.
My comment aboout the img tag may now be irrelevant.
Posted by noah (noah), 14 May 2006I've ignored that becasue I've gave just about all of the directories 777
Posted by admin (Graham Ellis), 14 May 2006on 05/14/06 at 16:29:06, noah wrote:
Well, it's having a problem writing it, isn't it? Perhaps you've created a directory called latest.img that it can't overwrite with a plain file. Have a careful look at the error message and see what it says - you already have the clue there
[Noah - you may be correct in suggesting that my advise is wrong, but as you hadn't told us that you had already set the file permissions, we were at best shooting in the dark. If you can provide information that's as complete as possible, then we can help as best as possible. And, b.t.w. it's usually counterproductive to be rude to people who give you there time free to make suggestions to help you along, even if a suggestion turns out to NOT be a solution]
Posted by noah (noah), 14 May 2006I didn't mean to be rude, Sorry. I just figured that it would work and I was getting mad at myself. Anyway I have got it to work! Thanks for your help!
Posted by admin (Graham Ellis), 14 May 2006Fair enough ...
WAS it a directory called latest.img by any chance?
Posted by noah (noah), 14 May 2006Yes and no, I did have that directory and removed it, however it still didn't work, I had to make the user directory 777 as well, Thanks a lot!
PH: 01225 708225 • FAX: 01225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho