Selecting rows

Alles, was MariaDB und MySQL betrifft, kann hier besprochen werden.

Selecting rows

Postby mickeymouse » 27. August 2021 00:40

I'm trying to select rows and also asking how many rows selected. Neither work.
Here is my code. Can you tell me what's wrong or direct me to the appropriate documentation.

I have not been able to find anything in the documentation concerning the selection so I'm doing it as I did it under Version 5.x where it worked beautifully.

For the row count, I believe I'm doing it exactly like the documentation says, but it doesn.t work. I get the following error msg:
Warning: Attempt to read property "num_rows" on bool in C:\xampp\htdocs\HA_LogInCheck.php on line 80


$results=mysqli_query($link, "SELECT * FROM 'hauser' WHERE `userid`='$UserID' ||perid`='$UserID' ");
$AffectedRows = $results->num_rows;
mickeymouse
 
Posts: 58
Joined: 08. March 2009 06:10
Location: France & Canada
Operating System: Win 7 Family Prem Ed (64 bit?)

Re: Selecting rows

Postby Altrea » 27. August 2021 06:29

check your syntax. you have at least one error in using backticks.
use backticks for every identifier (database name, table names, column names) and single quotes for strings.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11933
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Selecting rows

Postby Nobbie » 27. August 2021 13:58

mickeymouse wrote: it as I did it under Version 5.x where it worked beautifully.


No, that is impossible:

Code: Select all
$results=mysqli_query($link, "SELECT * FROM 'hauser' WHERE `userid`='$UserID' ||perid`='$UserID' ");


The single quotes at 'hauser' are wrong in every MySQL version, its simply a syntax error. You cannot apply a string as table name.
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04


Return to MariaDB - MySQL

Who is online

Users browsing this forum: No registered users and 27 guests