[php & sql] Insert into met variable variable :?

Pagina: 1
Acties:
  • 92 views sinds 30-01-2008

  • Choller
  • Registratie: Juli 2001
  • Laatst online: 22-05-2024
Ja, dit is (nogmaals) moeilijk om uit te leggen.

Het gaat om de onderstaande code
PHP:
1
<?while ($i <= $Attendance){    $result  = mysql_query("INSERT INTO nbalive_daybyday (PTS, PPG, FGM) VALUES ('$PTS' . $i. , '$PPG' . $i. , '$FGM' . $i.)");}?>

Dus ik moet de $i variabele "plakken" aan de overige waarden maar dit lukt niet. Ik denk dat mijn code niet goed is. Weet iemand hoe dit wel moet ?

  • Feyd-Rautha
  • Registratie: November 2001
  • Laatst online: 02-08-2025
Je moet uw variabele $i concateneren aan uw string met behulp van & of + of << tekentjes

* Feyd-Rautha kent geen PHP, dus ik ken het concatenatie-character ook niet

Beginnersfout imho :)

I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. Where the fear has gone there will be nothing. Only I will remain.


  • Choller
  • Registratie: Juli 2001
  • Laatst online: 22-05-2024
In php is de concatenatie een ".".
Maar blijkbaar gaat deze dus niet.
Het is wel een gevorderde beginnerfoutje :)

  • Dennis
  • Registratie: Februari 2001
  • Laatst online: 14:19
echo "hoi ".$bla." hoi ".$bla." hoi ";

:)

  • [ash]
  • Registratie: Februari 2002
  • Laatst online: 23-08 12:03

[ash]

Cookies :9

Op maandag 22 juli 2002 15:32 schreef -Avalanche- het volgende:
Je moet uw variabele $i concateneren aan uw string met behulp van & of + of << tekentjes

* [ash] kent geen PHP, dus ik ken het concatenatie-character ook niet

Beginnersfout imho :)
dat doe je in PHP met een punt "." (en dat deed ie netjes) >:)

Probeer de volgende string eens
code:
1
$result  = mysql_query(&quot;INSERT INTO nbalive_daybyday (PTS, PPG, FGM) VALUES (&quot;.$PTS.$i.&quot;,&quot;.&quot;$PPG.$i.&quot;,&quot;$FGM.$i.&quot;);

  • ACM
  • Registratie: Januari 2000
  • Niet online

ACM

Software Architect

Werkt hier

Wat probeer je?

Want bovenstaande code is syntactisch natuurlijk gewoon correct, totdat het bij mysql aankomt...

Bekijk dus eens wat er als query opgestuurd wordt, in de P&W-faq staat wel aardig beschreven hoe en wat.
Op maandag 22 juli 2002 15:34 schreef Choller het volgende:
In php is de concatenatie een ".".
Maar blijkbaar gaat deze dus niet.
Het is wel een gevorderde beginnerfoutje :)
Nee, dat is nog steeds een beginners fout...


Zie het verschil tussen "string" . $iets . "..." en "string .$iets . ".

  • Feyd-Rautha
  • Registratie: November 2001
  • Laatst online: 02-08-2025
Op maandag 22 juli 2002 15:36 schreef [ash] het volgende:

[..]

dat doe je in PHP met een punt "." (en dat deed ie netjes) >:)

Probeer de volgende string eens
code:
1
$result  = mysql_query(&quot;INSERT INTO nbalive_daybyday (PTS, PPG, FGM) VALUES (&quot;.$PTS.$i.&quot;,&quot;.&quot;$PPG.$i.&quot;,&quot;$FGM.$i.&quot;);
mjah, dan staan volgens mij zijn "-teken toch niet juist hoor. Die .-jes worden nu toch ook al gewonen string aanzien en niet als concatenatie.

I must not fear. Fear is the mind-killer. Fear is the little-death that brings total obliteration. I will face my fear. I will permit it to pass over me and through me. Where the fear has gone there will be nothing. Only I will remain.

Pagina: 1

Dit topic is gesloten.