RE: [PHP] UPDATE command In SQL

From: Date: Sun, 30 Jul 2000 13:58:59 +0000
Subject: RE: [PHP] UPDATE command In SQL
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-9099@lists.php.net to get a copy of this message
Try this.... MYSQL_QUERY ("UPDATE $table SET Monday = '".$mon[$count]."', Tuesday = '".$tues[$count]."' , Wednesday = '".$wed[$count]."' , Thursday = '".$thur[$count]."' , Friday = '".$fri[$count]."' , Saturday = '".$sat[$count]."' WHERE Number = ".$num[$count]); Notice I took the array's out of the string. The only thing I can see is that maybe PHP isn't correctly evaluating the array. Try taking the query out of the mysql_query() function itself and just do something like: $query = "query string"; echo $query; mysql_query($query); that way you can make sure the query is as-expected. John -----Original Message----- From: Nashirak Bosk [mailto:nashirak@mindspring.com] Sent: Sunday, July 30, 2000 9:57 PM To: php-general@lists.php.net Subject: [PHP] UPDATE command In SQL I am having trouble updating my database. My table has all varchar(25) except for the Number column which is an int . I have localized my problem to the actual query I give to the database. In Particular I think it may be my Number column. This is a snipet of my code. All the arrays come from the previous form. // Define all MYSQL Variables $host = "localhost"; $username = "username"; $password = "password"; $database = "database"; $table = "table"; // Conect to the database MYSQL_CONNECT ($host) or DIE ("Unable to connect to databse"); @mysql_select_db("$database") or DIE ("Unable to select database"); // Set all counters to 0 for flag pruposes $count = 0; while ($count < $i-1) { MYSQL_QUERY ("UPDATE $table SET Monday = '$mon[$count]', Tuesday = '$tues[$count]' , Wednesday = '$wed[$count]' , Thursday = '$thur[$count]' , Friday = '$fri[$count]' , Saturday = '$sat[$count]' WHERE Number = $num[$count]"); // Update Counters $count++; } MYSQL_CLOSE (); ?> <br><br> <center><h1>All records have been updated<h1></center> </body> </html> If anyone could help me out with this that would be great. Nashirak -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#9099) next »