Forum Moderators: coopster
<?
$id=$_POST['id'];
$text=$_POST['post'];
$name=$_POST['username'];
$a=$_POST['value'];
echo $a;
echo $text;
echo $id;$username="*******";
$password="************";
$database="forumguild";
mysql_connect(localhost,$username,$password);
$query="UPDATE genpost$a SET name = '$text' WHERE id = '$id'";
mysql_query($query);
echo "Post Editied";
mysql_close();
?>
The echos are included to make sure that the variables are not blank and they are not. However genpost$a is never updated. Does anyone know what I am doing wrong?
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
Put localhost in quotes. You don't have to quote
variable arguments, but you do have to quote strings:
mysql_connect('localhost',$username,$password); Select a database after you connect:
mysql_select_db($forumguild);
In your query string, are you concatinating $a to genpost, so if $a = x, the table name is genpostx? If not, that's a problem.
$query="UPDATE genpost$a SET name = '$text' WHERE id = '$id'";
The major thing is that you never executed the query:
$result = mysql_query($query);
Always test the result of your query so that if something goes wrong, you know what it is.
if (!$result) die("query error: ".mysql_error()); I hope this helps.