SQL/PHP Problem.
Posted: Sun Sep 30, 2007 12:16 pm
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello.
I have been trying to create a script that, if a correct answer is posted to the page, points are added to a user's profile. Also, it should add a number to a field, and does a strstr on the feild, so that the user cannot just re-post the answer and gain more points.
I know that this code adds points properly, but the rest I am stuck with.
Could you check out the syntax for me? And help me to see what the problem is.Code: Select all
<?php
if (isset($_POST['answer'])){
if ($_POST['answer'] == 'answer to question'){
$con = mysql_connect("XXXXXXXXXXXXXXXXX");
if (!$con){
die('Could not connect: ' . mysql_error());
}
mysql_select_db("b13_980789_db", $con);
$username = $_SESSION['username'];
$isitdone = mysql_query("SELECT * FROM basic WHERE username = '$username'");
if((strstr($isitdone, '1')) === FALSE){
mysql_query("UPDATE `b13_980789_db`.`users` SET `points` = points+3 WHERE `users`.`username` = '$username';
UPDATE `b13_980789_db`.`users` SET `basic` = basic + '1' WHERE `users`.`username` = '$username'");
echo "Congratulations.";
}
else{
}
mysql_close($con);
}
}
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]