LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-06-2006, 03:56 PM   #1
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Rep: Reputation: 30
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
 
Old 01-06-2006, 04:02 PM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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
 
Old 01-06-2006, 04:09 PM   #3
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
$query = "UPDATE tamrin SET A =60 WHERE Team LIKE 'Pas'"; works fine
thank you for your attention
 
Old 01-06-2006, 04:14 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
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";

 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating MySQL DB when a link is clicked with PHP Erik Thorsson Programming 2 12-03-2004 07:35 AM
Updating Php & mysql dutchkillers Red Hat 1 07-12-2004 12:37 AM
Updating PHP on apache Daredevil Programming 3 05-25-2004 08:40 AM
Updating Apache & PHP (RH9) herc Linux - Software 3 08-21-2003 01:10 PM
Updating php 4.3.1 from tar and keeping current php configuration with mandrake 9.1 mrjeep Linux - General 0 04-02-2003 07:50 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:53 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration