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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:44:05+00:00 2026-06-03T13:44:05+00:00

I really don’t know what i’m doing wrong. I want to count the rows

  • 0

I really don’t know what i’m doing wrong. I want to count the rows in my query. My id’s started from 1 to … step 1, so the biggest number is the last record. I only want to let the script run on the last record of de DB. So here is my code.

public function saveLongLan()
    {
        define("MAPS_HOST", "maps.google.com");
        define("KEY", "MYKEY");

        $link = mysql_connect('localhost', 'root', 'root');
        if (!$link) {
         die('Not connected : ' . mysql_error());
        }

        // Set the active MySQL database
        $db_selected = mysql_select_db('Foodsquare', $link);
        if (!$db_selected)  
        {
            die("Can\'t use db : " . mysql_error());
        }

        $query = "SELECT * FROM tblPlaces WHERE 1";
        $result = mysql_query($query);
        $row_cnt = mysqli_num_rows($result);


            if (!$result) 
                {
                    die("Invalid query: " . mysql_error());
                }


        $delay = 0;
        $base_url = "http://" . MAPS_HOST . "/maps/geo?output=xml" . "&key=" . KEY;

        while ($row = @mysql_fetch_assoc($result)) 
            {
                $geocode_pending = true;

                    while ($geocode_pending) 
                        {
                            $address = $row["Street"];
                            $id = $row["Id"];
                            $request_url = $base_url . "&q=" . urlencode($address);
                            $xml = simplexml_load_file($request_url) or die("url not loading");

                            $status = $xml->Response->Status->code;
                            if (strcmp($status, "200") == 0) 
                                {
                                      // Successful geocode
                                      $geocode_pending = false;
                                      $coordinates = $xml->Response->Placemark->Point->coordinates;
                                      //explode functie breekt een string af vanaf een bepaald teken en stopt hem dan in een array
                                      $coordinatesSplit = explode(',', $coordinates);
                                      // formaat: Longitude, Latitude, Altitude
                                      $lat = $coordinatesSplit[1];//getal = plaats in array
                                      $lng = $coordinatesSplit[0];


                                      $query = sprintf("UPDATE tblPlaces " .
                                                " SET lat = '%s', lng = '%s' " .
                                                " WHERE id = '". $row_cnt . "' LIMIT 1;",
                                             mysql_real_escape_string($lat),
                                             mysql_real_escape_string($lng),
                                             mysql_real_escape_string($id));
                                      $update_result = mysql_query($query);
                                          if (!$update_result) 
                                            {
                                            die("Invalid query: " . mysql_error());
                                            }
                                } else if (strcmp($status, "620") == 0) 
                                    {
                                          // sent geocodes too fast
                                          $delay += 100000;
                                    } 
                                    else 
                                    {
                                        // failure to geocode
                                        $geocode_pending = false;
                                        echo "Address " . $address . " failed to geocoded. ";
                                    echo "Received status " . $status . " \n";
                                    }
                                usleep($delay);
                        }
            }

    }
  • 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-06-03T13:44:05+00:00Added an answer on June 3, 2026 at 1:44 pm

    your query is incorrect $query = "SELECT * FROM tblPlaces WHERE 1";

    you should specify the column name after where clause for comparison with a value for example: WHERE column_name = 1 or something like that.

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

Sidebar

Related Questions

I want to learn VHDL but I really don't know from where to start.
I really don't understand what I'm doing wrong, but according to Adobe, this is
I really don't know what I'm doing with SQL, but I have two tables.
I really don't know how to explain what's going on, so I'll just show
I'm new to python so I really don't know the language very well. the
I'm stuck on a problem I really don't know how to solve: I have
I'm relatively new to Objective-C and really don't know much about it yet, so
I am trying to automate data extraction from a website and I really don't
I really don't want to have to reinvent the wheel with this one. There
I really don't know/have the answer, knowledge to find a resource value using a

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.