bleured27 Posted July 27, 2012 Share Posted July 27, 2012 got a problem whith counting rows php 5.3 error Fatal error: Can't use function return value in write context in D:\xampp\htdocs\login.php on line 13 <?php session_start(); if(!empty($_POST['pass']) ||!empty($_SESSION['user']) ) { $user=$_POST['name']; $pass=$_POST['pass']; mysql_connect('localhost', 'root', '') or trigger_error("Unable to connect to the database: " . mysql_error()); mysql_select_db('forum') or trigger_error("Unable to switch to the database: " . mysql_error()); $query="SELECT * FROM users where user='$user' and pass='$pass"; $show=mysql_query("query"); $check_e = @mysql_query($query); if(mysql_num_rows($check_e) =0) { echo"rong login"; session_destroy(); }} else { $_SESSION['user'] = "$user"; $_SESSION['pass'] = "$pass"; echo"hoi"; include"home.php"; } else{ echo"empty fields"; include"home.php"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/266326-count-rows/ Share on other sites More sharing options...
requinix Posted July 27, 2012 Share Posted July 27, 2012 Hint #1: What's line 13? Quote Link to comment https://forums.phpfreaks.com/topic/266326-count-rows/#findComment-1364802 Share on other sites More sharing options...
phpchamps Posted July 27, 2012 Share Posted July 27, 2012 if(mysql_num_rows($check_e) =0) there should be == (comparison operator ) not single = (assignment operator) Quote Link to comment https://forums.phpfreaks.com/topic/266326-count-rows/#findComment-1364804 Share on other sites More sharing options...
bleured27 Posted July 27, 2012 Author Share Posted July 27, 2012 then i get this Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in D:\xampp\htdocs\login.php on line 13 Quote Link to comment https://forums.phpfreaks.com/topic/266326-count-rows/#findComment-1364805 Share on other sites More sharing options...
peipst9lker Posted July 27, 2012 Share Posted July 27, 2012 Your query failed. Place die(mysql_error()); above line 13 and give us the output. Quote Link to comment https://forums.phpfreaks.com/topic/266326-count-rows/#findComment-1364806 Share on other sites More sharing options...
bleured27 Posted July 27, 2012 Author Share Posted July 27, 2012 i filld in cc as name 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 ''ccc' at line 1 Quote Link to comment https://forums.phpfreaks.com/topic/266326-count-rows/#findComment-1364807 Share on other sites More sharing options...
Barand Posted July 27, 2012 Share Posted July 27, 2012 Final single quote missing after '$pass Quote Link to comment https://forums.phpfreaks.com/topic/266326-count-rows/#findComment-1364808 Share on other sites More sharing options...
bleured27 Posted July 27, 2012 Author Share Posted July 27, 2012 okey no error whith this only the page is white!!! idk how plz help <?php session_start(); if(!empty($_POST['pass']) ||!empty($_POST['user']) ) { $user=$_POST['name']; $pass=$_POST['pass']; mysql_connect('localhost', 'root', '') or trigger_error("Unable to connect to the database: " . mysql_error()); mysql_select_db('forum') or trigger_error("Unable to switch to the database: " . mysql_error()); $query="SELECT * FROM users where user='$user' and pass='$pass'"; $show=mysql_query("query"); $check_e = @mysql_query($query); die(mysql_error()); if(mysql_num_rows($check_e) ==0) { echo"rong login"; } else { $_SESSION['user'] = "$user"; $_SESSION['pass'] = "$pass"; echo"hoi"; include"home.php"; }} else{ echo"empty fields"; include"home.php"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/266326-count-rows/#findComment-1364809 Share on other sites More sharing options...
Barand Posted July 27, 2012 Share Posted July 27, 2012 That's because you call die(); change $check_e = @mysql_query($query); die(mysql_error()); to $check_e = @mysql_query($query) or die(mysql_error()); What is this meant to do? $show=mysql_query("query"); Quote Link to comment https://forums.phpfreaks.com/topic/266326-count-rows/#findComment-1364824 Share on other sites More sharing options...
bleured27 Posted July 27, 2012 Author Share Posted July 27, 2012 i did or thing still nothing in the page exept the include home Quote Link to comment https://forums.phpfreaks.com/topic/266326-count-rows/#findComment-1364835 Share on other sites More sharing options...
requinix Posted July 27, 2012 Share Posted July 27, 2012 What's your code now? Quote Link to comment https://forums.phpfreaks.com/topic/266326-count-rows/#findComment-1364941 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.