New in PHP

Posts 1–7 of 7 · Page 1 of 1
New in PHP
I'm new to PHP and I need to fix the php files hat were given to me,I keep getting errors on this one saying line 12 has an error.Hope you can teach me guys

For example:

<?php
if($_SERVER['REQUEST_METHOD'] == 'GET')
{
if(isset($_GET['email']) && isset($_GET['password']) && ($_GET['password'])!='' && $_GET['email']!='')
{
require_once 'connect.php';
$em = $_GET['email'];
$pw = $_GET['password'];
$sql = "SELECT * FROM user_accounts a, user_info ui WHERE email='$em' and password='$pw' and a.userid=ui.userid";
$result = mysqli_query($conn, $sql);

if(mysqli_num_rows($result) != 0){
$row = mysqli_fetch_row($result);
session_start();
echo 'Authorized';
$_SESSION['Authorized'] = 'Granted';
$_SESSION['fullname'] = $row[7]. " " . $row[6];
} else{
echo "Invalid email or password.";
}
mysqli_close ($conn);
}else{
echo "Please fill all fields.";
}
} else{
echo "Access not authorized, access denied.";
}
?>

/PS im also new in posting threads sry
Quote Originally Posted by DoomedBlocks View Post
if(mysqli_num_rows($result) != 0){
should be
Code:
if($result->num_rows != 0){ ...
I believe.
The error is Fatal error:Can't Use function return value in write context in (directory).

I would try both of your suggestions


/PS can u guys help me in my project? cuz i need a LOT of help. ty ty
Quote Originally Posted by DoomedBlocks View Post
The error is Fatal error:Can't Use function return value in write context in (directory).

I would try both of your suggestions


/PS can u guys help me in my project? cuz i need a LOT of help. ty ty
I can try helping, add me on skype: Smirnoffq (or click in skype logo in my signature)
Well, what's the error message?

You should try to check the return of your mysqli_query function (returns false in case of error)
You can also try to print your result with this code snippet for example, to see if the result is what you expect

echo '<pre>';
print_r($result);
echo '</pre>';
Not an answer to your problem, but I'd suggest you asking on Stack Overflow or similar. There's a shitton of users willing to help.
Also, put your code in code blocks, make it look nicer. And please say what error you get, or else it can be hard helping you.
@DoomedBlocks
Your code:
Code:
if(mysqli_num_rows($result) != 0)
Spit the line into two sub-lines, it should somewhat look like this:
Code:
$resultvalue = mysqli_num_rows($result);
if($resultvalue != 0);
thats a common error in php versions prior to PHP 5.5
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?