Query Ombouwen [Help]

Gestart doorThijmgrijs17 reacties43 weergaven

18 berichten · pagina 1 van 2

Thijmgrijs

Lid · Topicstarter

Berichten
968
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo Allemaal,

Ik heb op dit moment dit:

$query = "UPDATE leden SET muntjes + 5 WHERE username = ".$_SESSION[username]." ";


Die ".$_SESSION[username]." moet veranderd worden in:

<?= ucfirst($uFetch[naam]) ?>


Zou iemand deze ervoor me willen in zetten?
Zodat die werkt, had al geprobeerd maar kwam er niet uit bloos.
Alvast bedankt.

Mvg
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"UPDATE leden SET muntjes + 5 WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700];[/COLOR]
?>

Afbeelding
emobiggrinbiggrin
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
emocrycry @^

Quote:
$query = "UPDATE leden SET muntjes + 5 WHERE username = ".ucfirst($uFetch[naam])." "
0
Thijmgrijs

Lid · Topicstarter

Berichten
968
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Kijk dat werkt dus niet.
Dan krijg ik dit op mn pagina:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near + 5 WHERE username = Thijmen at line 1


En dit is mn script:

[COLOR= #0000BB]<?php[/COLOR]

 [URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"config.php"[/COLOR][COLOR= #007700]);[/COLOR]
 [URL="http://www.php.net/define"]define[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"TITLE"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"Credits kopen"[/COLOR][COLOR= #007700]);[/COLOR]
 layoutboven[COLOR= #007700]();[/COLOR]
 checklogin[COLOR= #007700]();[/COLOR]

     ?>
     
     
[COLOR= #0000BB]<?php
$con[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"******"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"******"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700])
  {[/COLOR]
  [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Could not connect: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
  }[/COLOR]



[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"UPDATE leden SET muntjes + 250 WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]


[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
?> 

Je hebt 250 muntjes erbij!
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Thijmgrijs schreef:
Kijk dat werkt dus niet.
Dan krijg ik dit op mn pagina:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near + 5 WHERE username = Thijmen at line 1


En dit is mn script:

[COLOR= #0000BB]<?php[/COLOR]

 [URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"config.php"[/COLOR][COLOR= #007700]);[/COLOR]
 [URL="http://www.php.net/define"]define[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"TITLE"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"Credits kopen"[/COLOR][COLOR= #007700]);[/COLOR]
 layoutboven[COLOR= #007700]();[/COLOR]
 checklogin[COLOR= #007700]();[/COLOR]

     ?>
     
     
[COLOR= #0000BB]<?php
$con[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"******"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"******"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700](![/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700])
  {[/COLOR]
  [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Could not connect: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());
  }[/COLOR]



[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"UPDATE leden SET muntjes + 250 WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]


[URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
?> 

Je hebt 250 muntjes erbij!


Als je de melding leest zie je dat het fout gaat bij + 5 WHERE username = Thijmen at line 1
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Quote:
$query = "UPDATE leden SET muntjes + 5 WHERE username = ".mysql_real_escape_string(ucfirst($uFetch[naam]))." "
0
Thijmgrijs

Lid · Topicstarter

Berichten
968
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Thommity schreef:
Quote:
$query = "UPDATE leden SET muntjes + 5 WHERE username = ".mysql_real_escape_string(ucfirst($uFetch[naam]))." "
Dan krijg ik dit op de Pagina:

Parse error: syntax error, unexpected T_STRING in /home/thijmip94/domains/filetolink.net/public_html/addcredits.php on line 10


Ik had mn code ff wat verbeterd:

[COLOR= #0000BB]<?php[/COLOR]
 [URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"config.php"[/COLOR][COLOR= #007700]);[/COLOR]
 [URL="http://www.php.net/define"]define[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"TITLE"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"Credits kopen"[/COLOR][COLOR= #007700]);[/COLOR]
 layoutboven[COLOR= #007700]();[/COLOR]
 checklogin[COLOR= #007700]();[/COLOR]
 ?>
 
[COLOR= #0000BB]<?php
    $query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"UPDATE leden SET muntjes + 250 WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
            [URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
?> 

Je hebt 250 muntjes erbij!
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"UPDATE leden SET muntjes =  muntjes + 5 WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700];[/COLOR]
?>
0
Thijmgrijs

Lid · Topicstarter

Berichten
968
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dylanh schreef:
[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"UPDATE leden SET muntjes =  muntjes + 5 WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700];[/COLOR]
?>
Nu krijg ik dit op mn site:
Afbeelding

Na refreshen is en blijft t aantal nog steeds 4.
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Doe eens echo $query en post dan wat er staat.
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Thijmgrijs schreef:
Eerdere citaten tonen
Dylanh schreef:
[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"UPDATE leden SET muntjes =  muntjes + 5 WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700];[/COLOR]
?>
Nu krijg ik dit op mn site:
Afbeelding

Na refreshen is en blijft t aantal nog steeds 4.

omdat 5 gewoon 5 moet zijn yummie
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Thommity schreef:
Eerdere citaten tonen
Thijmgrijs schreef:
Eerdere citaten tonen
Dylanh schreef:
[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"UPDATE leden SET muntjes =  muntjes + 5 WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700];[/COLOR]
?>
Nu krijg ik dit op mn site:
Afbeelding

Na refreshen is en blijft t aantal nog steeds 4.
omdat 5 gewoon 5 moet zijn yummie
Ik doe het zelf ook met
0
Thijmgrijs

Lid · Topicstarter

Berichten
968
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Het is eindelijk gelukt.
Heb hem nu op:

[COLOR= #0000BB]<?php[/COLOR]
 [URL="http://www.php.net/include"]include[/URL] [COLOR= #007700]([/COLOR][COLOR= #DD0000]"config.php"[/COLOR][COLOR= #007700]);[/COLOR]
 [URL="http://www.php.net/define"]define[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"TITLE"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]"Credits kopen"[/COLOR][COLOR= #007700]);[/COLOR]
 layoutboven[COLOR= #007700]();[/COLOR]
 checklogin[COLOR= #007700]();[/COLOR]
 ?>
 
[COLOR= #0000BB]<?php
    $query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"UPDATE leden SET muntjes =  muntjes + 250 WHERE naam = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700];[/COLOR]
        [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
            [URL="http://www.php.net/mysql_close"]mysql_close[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$con[/COLOR][COLOR= #007700]);[/COLOR]
?> 

Je hebt 250 muntjes erbij!


Bedankt voor de hulp! biggrin
0
Thom

Lid

Berichten
10.654
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dylanh schreef:
Eerdere citaten tonen
Thommity schreef:
Eerdere citaten tonen
Thijmgrijs schreef:
Eerdere citaten tonen
Dylanh schreef:
[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"UPDATE leden SET muntjes =  muntjes + 5 WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700];[/COLOR]
?>
Nu krijg ik dit op mn site:
Afbeelding

Na refreshen is en blijft t aantal nog steeds 4.
omdat 5 gewoon 5 moet zijn yummie
Ik doe het zelf ook met

ja maar muntjes = int?
0
Berichten
308
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php
$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"UPDATE leden SET muntjes = muntjes + 5 WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/ucfirst"]ucfirst[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" "[/COLOR][COLOR= #007700];[/COLOR]
?>


Zo dus emo
Je kan niet muntjes +5 doen. Dat wordt niet herkend als geldige SQL syntax. Je moet dus eerst het veld muntjes de oorspronkelijke waarde van muntjes toekennen, en dan pas kan je hem met 5 vermeerderen.

Heeft niks te maken met het gebruiken van of niet, maar Tom heeft wel gelijk muntjes is een integer. En zou dus ook moeten behandeld worden als n integer
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren