LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   problem in updating in PHP (https://www.linuxquestions.org/questions/programming-9/problem-in-updating-in-php-400336/)

mohtasham1983 01-06-2006 03:56 PM

problem in updating in PHP
 
I want to update some fields of my table. In order to do it I use the following command in phpmyadmin which works fine:
UPDATE tamrin SET tamrin.A =60 WHERE Team LIKE 'Pas' ;
but in php this command doesn't work. databse connection and everything else is correct because i can query my table's data.
My code looks like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>Result</title>
</head>
<body>
<?php
require 'db.inc';
// Connect to the MySQL server
if (!($connection = @ mysql_connect($hostname, $username, $password)))
die("Cannot connect");

if (!mysql_select_db("League", $connection))
showerror();

$query = "UPDATE 'tamrin' SET tamrin.A =60 WHERE Team LIKE 'Pas'";
if (mysql_affected_row()==0)
{
echo "query did nothing";
}

?>
</body>
</html>


I cannot see any change after this page in loaded :(

graemef 01-06-2006 04:02 PM

You have single quotes around the table in you PHP code but not in the example you used with phpmyadmin.

Could that be the issue?

graeme

mohtasham1983 01-06-2006 04:09 PM

$query = "UPDATE tamrin SET A =60 WHERE Team LIKE 'Pas'"; works fine
thank you for your attention

Hko 01-06-2006 04:14 PM

Eh,.. the code you posted does not call mysql_query() to actually execute the query:
PHP Code:

 $query "UPDATE 'tamrin' SET tamrin.A =60 WHERE Team LIKE 'Pas'";
/** HERE **/
if (mysql_affected_row()==0)
{
echo 
"query did nothing";




All times are GMT -5. The time now is 02:10 AM.