Quick edit record question

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
erick
Forum Newbie
Posts: 3
Joined: Thu Mar 31, 2005 12:14 pm

Quick edit record question

Post by erick »

Code: Select all

<?php
    $submit = $_POST["submit"]; 
     
    if ($submit) { 
        $username = $_POST["username"]; 
        $comment = $_POST["comment"]; 

    	$connection = mysql_connect("localhost", "****", "****") or die("connect"); 

    	mysql_select_db("****",$connection) or die ("Unable to select requested database.");

    	$changeresult = mysql_query

    	("UPDATE `auth` SET `comm` = $comment WHERE `username` = $username");

    	$result=mysql_query($changeresult, $connection);
    	$affected_rows=mysql_affected_rows($connection);

    	echo "<b>$username</b> was affected.";
	}
    ?>
This code goes to the last line successfuly but the "UPDATE" does not occur I have tried various ways of writing this code. Can anyone show me a solution or point me in the right direction.

-Thanks in advance

Eric
cbrian
Forum Commoner
Posts: 97
Joined: Sun Feb 27, 2005 12:29 pm

Post by cbrian »

I think the problem is here:

Code: Select all

("UPDATE `auth` SET `comm` = $comment WHERE `username` = $username");
It should be changed to

Code: Select all

("UPDATE `auth` SET `comm` = '$comment' WHERE `username` = '$username'");
Post Reply