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

  • Home
  • SEARCH
  • 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 7917253
In Process

The Archive Base Latest Questions

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

Here is the code is written is RadarsMySql.php <?php $con = mysql_connect(localhost,root,dacian); $db =

  • 0

Here is the code is written is RadarsMySql.php

 <?php
 $con = mysql_connect("localhost","root","dacian");


 $db = mysql_select_db("radars");

 $sql = mysql_query("SELECT latitude,longitude,description FROM radars WHERE id > '0'");

 while($row=mysql_fetch_assoc($sql))
 $output[]=$row;
 print(json_encode($output));
 foreach($out["radars"] as $radars) { 
 $latitude = addslashes($radars[latitude]); 
 $longitude= addslashes($radars[longitude]); 
 $description = addslashes($radars[description]);

 mysql_query("INSERT INTO radars (latitude, longitude, description) VALUES('$name', '$ingredients', '$ingredients2')") or die (mysql_error()); 
 }

  mysql_close(); ?>

It gives me this error :

Notice: Undefined variable: out in C:\xampp\htdocs\RadarsMySql.php on line 13

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\RadarsMySql.php on line 13

I need this because i want to write data from android app using JSON. Could anyone tell me what is wrong or to give me some tips ?

  • 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-03T15:05:02+00:00Added an answer on June 3, 2026 at 3:05 pm
    foreach ($out["radars"] as $radars) {}
    

    If $out["radars"] is an array, this is fine. If it isn’t, you’ll get a bug: Invalid argument supplied for foreach.

    In your case $out["radars"] doesn’t exist at all. In fact $out doesn’t exist at all. So you get another bug: Undefined variable out.

    You’re initialising a variable $output but then trying to use it as $out. That won’t work.

    To pull data out of the database, encode it as JSON, and output it:

    $sql = 'SELECT latitude,longitude,description FROM radars WHERE id>0'
    $result = mysql_query($sql);
    
    $rows = array();
    while ($row = mysql_fetch_assoc($sql)) $rows[] = $row;
    echo json_encode($rows);
    

    And to receive JSON posted to the server, process it, and add it to the database:

    // It's being posted as application/json, not as application/x-www-form-urlencoded, so it won't populate the $_POST array.
    if ($json = file_get_contents('php://input')) {
        // Never mind. We'll do it ourselves.
        $a = json_decode($json, true); // Now we have a nice PHP array.
        $insert = '';
        foreach ($a as $v) {
            if ($insert) $insert .= ',';
            $insert .= ' ("' . $d->escape($v['lattitude']) . '", "' . $d->escape($v['longitude']) . '", "' . $d->escape($v['description']) . '")';
        }
        $sql = 'INSERT INTO `radars` (`latitude`, `longitude`, `description`) VALUES' . $insert;
        $d->exec($sql);
    }
    
    // I'm assuming you have a database class here, $d.
    // $d->exec() could be simply mysql_query() or mysqli_query().
    // $d->escape() should be mysql_real_escape_string() or mysqli_real_escape_string(), but both of those functions will fail if a database connection is not currently open.
    // So $d->escape() should (a) check whether a connection is currently open, (b) open one if not, (c) perform the escape and return the result.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

enter code here I have a table on SQL server 2005 with bigint primary
I'm working with some SQL 2005 CLR code written in C#. We have recently
I am trying to initialize a ViewController from another. Here is the code written
I've got my code written here . setInterval( function (data){ var alreadyScrolled = $("#smallBox").height()
Baffled here: I am looking at a bunch of code written in PHP4 but
Quickie here, I'm sure... I am going through some code written by a former
I have written code to insert an Image in SQL server but it throws
I have some PHP code (written by someone else) that's parsing a html file
I'm writing some unittests for code written by someone else here at the office.
So I have written this code here: highlighter: function (item) { var parts =

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.