tobeye Posted October 30, 2010 Share Posted October 30, 2010 hello, I'm a beginner when it comes to PHP: I'm working on a log in system but i keep on getting the same errors which makes my system unreliable. this is the function I'm trying to use: if(pg_numrows($q) == 1){ echo "<p>Someone took that username</p>"; include "signup.php"; exit; } --> I'm using a postgresql database this is the warning I keep on getting: Warning: pg_numrows(): supplied argument is not a valid PostgreSQL result resource in /var/ftpdirs/512544/PHP/login/adduser.php on line 13 I have the same problem when I try to look if an username is taken or not... when people try to register this is my adduser.php file: <?php session_start(); include "connectie_db.php"; $User_name = $_POST['user_name'] ; $User_pass = $_POST['user_pass'] ; $User_pass2 = $_POST['user_pass2'] ; $checkUsername= "SELECT user_name from tovanu.users where user_name = '$User_name';"; $q = $db->exec($checkUsername); if(MDB2::isError($q)){ echo "code: ".$q->getUserInfo(); exit(); } if(pg_numrows($q) == 1){ echo "<p>Someone took that username</p>"; include "signup.php"; exit; } If(strlen($User_name > 32)){ echo "<p>The username is too long</p>"; include "signup.php"; exit; } if($User_pass != $User_pass2){ echo "<p>Both passwords must be the same</p>"; include "signup.php"; exit; } $password = md5($User_pass); $add = "INSERT INTO tovanu.users (user_name,user_pass,user_email,user_date,user_level,naam,adres,plaats,postcode) VALUES ('$User_name','$password','email',current_date,1,'jef','jonhstraat','maaseik','3687')"; $execute = $db->exec($add) ; if(MDB2::isError($execute)){ echo "code: ".$q->getUserInfo(); exit(); } $_SESSION['user'] = $username; include "index.php"; ?> any help would be appreciated!!!!!!!!!!! Link to comment https://forums.phpfreaks.com/topic/217293-php-newbie-problem-with-a-function-easy-solution/ Share on other sites More sharing options...
revraz Posted October 30, 2010 Share Posted October 30, 2010 Sounds like your query is failing. Link to comment https://forums.phpfreaks.com/topic/217293-php-newbie-problem-with-a-function-easy-solution/#findComment-1128358 Share on other sites More sharing options...
chrules Posted October 31, 2010 Share Posted October 31, 2010 Don't really know anything about postgresql (I use MySQL), but as far as i could google couldn't you just use SELECT COUNT(*) for this (since it seems the way you're counting is wrong)? Link to comment https://forums.phpfreaks.com/topic/217293-php-newbie-problem-with-a-function-easy-solution/#findComment-1128524 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.