I'm getting an error, even though the script is executing correctly. I'm trying to send information from a form to a function:
I am learning to use functions and want to send information over from the submitted form to the function? here is the code i have so far, which seems to work, but i do get an error:
this should then send $_POST['text'] to the function?
[PHP] function updateConfig() {
$ticker = $_POST['text'];
$query = mysql_query("UPDATE config SET text = '$ticker' WHERE name = 'ticker'");
if (!mysql_query($query)) { die('Error: ' . mysql_error()); } else { echo "<p>Update Successful. Your changes will appear immediately.</p>\n <p><a href=\"/admin/\">Go back</a></p>"; } } [/PHP]
This does update but i get this error:
[CODE]Error: 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 '1' at line 1[/CODE]
Am i using the function and passing the info in the correct way? what is causing the error?
Question
game_over
I'm getting an error, even though the script is executing correctly. I'm trying to send information from a form to a function:
I am learning to use functions and want to send information over from the submitted form to the function? here is the code i have so far, which seems to work, but i do get an error:
form action="index.php?add=config"
this should then send $_POST['text'] to the function?
function updateConfig() {
$ticker = $_POST['text'];
$query = mysql_query("UPDATE config SET text = '$ticker' WHERE name = 'ticker'");
if (!mysql_query($query)) {
die('Error: ' . mysql_error());
} else {
echo "<p>Update Successful. Your changes will appear immediately.</p>\n <p><a href=\"/admin/\">Go back</a></p>";
}
}
[/PHP]
This does update but i get this error:
Am i using the function and passing the info in the correct way? what is causing the error?
Link to comment
Share on other sites
22 answers to this question
Recommended Posts