Jump to content

Puzzling Problem With Function Variable


westonm

Recommended Posts

I have been having a problem with a very simple function for about the last 6 hours and it is getting real frustrating. I am quite sure it is a very simple something I am overlooking but I don't see it. If someone could point me in the right direction I would greatly appreciate it. The code is in the attached file: The problem is that I am passing a value of "MaynardWestonA" which is a key to a SQL table. In the function I want to update the record for "MaynardWestonA" but it keeps seeing only "Mayna" in the function- it is dropping the rest of the variable and consequently not finding the record.

function updtRegis($keyin) {

UPDATE directory SET username='', password='', registered='Yes' WHERE key = $keyin ;

}

The main program calls the function as follows:

$keypass = 'MaynardWestonA'

...

rtnvalue2 = updtRegis($keypass);

UpdateSnip.txt

Link to comment
https://forums.phpfreaks.com/topic/272384-puzzling-problem-with-function-variable/
Share on other sites

Sorry - I thought the basics idea would be enough - The actual code is

function updtRegist($keyin, $database_Class63, $Class63) {
require_once('Connections/Class63.php');
mysql_select_db($database_Class63, $Class63);
$updateSQL = sprintf("UPDATE 'directory' SET 'USERNAME'='','PASSWORD'='','Registered'='Yes' WHERE 'KEY'=%s",
	    GetSQLValueString($keyin, "text"));  
$Result1 = mysql_query($updateSQL, $Class63) or die(mysql_error());		   
}

The calling code is

$rtnval2 = updtRegist($keypass, $database_Class63, $Class63);

Why can't I do a line feed here? This is just the function and the calling code.

Barand - Thanks this seemed to help, it passed the full value of the variable. Didn't update the table but I am a step closer now, at least it is not giving me an error. I have always had a problem with single and double quotes and when to use them or not. Actually had to leave the single quotes on KEY and not put them on %s. I think it needs them on KEY since that is a reserved name. Thanks again, now I can find the next problem.

DB/table/field names are never enclosed in quotes (in MySQL, anyhow. Don't know about the rest). If they happen to be a reserved word, the best thing is to rename the entity, the next best thing is to enclose the name in `backticks`.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.