bigbikkuri
05-13-2006, 11:09 AM
I'm completely at my wits end.
I have a dropdown menu form:
<form method="POST" action="moviescoreinput.php">
<select name="usermoviescore">
<option value="0" selected="selected">0</option>
<option value="1">1 - Terrible</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5 - Average</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10 - Amazing</option>
</select>
<input type="submit" value="Get Club L Point">
</form>
That code with the following SQL query:
if(mysql_result($result,0,0)>0)
{
echo "HERE 4.1";
$sql = "UPDATE usermoviedata
SET moviescore = $moviescore, moviescorepoint = 1
WHERE username ='$user' AND movie ='$movie'";
mysql_query($sql) or die(mysql_error());
}
else
{
echo "HERE 4.2";
$sql = sprintf ( "INSERT INTO usermoviedata
(username, movie, moviescore, moviescorepoint) VALUES
('%s','%s','%s','%s')",
mysql_real_escape_string($_SESSION['name']),
mysql_real_escape_string($_SESSION['movie']),
mysql_real_escape_string($moviescore),
mysql_real_escape_string(1)
);
mysql_query($sql) or die(mysql_error());
}
And that checks out all fine and rockin.
However, now I have a textarea:
<form method="POST" action="moviescorewhyinput.php">
<textarea rows="10" cols="40" wrap="virtual"></textarea>
<input type="submit" value="Get Club L Point">
</form>
That has code with THIS SQL statement:
if(mysql_result($result,0,0)>0)
{
echo "HERE 4.1";
var_dump($user);
var_dump($movie);
$sql = "UPDATE usermoviedata
SET scorewhy = $moviescorewhy, scorewhypoint = 1
WHERE username ='$user' AND movie ='$movie'";
mysql_query($sql) or die(mysql_error());
}
else
{
echo "HERE 4.2";
$sql = sprintf ( "INSERT INTO usermoviedata
(username, movie, scorewhy, scorewhypoint) VALUES
('%s','%s','%s','%s')",
mysql_real_escape_string($_SESSION['name']),
mysql_real_escape_string($_SESSION['movie']),
mysql_real_escape_string($moviescorewhy),
mysql_real_escape_string(1)
);
mysql_query($sql) or die(mysql_error());
}
And it gives me a syntax error. The output of the php file is as follows:
'HERE 0HERE 1HERE 2HERE 3string(20) "my@email.com" string(23) "Raiders of the Lost Ark" HERE 4.1string(20) "my@email.com" string(23) "Raiders of the Lost Ark" You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' scorewhypoint = 1 WHERE username ='my@email.com' A' - but it is exactly the same as the dropdown query less a name change. The database designtable is as follows:
col-type-size:
username-varchar-50
movie-varchar-100
moviescore-varchar-2
moviescorepoint-int-1
scorewhy-varchar-100
scorewhypoint-int-1
scene-varchar-100
scenepoint-int-1
scenewhy-varchar-100
scenewhypoint-int-1
Any help in the matter would be SO appreciated. I've been banging my head against the wall for 2 hours already...:(
I have a dropdown menu form:
<form method="POST" action="moviescoreinput.php">
<select name="usermoviescore">
<option value="0" selected="selected">0</option>
<option value="1">1 - Terrible</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5 - Average</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10 - Amazing</option>
</select>
<input type="submit" value="Get Club L Point">
</form>
That code with the following SQL query:
if(mysql_result($result,0,0)>0)
{
echo "HERE 4.1";
$sql = "UPDATE usermoviedata
SET moviescore = $moviescore, moviescorepoint = 1
WHERE username ='$user' AND movie ='$movie'";
mysql_query($sql) or die(mysql_error());
}
else
{
echo "HERE 4.2";
$sql = sprintf ( "INSERT INTO usermoviedata
(username, movie, moviescore, moviescorepoint) VALUES
('%s','%s','%s','%s')",
mysql_real_escape_string($_SESSION['name']),
mysql_real_escape_string($_SESSION['movie']),
mysql_real_escape_string($moviescore),
mysql_real_escape_string(1)
);
mysql_query($sql) or die(mysql_error());
}
And that checks out all fine and rockin.
However, now I have a textarea:
<form method="POST" action="moviescorewhyinput.php">
<textarea rows="10" cols="40" wrap="virtual"></textarea>
<input type="submit" value="Get Club L Point">
</form>
That has code with THIS SQL statement:
if(mysql_result($result,0,0)>0)
{
echo "HERE 4.1";
var_dump($user);
var_dump($movie);
$sql = "UPDATE usermoviedata
SET scorewhy = $moviescorewhy, scorewhypoint = 1
WHERE username ='$user' AND movie ='$movie'";
mysql_query($sql) or die(mysql_error());
}
else
{
echo "HERE 4.2";
$sql = sprintf ( "INSERT INTO usermoviedata
(username, movie, scorewhy, scorewhypoint) VALUES
('%s','%s','%s','%s')",
mysql_real_escape_string($_SESSION['name']),
mysql_real_escape_string($_SESSION['movie']),
mysql_real_escape_string($moviescorewhy),
mysql_real_escape_string(1)
);
mysql_query($sql) or die(mysql_error());
}
And it gives me a syntax error. The output of the php file is as follows:
'HERE 0HERE 1HERE 2HERE 3string(20) "my@email.com" string(23) "Raiders of the Lost Ark" HERE 4.1string(20) "my@email.com" string(23) "Raiders of the Lost Ark" You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' scorewhypoint = 1 WHERE username ='my@email.com' A' - but it is exactly the same as the dropdown query less a name change. The database designtable is as follows:
col-type-size:
username-varchar-50
movie-varchar-100
moviescore-varchar-2
moviescorepoint-int-1
scorewhy-varchar-100
scorewhypoint-int-1
scene-varchar-100
scenepoint-int-1
scenewhy-varchar-100
scenewhypoint-int-1
Any help in the matter would be SO appreciated. I've been banging my head against the wall for 2 hours already...:(