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"; } ?> 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? 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) 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 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. 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 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 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"; } ?> 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"); 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 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? Link to comment https://forums.phpfreaks.com/topic/266326-count-rows/#findComment-1364941 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.