[php] error?

Gestart doorSemmiiee10 reacties37 weergaven

11 berichten · pagina 1 van 1

Semmiiee

Lid · Topicstarter

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

Ik ben bezig met een eigen website te maken, alles zelf gescript. Maar dat is dan ook echt de eerste keer,

En ik ben nu bezig met een login script, maar ik krijg een error.
Ik werk met PHPDesigner 7, dat zelf geen error ingeeft.

Maar op mijn host als ik test krijg ik de error:

SELECT * FROM users WHERE username=sem AND password=random
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/deluxhost/domains/deluxhost.s3.one2xs.com/public_html/One2Uploads/login.php on line 23
random

Nadat ik wou inloggen.
Ik moest mijn wachtwoord (random) in md5 formaat crypten, normaal als je je gegevens (iets randoms yummie) ingeeft, krijg je een code met je encrypted wachtwoord,

Nu krijg ik die error.
Line 23:

$rowcount = mysql_num_rows(mysql_query($login));


Ik snap de fout niet..

edit:
hele script:

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

[URL="http://www.php.net/require"]require[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"connect.php"[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$post_username[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$post_password[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_username[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_username[/COLOR][COLOR= #007700])>[/COLOR][COLOR= #0000BB]25[/COLOR][COLOR= #007700]||[/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700])>[/COLOR][COLOR= #0000BB]35[/COLOR][COLOR= #007700])[/COLOR]
        [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Username or password character length too long!"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR]
        [COLOR= #FF8000]//convert password to md5[/COLOR]
        [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700]);[/COLOR]
        
        
        [COLOR= #FF8000]//query the database[/COLOR]
        [COLOR= #0000BB]$login[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/printf"]printf[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE username=%s AND password=%s"[/COLOR][COLOR= #007700],[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_username[/COLOR][COLOR= #007700]),[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700]));[/COLOR]
        
       [COLOR= #0000BB]$rowcount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$login[/COLOR][COLOR= #007700]));[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700]; 
    }
    
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Username and Password required!"[/COLOR][COLOR= #007700]);[/COLOR]
    
?>
0
Berichten
1.054
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
1. Heb je de SQL in de database gezet
2. Heb je een config/verbind of whatever .php om met de database te verbinden? emo
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
$rowcount = mysql_num_rows(mysql_query($login));
0
Semmiiee

Lid · Topicstarter

Berichten
4.013
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hdradio schreef:
1. Heb je de SQL in de database gezet
2. Heb je een config/verbind of whatever .php om met de database te verbinden? emo
ik heb connect.php
@^:
werkt niet
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lijn 20 veranderen in

$login = printf("SELECT * FROM users WHERE username=%s AND password=%s", mysql_real_escape_string($post_username),mysql_real_escape_string($post_password));
0
Semmiiee

Lid · Topicstarter

Berichten
4.013
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Luukvdo schreef:
Lijn 20 veranderen in

$login = printf("SELECT * FROM users WHERE username=%s AND password=%s", mysql_real_escape_string($post_username),mysql_real_escape_string($post_password));
SELECT * FROM users WHERE username=Alex AND password=ccb1b7f2ec15002876fb77b13e1e0065
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/deluxhost/domains/deluxhost.s3.one2xs.com/public_html/One2Uploads/login.php on line 23

Werkt dus niet.
0
Berichten
18.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/require"]require[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"connect.php"[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$post_username[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$post_password[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_username[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_username[/COLOR][COLOR= #007700])>[/COLOR][COLOR= #0000BB]25[/COLOR][COLOR= #007700]||[/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700])>[/COLOR][COLOR= #0000BB]35[/COLOR][COLOR= #007700])[/COLOR]
        [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Username or password character length too long!"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR]
        [COLOR= #FF8000]//convert password to md5[/COLOR]
        [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700]);[/COLOR]
        
        
        [COLOR= #FF8000]//query the database[/COLOR]
        [COLOR= #0000BB]$login[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE username="[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_username[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]" AND password="[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]""[/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]
        
       [COLOR= #0000BB]$rowcount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$login[/COLOR][COLOR= #007700]);[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700]; 
    }
    
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Username and Password required!"[/COLOR][COLOR= #007700]);[/COLOR]
    
?>
0
Semmiiee

Lid · Topicstarter

Berichten
4.013
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Luukvdo schreef:
[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/require"]require[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"connect.php"[/COLOR][COLOR= #007700]);[/COLOR]

[COLOR= #0000BB]$post_username[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$post_password[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_username[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_username[/COLOR][COLOR= #007700])>[/COLOR][COLOR= #0000BB]25[/COLOR][COLOR= #007700]||[/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700])>[/COLOR][COLOR= #0000BB]35[/COLOR][COLOR= #007700])[/COLOR]
        [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Username or password character length too long!"[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
    [COLOR= #007700]{[/COLOR]
        [COLOR= #FF8000]//convert password to md5[/COLOR]
        [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700]);[/COLOR]
        
        
        [COLOR= #FF8000]//query the database[/COLOR]
        [COLOR= #0000BB]$login[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users WHERE username="[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_username[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]" AND password="[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]""[/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]
        
       [COLOR= #0000BB]$rowcount[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$login[/COLOR][COLOR= #007700]);[/COLOR] 
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$post_password[/COLOR][COLOR= #007700]; 
    }
    
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Username and Password required!"[/COLOR][COLOR= #007700]);[/COLOR]
    
?>
Nu geeft hij deze error:
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 sdfsdfsvdfh at line 1

die sdfsdfvdfh was random password dat ik intikte.
IK heb geen idee wat nu fout is?
0
Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
$login = mysql_query("SELECT * FROM users WHERE username=" . mysql_real_escape_string($post_username) . " AND password=" . mysql_real_escape_string($post_password) . "") or die(mysql_error());
0
Semmiiee

Lid · Topicstarter

Berichten
4.013
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Daiman schreef:
$login = mysql_query("SELECT * FROM users WHERE username=" . mysql_real_escape_string($post_username) . " AND password=" . mysql_real_escape_string($post_password) . "") or die(mysql_error());
Dat is precies hetzelfde als het nu is. emo
0
Berichten
5.795
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
nope de voor password is weg wink
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