frobak Posted March 9, 2009 Share Posted March 9, 2009 Hi Im trying to write a very simple script that creates a php file that logs a download in a database. Basically, the user will upload some audio and I want to use fopen to automatically create a download counter. I get the file created ok, but my $sql, $result & $connection are stripped and not written, so the queries wont run. Is there anyway to escape this, so it writes the variables. Heres the code: <?php $file = "downloads/pbz99.php"; $open = fopen($file, "w+"); fwrite($open,"<?php include ('functions/db_fws_connect.inc.php'); $sql = 'INSERT INTO `frobakco_fwsapps`.`downloadcount` (`downloadcountid`, `downloadid`) VALUES (NULL, '99')'; $result = @mysql_query($sql,$connection) or die(mysql_error());?> <html><head><title>DJ Neil S audio download page</title></head><body><a href='../mixes/.$filename.mp3'></a></body></html>"); ?> any ideas Link to comment https://forums.phpfreaks.com/topic/148666-using-fopen-to-write-a-sql-query/ Share on other sites More sharing options...
corbin Posted March 9, 2009 Share Posted March 9, 2009 You're going about this entirely the wrong way. Have 1 page that serves different files based on dynamic input (GET) instead of having different pages. Link to comment https://forums.phpfreaks.com/topic/148666-using-fopen-to-write-a-sql-query/#findComment-780685 Share on other sites More sharing options...
frobak Posted March 9, 2009 Author Share Posted March 9, 2009 ok, any chance you can kind of point me in the right direction? Link to comment https://forums.phpfreaks.com/topic/148666-using-fopen-to-write-a-sql-query/#findComment-780688 Share on other sites More sharing options...
corbin Posted March 9, 2009 Share Posted March 9, 2009 Uhhhh.... Form the query off of the input value. Then, pull the corrosponding data from the database. Link to comment https://forums.phpfreaks.com/topic/148666-using-fopen-to-write-a-sql-query/#findComment-780698 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.