Friday, 15 January 2010

php - Error array, i cant get out the information - in mysql query -



php - Error array, i cant get out the information - in mysql query -

hello got big problem couldnt solve, weird problem :s utilize next code:

for( $m = 0; $m < sizeof( $jugadores ) ; $m++ ) { $juga_q = "insert jugadores values($jugadores[$m][1],$nom_equipo,'',$jugadores[$m][4]);"; $result = mysql_query( $juga_q ); echo $juga_q."<br>"; }

i got info in array want insert info base, dump query in $juga_q variable utilize in insert into, query doesnt execute , create echo check whats failing , got next:

insert jugadores values(array[1],aston villa,'',array[4]);

when create echo of array out of query got no problems, thats why im getting crazy , hope u help me.

thanks forward!!

try concatenate it,

$juga_q = "insert jugadores values(". $jugadores[$m][1].",$nom_equipo,'',".$jugadores[$m][4].");";

as sidenote, query vulnerable sql injection if value(s) of variables came outside. please take @ article below larn how prevent it. using preparedstatements can rid of using single quotes around values.

how prevent sql injection in php?

php mysql

No comments:

Post a Comment