Page 1 of 2

Help me !!!

Posted: Sun Mar 16, 2003 4:03 pm
by lapicki
$sSQL="Update Table1 Set Nombre=$nom".$size." where Legajo='024'";


With this instruction desire to record the content of the field nom,
but does not work. Somebody can say to me if there is a syntax error?

Posted: Sun Mar 16, 2003 7:24 pm
by craigh
$sSQL="Update Table1 Set Nombre=$nom".$size." where Legajo='024'"

is $nom a variable? is $size a variable?

how about:

$sSQL="Update Table1 Set Nombre=".$nom.$size." where Legajo='024'"

??

Posted: Mon Mar 17, 2003 1:56 am
by twigletmac
Do you get an error or what happens/doesn't happen that shouldn't/should happen?

Mac

Re: Help me !!!

Posted: Mon Mar 17, 2003 7:18 am
by craigh
lapicki wrote:$size it is a variable that indicates the number of row within the table

$nom it is the entered value to modify the name of that field, from another form
OK - so what are the answers to the previous post?

Re: Help me !!!

Posted: Mon Mar 17, 2003 4:04 pm
by craigh
lapicki wrote:

Code: Select all

<?php
MySQL_CONNECT($hostname,$username,$password) or DIE("DATABASE NO RESPONDE"); 
mysql_select_db($dbName)or DIE("Tabla no disponible"); 
$result=mysql_db_query("auth","select * from tabla1"); 
$number = MySQL_NUM_ROWS($result); 
$size = 1; 
while($size <= $number) 
{ 
$sSQL="Update tabla11 Set Nombre=$nom".$size."  where Legajo='024'"; 
echo $sSQL; 
mysql_db_query("auth",$sSQL)or DIE($sSQL .' :'.mysql_error()); 
$size++; 
} 
mysql_close;
?>
You sent this to me via PM. What is the error that is produced?

Re: Help me !!!

Posted: Mon Mar 17, 2003 6:27 pm
by lapicki
craigh wrote:
lapicki wrote:

Code: Select all

<?php
MySQL_CONNECT($hostname,$username,$password) or DIE("DATABASE NO RESPONDE"); 
mysql_select_db($dbName)or DIE("Tabla no disponible"); 
$result=mysql_db_query("auth","select * from tabla1"); 
$number = MySQL_NUM_ROWS($result); 
$size = 1; 
while($size <= $number) 
{ 
$sSQL="Update tabla11 Set Nombre=$nom".$size."  where Legajo='024'"; 
echo $sSQL; 
mysql_db_query("auth",$sSQL)or DIE($sSQL .' :'.mysql_error()); 
$size++; 
} 
mysql_close;
?>
You sent this to me via PM. What is the error that is produced?

Two types of errors take place:
1) You have an error in your SQL syntax near '1 where Legajo='024'' at line 1
2) If the instruction is: Set Nombre=$nom".$size."
it records I number of row, is to say $size, instead of recording
the content of the field Nombre

Posted: Tue Mar 18, 2003 1:49 am
by twigletmac
When you echo $sSQL what do you get?

Mac

Posted: Tue Mar 18, 2003 3:25 am
by lapicki
twigletmac wrote:When you echo $sSQL what do you get?

Mac
Print the value of $size and the one of the field does not name

Posted: Tue Mar 18, 2003 3:27 am
by twigletmac
Are $nom and $size both numbers and they are both being printed correctly when you echo $sSQL?

Mac

Posted: Tue Mar 18, 2003 5:11 am
by lapicki
$size prints it correctly

$nom would have to be the name corresponding to the row that
indicates $size

Posted: Tue Mar 18, 2003 5:14 am
by twigletmac
So is $nom - a string (text or mixture of text and numbers) or a number?

Could you please post exactly what you get when you echo $sSQL - the whole SQL query as produced by your code.

Mac

Posted: Tue Mar 18, 2003 6:23 am
by lapicki
Update Personal1 Set Nombre=''1 where Legajo='024'Update Personal1 Set Nombre=''1 where Legajo='024' :You have an error in your SQL syntax near '1 where Legajo='024'' at line 1

Posted: Tue Mar 18, 2003 6:30 am
by twigletmac

Code: Select all

Update Personal1 Set Nombre=''1 where Legajo='024'
Where do the single quotes come from after the Nombre= bit in the statement?

Your statement is failing because of those single quotes them - you need to have either:

Code: Select all

UPDATE Personal1 SET Nombre = '1' WHERE Legajo='024'
or if Nombre will always be a number:

Code: Select all

UPDATE Personal1 SET Nombre = 1 WHERE Legajo='024'
for the query to be syntactically correct.

It also doesn't look as though $nom contains anything.

Mac

Posted: Tue Mar 18, 2003 6:52 am
by lapicki
$sSQL="Update Personal1 Set Nombre=$nom".$size." where Legajo='024'";


echo $sSql:

Update Personal1 Set Nombre=1 where Legajo='024'

I need that instead of printing 1, she prints the name entered a
previous form

Posted: Tue Mar 18, 2003 6:55 am
by twigletmac
Have you tried:

Code: Select all

$sSQL = "Update Personal1 Set Nombre='".$_POST['nom'].$size."' where Legajo='024'";
You may need to read:
viewtopic.php?t=511

Mac