Jump to content

using fopen to write a sql query


frobak

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.