PHP/MYSQL fout

Gestart doorBasDev3 reacties23 weergaven

4 berichten · pagina 1 van 1

BasDev

Lid · Topicstarter

Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hey,

Ik heb iets gemaakt waardoor je een MYSQL query via een pagina op je site kan maken...
Alleen als ik het volgende doe:

Query:
UPDATE gebruikers SET muntjes = muntjes + 5 WHERE naam = admin

Ik druk op verzenden en er komt dit te staan:

Fout:
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 naam = admin at line 1

+ nog een query andere manier:

Query:
UPDATE gebruikers SET muntjes = muntjes + `5` WHERE naam = `admin`

Fout:
Unknown column admin in where clause

Het script van de hele pagina:

[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/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]./menu.php[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"safe/safe_leerling.php"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"safe/safe_leeraar.php"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"safe/safe_beheerde.php"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"safe/safe_admin.php"[/COLOR][COLOR= #007700]);[/COLOR]
?>
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]query[/COLOR][COLOR= #007700]])){[/COLOR]
    [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]query[/COLOR][COLOR= #007700]];[/COLOR]
    [COLOR= #0000BB]$query[/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 [COLOR= #0000BB]$errstr[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]();[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$errstr[/COLOR][COLOR= #007700])){[/COLOR]
    [COLOR= #0000BB]$msg[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$msg[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"</strong>FOUT! Er zit in fout in de mysql query: <strong>"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$errstr[/COLOR][COLOR= #007700];
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    [COLOR= #0000BB]$affected_rows[/COLOR] [COLOR= #007700]= @[/COLOR][URL="http://www.php.net/mysql_affected_rows"]mysql_affected_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
    [COLOR= #0000BB]$msg[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$msg[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]"</strong>Gelukt!: <strong>"[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$affected_rows[/COLOR][COLOR= #007700];
    }
}[/COLOR]
?>


<b>MYSQL tabellen & querys voor DataBase:</b> superb_database<BR><BR>
<div id="column7" class="column">
<b>MYSQL Database tabellen:</b><BR>

[COLOR= #0000BB]<?php
$getTables[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SHOW TABLES FROM superb_database"[/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/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$tmp[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$getTables[/COLOR][COLOR= #007700])){[/COLOR]
[COLOR= #0000BB]$table[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$tmp[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700]];[/COLOR]
?>
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$table[/COLOR] ?><BR>
[COLOR= #0000BB]<?php[/COLOR] [COLOR= #007700]}[/COLOR] ?>

</div>
<div id="column7" class="column">
<b>MYSQL Query:</b>
[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$msg[/COLOR][COLOR= #007700])){[/COLOR] ?><strong><font color="#FF0000" face="Arial,Arial Black,sans-serif" size="2">[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$msg[/COLOR][COLOR= #007700];[/COLOR] ?></font></strong>[COLOR= #0000BB]<?php[/COLOR] [COLOR= #007700]}[/COLOR] ?>
<form method=post>

<textarea name=query cols=40 rows=10>[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]query[/COLOR][COLOR= #007700]];[/COLOR] ?></textarea>
<BR>
<input type=submit value=Verstuur>
</form>

<BR><BR><BR>
<a class="butto" href="./mysql_rep" onclick="this.blur();"><span>Tabellen repareren</span></a>
</div>
</p>


Alles werkt behalve dat...
0
Berichten
4.214
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
haal die quotes weg bij de 5 dat helpt als ik me niet vergis
0
BasDev

Lid · Topicstarter

Berichten
2.692
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
@Timmie Had al geprobeerd werkt ook niet
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zet dit onder de includes:

/* slash-stripper is gemaakt door Lennard van one2xs.com / one2apps.com */
    function strip($string)
    {
        if(!is_array($string))
        {
            return get_magic_quotes_gpc() == 1 ? stripslashes($string) : $string;
        }
        else
        {
            $nieuwe = array();
            foreach($string as $key => $value)
            {
                if(!is_array($value))
                {
                    $nieuwe[$key] = get_magic_quotes_gpc() == 1 ? stripslashes($value) : $value;
                }
                else
                {                
                    $nieuwe[$key] = strip($value);
                }
            }
            return $nieuwe;
        }
    }

    if(isset($_GET) && is_array($_GET) && count($_GET) > 0)
        $_GET = strip($_GET);

    if(isset($_POST) && is_array($_POST) && count($_POST) > 0)
        $_POST = strip($_POST);
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