Register for your free account! | Forgot your password?

You last visited: Today at 12:08

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[php] Problem

Discussion on [php] Problem within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1

 
Byte.'s Avatar
 
elite*gold: 7
Join Date: Jun 2011
Posts: 659
Received Thanks: 160
[php] Problem

Hallo, habe folgendes Problem beim Einloggen:

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /var/customers/webs/ni272979_1/Loader/login.php on line 17

Das ist der Code-Ausschnitt:

PHP Code:
<?php
$filename 
'install.php';
if (
file_exists($filename)) {
echo (
"<center><font color='red'><b>/install.php still exists<br>
After installing please delete install.php</center></font></b>"
);
} else {
    if (isset(
$_POST['Login'])){
    include(
'config.php');
        if (!
mysql_connect($host$username$password)) die("Can't connect to database");
        if (!
mysql_select_db($db_name)) die("Can't select database");
        
$myusername=$_POST['myusername'];
        
$mypassword=$_POST['mypassword'];

        
$sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
        
$result=mysql_query($sql);
        
$count=mysql_num_rows($result);
        if(
$count >= 1){
        
session_register("myusername");
        
session_register("mypassword");
        
header("location: index.php");
        } else {
            
        }
    }
Byte. is offline  
Old 05/11/2014, 13:59   #2
 
tolio's Avatar
 
elite*gold: 2932
The Black Market: 169/1/0
Join Date: Oct 2009
Posts: 6,966
Received Thanks: 1,097
$result ist also nen boolean und keine resource, ich vermute das der query entsprechend false zurückgibt weils fehlschlägt und eben keine antwort

auch hier ist wieder debuggen das zauberwort, zwischenwerte zum kontrollieren ausgeben lassen dann findet man die problempunkte schnell selber, ganz zu schweigen davon das in der fehlermeldung ne zeilenangabe steht
tolio is offline  
Old 05/11/2014, 14:33   #3
 
elite*gold: 25
Join Date: Sep 2011
Posts: 5,537
Received Thanks: 1,266
Nur als Tip zu "session_register()"
IchVerabschiedeMich is offline  
Old 05/11/2014, 14:57   #4


 
elite*gold: 1091
Join Date: Jun 2007
Posts: 19,836
Received Thanks: 7,180
Deine Query schlägt fehl, deshalb ist $result ein boolean und somit auch false.

Die Session solltest du direkt über die Keys füllen ($_SESSION['key'] = value), da wie Padrio schon erwähnt hat, session_register entfernt wurde.

Achja, escapen solltest du deine Eingaben auch noch.
Mostey is offline  
Reply


Similar Threads Similar Threads
[Problem]Habe ein Problem und zwar spinnt mein VPC etwas(ohne Grund)?!
07/28/2011 - Metin2 Private Server - 10 Replies
Also wie schon gesagt meins Server spinnt wodurch kiks usw. kommen :( ich lade euch die Screens in den Anhang, mit der Hoffnung, dass ihr mir helfen könnt :) wäre echt sehr nice :)



All times are GMT +1. The time now is 12:08.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.