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 6331127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:59:57+00:00 2026-05-24T17:59:57+00:00

Hello i got a problem with my mysql code it gives the following error

  • 0

Hello i got a problem with my mysql code it gives the following error upon trying to output:

Parse error: syntax error, unexpected $end in     C:\xampplite\htdocs\learncent\acksearch\search.php on line 25 

<?php
$db = new mysqli("localhost","root","","acksocial");

if(mysqli_connect_error())
{
printf("Connection failed:%s \n",mysqli_connect_error());
exit();
}

$name = mysqli_real_escape_string($db, $_POST['search']);
$table = 'acksearch';

if($result = $db->query("SELECT * FROM $table WHERE name = $name", MYSQLI_ASSOC))
{
    while($row = $result->fetch_object())
    {

    // $row is an associative array

    // Do something here

echo "Name: ".$row['name'];

echo " country: ".$row['country'];


}

$db->close();
?>

EDIT:
added 1 more } and no error but it wont output the result?

Would be good if anyone could help me.

EDIT AGAIN : Now the code look like this

<?php
$db = new mysqli("localhost","root","","acksocial");

if(mysqli_connect_error())
{
printf("Connection failed:%s \n",mysqli_connect_error());
exit();
}

$name = mysqli_real_escape_string($db, $_POST['search']);
$table = 'acksearch';

if($result = $db->query("SELECT * FROM $table WHERE name = $name", MYSQLI_ASSOC))
{
while($row = $result->fetch_object())
{

// $row is an associative array

// Do something here

echo "Name: ".$row['name'];

echo " country: ".$row['country'];

}

The error its giving its:

Parse error: syntax error, unexpected $end in C:\xampplite\htdocs\searcher.php on line 25

Thanks Fredrik

  • 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-24T17:59:58+00:00Added an answer on May 24, 2026 at 5:59 pm

    you did not close the while loop:

    while($row = $result->fetch_object())
        {
    
        // $row is an associative array
    
        // Do something here
    
    echo "Name: ".$row['name'];
    
    echo " country: ".$row['country'];
    
    }///// I added this } here
    

    you need to add } after the last row.

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

Sidebar

Related Questions

hello i got a problem with reading from a file, i am trying to
hello i have an error with the following code: in my h file i
Hello I got problem with scroll on my grid. Here is the code (nothing
hello i got a problem with comparing two char* variables that contains numbers for
hello i got a problem using valgrind when i use it with valgrind --leak-check=full
hello i got a problem, whenever i try to write any simple thing inside
hello i got the same problem as php :: new line in textarea? or
Hello I have got the problem with my query and it display the correct
I got a problem when I parse a complex file which include thousands of
Problem in brief I have got a piece of working two dimensional scrolling code.

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.