View Single Post

   
  #1 (permalink)  
Old 05-05-2008, 05:51 AM
Geoff Cox
 
Posts: n/a
Default code OK for large number of hits?

Hello,

I have a site with 7 pages, on each of which users answer 4 questions.
The answers are submitted using AJAX and the php code below into a
MySQL database.

There is a possibility that the site may get mentioned on the radio
which could result in a high number of users accessing the site in a
short period of time.

Are there are any precautions I need to take re the adding of the data
to the database? Is the code below adequate?

Thanks

Geoff

@require(dirname(__FILE__) . '/../../../config/config.php');

$result1 = $_GET['answer1'];
$result2 = $_GET['answer2'];
$result3 = $_GET['answer3'];
$result4 = $_GET['answer4'];

mysql_connect($conf['sql']['host'], $conf['sql']['user'],
$conf['sql']['pass']) or die(mysql_error());
mysql_select_db($conf['sql']['db']) or die(mysql_error());

mysql_query("INSERT INTO mytable (answer1,answer2,answer3,answer4)
VALUES ('$result1','$result2','$result3','$result4')");
Reply With Quote