No results

I have a table with 3 columns id, FILE & DOWNLOADS.
All I want to do is view the value of the DOWNLOADS column if I specify the id value.
Simple eh! NOT. it gives me a value of 0 where it should be 17 so it doesn’t work.
[php]<?php

require ‘connect.php’;

$id = $_GET[‘xx’];

$body = “”;

if ($id == 1)
{
$result = mysqli_query(“SELECT * FROM download_manager WHERE id = $id”);

$row = mysqli_fetch_assoc($sql);

$downloads = $row[“DOWNLOADS”];

$body = ‘’.(int)$downloads.’’;
}
else
{
$body = '2. Blue ';
}

echo “returnBody=$body”;

exit();

?>
[/php]

plz plz plz help!

[PHP]
$row = mysqli_fetch_assoc($sql);
[/PHP]

Should be:

[PHP]
$row = mysqli_fetch_assoc($result);
[/PHP]

I realised that and changed it and still doesn’t work.
As I have tested my flash as3 on another basic php file and works… so its my php that’s wrong :frowning:

thanks
Steven

ok this is the correct PHP I’m using…
[php]<?php

require(‘connect.php’);

$id = $_GET[‘xx’];

$body = “”;

if ($id == 1)
{

$result = mysqli_query(“SELECT DOWNLOADS FROM download_manager WHERE id = ‘xx’”);

$data = mysqli_fetch_assoc($result);

$body = ‘’. $data[‘DOWNLOADS’] .’ ';

}
else
{
$body = '2. Blue ';
}

echo “returnBody=$body”;

exit();

?>[/php]
And if I change some of the code to this…
[php]$body = ‘’. (int)$data[‘DOWNLOADS’] .’ ';[/php]
I get a zero… so its the PHP for some reason is not getting the correct value :frowning:

PLEASE! PLEASE! HELP!!!

$id is looking for a $_GET id of xx, but your code says if $id==1 then do something. Never going to work. The query as you posted it will ONLY run if $id is 1.

Figured it out… here is the code :slight_smile:

[php]<?php
require_once (‘connect.php’);
$id = $_GET[‘xx’];
$body = “”;
if ($id == 0)
{
$body = ‘NO DATA’;
}
else
{
$result = mysqli_query(“SELECT * FROM download_manager WHERE id = $id”);
$row = mysqli_fetch_assoc($result);
$body = ‘’.$row[‘DOWNLOADS’].’’;
}
echo “returnBody=$body”;
exit();
?>[/php]

Thanks
Steven 8)

Figured it out

You actually don’t have it figured out. I would recommend you study the basics of Php, Html, and CSS

What happens if you submit this:

http://yoursite.com/yourfile.php?id=3' // note the ' ...

Hmmmmm … same as =1 lol
hows that ?

Sponsor our Newsletter | Privacy Policy | Terms of Service