# Problem with update querry in mysql using php

**URL:** <https://forum.kirupa.com/t/problem-with-update-querry-in-mysql-using-php/101946>\
**Category:** Uncategorized\
**Created:** [February 18, 2004, 4:14am UTC](https://forum.kirupa.com/t/problem-with-update-querry-in-mysql-using-php/101946 "2004-02-18T04:14:27Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![upuaut](https://avatars.discourse-cdn.com/v4/letter/u/9fc348/32.png) [@upuaut](https://forum.kirupa.com/u/upuaut)\
**Post date:** [February 18, 2004, 4:14am UTC](https://forum.kirupa.com/t/problem-with-update-querry-in-mysql-using-php/101946/1 "2004-02-18T04:14:27Z")

</div>

here is my string… $Ndate, and $Nevent are sent from the Flash file to my php code and the code is as follows

```auto
		$TableName="dotsevents";
		$linkID = mysql_connect($Host, $User, $Password) or die("Could not connect to host."); 
		mysql_select_db($DBName, $linkID) or die("Could not find database.");
		$Query = 'UPDATE $TableName SET `event` = \'$Nevent\' WHERE `date` = \'$Ndate\' LIMIT 1 ;'
        . ' ';
		mysql_query($Query , $linkID) or die("Could not alter record");
		echo "&Status=Event on $Ndate altered";

```

this doesn’t seem to update, but I can’t figure out why… I’m sure it’s something having to do with the escaped quotes in the query variable set. Anyone see what it is I’m doing wrong?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2004, 4:54am UTC](https://forum.kirupa.com/t/problem-with-update-querry-in-mysql-using-php/101946/2 "2004-02-18T04:54:02Z")

</div>

I think you should change $Query to:

```php

$Query = "UPDATE '$TableName' SET `event` = '$Nevent' WHERE `date` = '$Ndate' LIMIT 1";

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2004, 5:13am UTC](https://forum.kirupa.com/t/problem-with-update-querry-in-mysql-using-php/101946/3 "2004-02-18T05:13:22Z")

</div>

I agree…

I thought that I had tried it that way and it didn’t work… but the amount of times I retested… I’m not sure anymore. I am sure that it’s something simple since this after noon I had the script working, then accidentaly saved a bad copy over the good one. (silly me)

The thing which confuses me is, I’m taking my php from mysql admin, after doing the querry in there… and then hitting “create php”. I can’t for the life of me figure out why phpmyadmin wants to concat ’ ’ to the end of the query. It’s all very strange…

I’ll try it comic… at least I know I’m on the right track with my thinking.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2004, 6:19am UTC](https://forum.kirupa.com/t/problem-with-update-querry-in-mysql-using-php/101946/4 "2004-02-18T06:19:50Z")

</div>

```php
	if($validity&&$isAdmin==1){
		$TableName="dotsevents";

		$linkID = mysql_connect($Host, $User, $Password) or die("Could not connect to host."); 

		mysql_select_db($DBName, $linkID) or die("Could not find database.");

		$Query = "UPDATE '$TableName' SET `event` = '$Nevent' WHERE `date` = '$Ndate' LIMIT 1";

		mysql_query($Query , $linkID) or die("Could not alter record");

		echo "&Status=Event on $Ndate altered";
	}
?>

```

returns to me, “could not alter record”

any other thoughts?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2004, 6:30am UTC](https://forum.kirupa.com/t/problem-with-update-querry-in-mysql-using-php/101946/5 "2004-02-18T06:30:23Z")

</div>

```auto
<?php
	//accepts $Ndate,$Nevent,$subName,$subPass from Flash swf
	include("validatePassword.php");

	// alteration
	if($validity&&$isAdmin==1){
		$TableName="dotsevents";

		$linkID = mysql_connect($Host, $User, $Password) or die("Could not connect to host."); 

		mysql_select_db($DBName, $linkID) or die("Could not find database.");

		$Query = "UPDATE `$TableName` SET `event` = '$Nevent' WHERE `date` = '$Ndate' LIMIT 1 ;";

		mysql_query($Query , $linkID) or die("Could not alter record");

		echo "&Status=Event on $Ndate altered";
	}
?>

```

now this works… just posting this so I can compare and see where my differences are… I have it working now.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2004, 6:44am UTC](https://forum.kirupa.com/t/problem-with-update-querry-in-mysql-using-php/101946/6 "2004-02-18T06:44:48Z")

</div>

missing semicolon… always it’s a missing semicolon.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2004, 7:18am UTC](https://forum.kirupa.com/t/problem-with-update-querry-in-mysql-using-php/101946/7 "2004-02-18T07:18:30Z")

</div>

a quick note, but not that important:  
Typically,only class names start with uppercase letters, and variable names start with lowercase 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2004, 7:44am UTC](https://forum.kirupa.com/t/problem-with-update-querry-in-mysql-using-php/101946/8 "2004-02-18T07:44:05Z")

</div>

typically? ah well… I’m certainly atypical. 🙂

I’ll try to keep track of that. As a novice php’er it’s difficult to tell why they are going with caps in some cases and lower case in the others. I haven’t even started thinking about classes in php yet. 🙂 Thanks for letting me know though… that should help a lot in my reading of php files.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2004, 3:04pm UTC](https://forum.kirupa.com/t/problem-with-update-querry-in-mysql-using-php/101946/9 "2004-02-18T15:04:04Z")

</div>

yeah its a really standard way to make things easier to read. Even if you don’t practice it, its good to know and it makes other peoples code easier to read. functions should start with lowercase letters as well. 🙂

edit: I was thinking about a simple OOP PHP tutorial. If you think it will help I will speed up the release date.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 18, 2004, 3:20pm UTC](https://forum.kirupa.com/t/problem-with-update-querry-in-mysql-using-php/101946/10 "2004-02-18T15:20:47Z")

</div>

Quick question: what’s the difference between ` and ’ ?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 19, 2004, 5:49am UTC](https://forum.kirupa.com/t/problem-with-update-querry-in-mysql-using-php/101946/11 "2004-02-19T05:49:14Z")

</div>

wow, good call… I didn’t even notice that ` \<-- this existed until you posed that… Is that a legitimate quote to use? or is it just something the forums PHP display thing does with nested single guotes?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 19, 2004, 5:55am UTC](https://forum.kirupa.com/t/problem-with-update-querry-in-mysql-using-php/101946/12 "2004-02-19T05:55:39Z")

</div>

sorry… no clue. My editor edit2Plus automaticaly formats them so I really havent’ had to pay attention to them.
