Page 1 of 1

Quick edit record question

Posted: Thu May 05, 2005 12:10 pm
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

Posted: Thu May 05, 2005 3:22 pm
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'");