Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error "0" from server: #11

Closed
fullyconnected opened this issue Aug 9, 2015 · 5 comments
Closed

Error "0" from server: #11

fullyconnected opened this issue Aug 9, 2015 · 5 comments

Comments

@fullyconnected
Copy link

Hello,

Are you able to tell me what's wrong with my code? I keep getting the error "0" from server.

Here's my code shown below, which is from your example code...

Thanks in advance.

"starts_with(incident_zip, '11207')"); $response = $socrata->get("/resource/$view_uid.json", $params); ``` } ?>
<?php if($response == NULL) { ?>
  <form action="311.php" method="POST">

    <label for="incident_zip">Zip Code</label>
    <input type="text" name="incident_zip" size="10" value="11207"/><br/>

    <input type="submit" value="Submit"/>
  </form>
<?php } else { ?>
  <h2>Results</h2>

  <?# Create a table for our actual data ?>
  <table border="1">
    <tr>
      <th>Agency</th>
      <th>Complaint Type</th>
    </tr>
    <?# Print rows ?>
    <?php foreach($response as $row) { ?>
      <tr>
        <td><?= $row["agency"] ?></td>
        <td><?= $row["complaint_type"] ?></td>
      </tr>
    <?php } ?>
  </table>

  <h3>Raw Response</h3>
  <pre><?= var_dump($response) ?></pre>
<?php } ?>
@allejo
Copy link

allejo commented Aug 15, 2015

The dataset you're trying to access doesn't have a incident_zip column. I can't replicate getting "0" from the server, I get an error saying that no such column exists.

To achieve your goal, try building a query like so:

http://data.cityofnewyork.us/resource/qiz3-axqb.json?$where=zip_code='11207'

@fullyconnected
Copy link
Author

@allejo Thank you very much... The names on the dataset were different from the .json response

@fullyconnected
Copy link
Author

@allejo How can I add two parameters to this assoc array? For example, I wanted to add a parameter which would have the date ('created_date') appear in descending order. According to the documentation I should use $order= created_date DESC, but unsure how to add to this parameter. The dataset is sorting in ASC order, I just need to reverse it.

$incident_zip = array_get("incident_zip",$_POST);

$params = array("$where" => "starts_with(incident_zip, '$incident_zip')");

@fullyconnected fullyconnected reopened this Sep 7, 2015
@allejo
Copy link

allejo commented Sep 7, 2015

Separate it with a comma. Something like this would do:

$params = array(
              "\$where" => "starts_with(incident_zip, '$incident_zip')",
              "\$order" => "<something>"
          );

@fullyconnected
Copy link
Author

@allejo Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants