I have this Upload Script and I want it so that whenever I upload something it will automatically update some data in a mysql database.
Here is the code for the upload script. It comes in 2 pages.
<!-- m --><a class="postlink" href="http://www.skafreaksonline.com/ArtistLog/upload.txt">http://www.skafreaksonline.com/ArtistLog/upload.txt</a><!-- m -->
<!-- m --><a class="postlink" href="http://www.skafreaksonline.com/ArtistLog/upload1.txt">http://www.skafreaksonline.com/ArtistLog/upload1.txt</a><!-- m -->
I have it setup right now within a login script. Someone will be logged in and the username will equal $artist. So then I want to do
UPDATE nuke_ska_artists SET artpicture='$filename' WHERE artist='$artist'
But everytime I try it, it doesnt work. I've tried putting it in a few different places, and tried using $filename & $upload->file['name'] but nothing works.
Any help on figuring this out would be appreciated!
THANKS!you can't just put an SQL query into a script like that...
you need to have an open connection to the database, and then use the mysql_query function:
$cnxn = mysql_connect(host, user, password);
mysql_select_db(database, $cnxn);
mysql_query("UPDATE nuke_ska_artists SET artpicture='$filename' WHERE artist='$artist'", $cnxn);
mysql_close($cnxn);
host, user, password and database are probably gloabl variables stored in your scripts already.i had all of that in there, i just took it out when i posted it up. im not sure if there is a certain place to put it.Thank you & nevermind. I figured it out when you posted that last post. i realized I was leaving a piece out.
Thanks!
Here is the code for the upload script. It comes in 2 pages.
<!-- m --><a class="postlink" href="http://www.skafreaksonline.com/ArtistLog/upload.txt">http://www.skafreaksonline.com/ArtistLog/upload.txt</a><!-- m -->
<!-- m --><a class="postlink" href="http://www.skafreaksonline.com/ArtistLog/upload1.txt">http://www.skafreaksonline.com/ArtistLog/upload1.txt</a><!-- m -->
I have it setup right now within a login script. Someone will be logged in and the username will equal $artist. So then I want to do
UPDATE nuke_ska_artists SET artpicture='$filename' WHERE artist='$artist'
But everytime I try it, it doesnt work. I've tried putting it in a few different places, and tried using $filename & $upload->file['name'] but nothing works.
Any help on figuring this out would be appreciated!
THANKS!you can't just put an SQL query into a script like that...
you need to have an open connection to the database, and then use the mysql_query function:
$cnxn = mysql_connect(host, user, password);
mysql_select_db(database, $cnxn);
mysql_query("UPDATE nuke_ska_artists SET artpicture='$filename' WHERE artist='$artist'", $cnxn);
mysql_close($cnxn);
host, user, password and database are probably gloabl variables stored in your scripts already.i had all of that in there, i just took it out when i posted it up. im not sure if there is a certain place to put it.Thank you & nevermind. I figured it out when you posted that last post. i realized I was leaving a piece out.
Thanks!