Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7557541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:09:30+00:00 2026-05-30T12:09:30+00:00

I am working on making server side validation for a form. Using AJAX, the

  • 0

I am working on making server side validation for a form. Using AJAX, the form sends the value in the input field for ‘username’ to my php page which then checks to see if this username already exists in the database.

Here is my php code:

$result = mysqli_query($dblink, "SELECT * FROM users WHERE `username` = '$regname'") 
or die(mysqli_error($dblink));
echo mysqli_affected_rows($result);

*(At the moment I am doing a simple echo for the mysqli_affected_rows just to see if my MySQL query is working as intended)*

The error I am getting is:

Warning: mysqli_affected_rows() expects parameter 1 to be mysqli, object given in /Users/test/Sites/proj/formvalidate.php on line 20

I am not quite sure what this error is trying to tell me. From what I have Googled “object” is a reference to OOP programming methods, but (as far as I know) I am not using OOP concepts/principles in this particular example? Or did I misinterpret this error message?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T12:09:31+00:00Added an answer on May 30, 2026 at 12:09 pm

    Rather than passing $result in to mysqli_affected_rows you actually want to pass the DB link (returned by mysqli_connect) which will give you the number of rows affected by the previous query. See:

    http://uk.php.net/mysqli_affected_rows

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i've been making web app's and working with various server side language like php,
I'm working on a web page where I'm making an AJAX call that returns
I'm working on making a simple server application with python, and I'm trying to
We're making this web app in PHP and when working in the reports we
I am making simple one on server side & one on client side application
Im working on a sparetime project, making some server code to an Arduino Duemilanove,
I'm working with libconfig++ and threads for making a small server application. The point
I'm working on making an HTTP server for my class. But, the returned file
I am working on making an application run on both Postgres and SQL Server.
I am working on making a mini app using Json parsing . Output I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.