Hi Leute,
ich habe mir schon seit einiger Zeit ne mysql Klasse geschrieben, aber nun kommt ein Fehler bei der Funktion num_rows...
Hier ein Teil der Klasse:
PHP-Code:
function query($sql)
{
$query = mysql_query($sql);
//check the sql command
if (!$query)
{
throw new mysqlexception("The sql command is invalid");
return FALSE;
}
else { return $this->query = $query; }
}
function num_rows()
{
$number_of_entries = mysql_num_rows($this->query);
if(!$number_of_entries)
{
throw new mysqlexception("The sql command is invalid or not existing");
return FALSE;
}
else
{
return $number_of_entries;
}
}
PHP-Code:
<?php
require 'mysql_class.php';
$mysql = new mysql_class("localhost","test","root","");
if (isset($_POST['send']))
{
$query = sprintf("SELECT name,pass FROM test_1 WHERE name='%s' AND pass='%s'",
mysql_real_escape_string($_POST['user']),
mysql_real_escape_string(md5($_POST['passwort'])));
$mysql->query($query);
echo $mysql->num_rows();
}
Und die Fehlermeldung ist:
Code:
Fatal error: Uncaught exception 'mysqlexception'
with message 'The sql command is invalid or notexisting'
in D:\03 - programmieren\xampp\htdocs\class\.settings\mysql_class.php:64 Stack trace:
#0 D:\03 - programmieren\xampp\htdocs\class\.settings\login_class.php(14): mysql_class->num_rows() #1
{main} thrown in D:\03 - programmieren\xampp\htdocs\class\
.settings\mysql_class.php on line 64
Was mache ich denn nur falsch?:-(
Ach ja und wenn ich keine Variablen in den SQL Befehl mit einbinde dann geht das...