[PHP] Een quoteje meer of minder...

Pagina: 1
Acties:

  • kaandorp
  • Registratie: November 1999
  • Laatst online: 03-09 22:36
Ik gebruik deze string om een newsitem toe te voegen:
PHP:
1
<?$query = "INSERT INTO news VALUES('','$time','$_SESSION[newsdata][source]','$_SESSION[newsdata][title]','$_SESSION[newsdata][subtitle]','$_SESSION[newsdata][message]','$_SESSION[newsdata][category]')";?>

Maar als ik dan ga kijken wat hij in de db geplaatst heb zie ik dat er Array[veldnaam] in staat i.p.v. de waarde van Array[veldnaam].

Moet ik nog ergens quotes o.i.d. toevoegen, of moet ik het helemaal anders doen?

  • LuCarD
  • Registratie: Januari 2000
  • Niet online

LuCarD

Certified BUFH

ooit gekeken naar de . operator?

http://www.php.net/manual/en/language.operators.string.php

Of je kan de c style gebruiken...

http://www.php.net/sprintf

Programmer - an organism that turns coffee into software.


  • kaandorp
  • Registratie: November 1999
  • Laatst online: 03-09 22:36
Ja idd... Stom van me... Met een "." werkt het wel.

  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06-2025

drm

f0pc0dert

En wat nog een van de mooiste oplossingen is, wanneer PHP de variabelen niet parst binnen een string, is even accolades eromheen zetten.
code:
1
$string = "blaat maar ook een {$hele->ingewikkelde['variabele']['met_een']['diepe']['structuur']}";

werkt altijd ;)

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz


  • DRvDijk
  • Registratie: Juni 2001
  • Laatst online: 17:10
Laat Grum ut niet zien! Quote your named array's! The why

  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06-2025

drm

f0pc0dert

elviver:
Laat Grum ut niet zien! Quote your named array's! The why
Grum wist niet eens dat 't in de manual stond, totdat ik 'm er op wees >:)

voordeel is wel dat hij 't in z'n sig zet, hoef ik 't niet meer te zeggen :D

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz


  • Grum
  • Registratie: Juni 2001
  • Niet online
je doet et alleen wel fout :)

je mag niet quoten IN een string ... :)

  • LuCarD
  • Registratie: Januari 2000
  • Niet online

LuCarD

Certified BUFH

Op donderdag 23 mei 2002 12:05 schreef Grum het volgende:
je doet et alleen wel fout :)

je mag niet quoten IN een string ... :)
Mag nie???

Nee het is niet netjes.... maar dat is wat anders...

Programmer - an organism that turns coffee into software.


  • drm
  • Registratie: Februari 2001
  • Laatst online: 09-06-2025

drm

f0pc0dert

Op donderdag 23 mei 2002 12:05 schreef Grum het volgende:
je doet et alleen wel fout :)

je mag niet quoten IN een string ... :)
daar heb je nou precies die accollades voor:
Quote je named arrays ook in een string, binnen accollades,the why

:D ;)

Music is the pleasure the human mind experiences from counting without being aware that it is counting
~ Gottfried Leibniz

Pagina: 1