Problem with update querry in mysql using php

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

		$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?

I think you should change $Query to:


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

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.

	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?

<?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.

missing semicolon… always it’s a missing semicolon.

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

typically? ah well… I’m certainly atypical. :slight_smile:

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. :slight_smile: Thanks for letting me know though… that should help a lot in my reading of php files.

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. :slight_smile:

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

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

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?

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