Page 1 of 1
Selection problem
Posted: Wed Aug 22, 2007 11:13 pm
by thefreebielife
For this code, I only want users to display where $site = cash
Site is a table, and cash is an option of the table.
Nothing displays, what am I doing wrong?
Code: Select all
else
$sql="select * from users order by uId ASC WHERE Cash=$site";
}
$result = mysql_query($sql);
$i = 0;
//grab all the content
while($r=mysql_fetch_array($result))
{
$i++;
$auid=$r["uId"];
$site=$r["site"];
$ausername=$r["username"];
$fname=$r["fname"];
$email=$r["email"];
$address=$r["address"];
$city=$r["city"];
$state=$r["state"];
$zip=$r["zip"];
$ostatus=$r["ostatus"];
$astatus=$r["astatus"];
$date=$r["date"];
$deadline=$r["deadline"];
$ip=$r["ip"];
$dead=$r["dead"];
$char = strlen($email);
if ($char > 25) {
$email = substr($email,0,20)."...";
}
?>
Thanks,
Jared
Re: Selection problem
Posted: Wed Aug 22, 2007 11:42 pm
by feyd
thefreebielife wrote:Nothing displays, what am I doing wrong?
Not using
mysql_num_rows() and/or
mysql_error().
Posted: Wed Aug 22, 2007 11:51 pm
by thefreebielife
Okay let me try that
Posted: Thu Aug 23, 2007 12:13 am
by thefreebielife
This is now returning a blank page:
Code: Select all
<?
//select the table
$data6 = mysql_query("SELECT * FROM gifts WHERE gSite='Cash'")
or die(mysql_error());
{
$r = mysql_fetch_array($data6);
$gname=$r["gName"];
$gref=$r["gRef"];
$gd=$r["gDescription"];
$gprice=$r["gPrice"];
$gsite=$r["gSite"];
$i = 1;
<Td>
<Table style="width:200px "><tr><td> <div class="gimage" align="center"><img src="<? echo "$gimage"; ?>" border="0"></div></td></tr>
<tr><td align="center"><div class="gname"><? echo "$gname"; ?></div></td></tr>
<tr><td><div class="gdescription"><? echo "$gdescription"; ?></div></td></tr>
<Tr><Td><div class="gprice" align="left"><font color="#000000">Price:</font> $<? echo "$gprice"; ?><br></Td></Tr>
<Tr><Td> <div align="center"><font color="#000000"><a href="agifts.php?change=<? echo "$gid"; ?>">Edit Gift</a></font></div></Td></Tr>
<Tr><Td><div align="center"><font color="#000000"><a href="agifts.php?remove=<? echo "$gid"; ?>">Remove Gift</a></font></div></td></tr>
</table>
<?
if ($i % 3 == 0) { echo "</tr><tr>"; }
$i++;
}
?>
Everything is closed..
Posted: Thu Aug 23, 2007 9:15 am
by feyd
You probably have a parse error. Modify your php.ini to display errors and make sure it's set to at least E_ALL. Don't settle for anything less than E_ALL. You can use the following to make sure the settings take hold.
Code: Select all
<?php
$neg = array('off', 0, false, '', null);
$flags = array(
'Register Globals' => 'register_globals',
'Short Tags' => 'short_open_tag',
'Display Errors' => 'display_errors',
'Magic Quotes GPC' => 'magic_quotes_gpc',
'Magic Quotes Runtime' => 'magic_quotes_runtime',
'Magic Quotes Sybase' => 'magic_quotes_sybase',
);
$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
foreach ($flags as $n => $v)
{
$flags[$n] = (in_array(strtolower(ini_get($v)), $neg) ? 'Off' : 'On');
}
$flags['Config file'] = get_cfg_var('cfg_file_path');
if (empty($flags['Config file']))
{
$flags['Config file'] = '-';
}
$cli = (php_sapi_name() == 'cli');
$eol = "\n";
$gle = get_loaded_extensions();
$rows = array();
$le = '';
$wide = 4;
$j = count($gle);
$pad = $wide - $j % $wide;
$len = max(array_map('strlen', $gle));
$func = create_function('$a', 'return str_pad($a, ' . intval($len) . ');');
$gle = array_map($func, $gle);
for($i = 0; $i < $j; $i += $wide)
{
$le .= ' ' . implode(' ', array_slice($gle, $i, $wide)) . $eol;
}
$ec = array(
'E_STRICT' => 2048, 'E_ALL' => 2047, 'E_USER_NOTICE' => 1024,
'E_USER_WARNING' => 512, 'E_USER_ERROR' => 256, 'E_COMPILE_WARNING' => 128,
'E_COMPILE_ERROR' => 64, 'E_CORE_WARNING' => 32, 'E_CORE_ERROR' => 16,
'E_NOTICE' => 8, 'E_PARSE' => 4, 'E_WARNING' => 2, 'E_ERROR' => 1,
);
$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
if (($t & $v) == $v)
{
$e[] = $n;
$t ^= $v;
}
}
if (ceil(count($ec) / 2) + 1 < count($e))
{
$e2 = array();
foreach ($ec as $n => $v)
{
if (!in_array($n, $e) and $n != 'E_ALL')
{
$e2[] = $n;
}
}
$er = $er . ' ((E_ALL | E_STRICT) ^ ' . implode(' ^ ', $e2) . '))';
}
else
{
$er = $er . ' (' . implode(' | ', $e) . ')';
}
if (!$cli)
{
echo '<html><head><title>quick info</title></head><body><pre>', $eol;
}
echo 'PHP Version: ', $ve, $eol;
echo 'PHP OS: ', $os, $eol;
echo 'Error Reporting: ', $er, $eol;
foreach ($flags as $n => $v)
{
echo $n, ': ', $v, $eol;
}
echo 'Loaded Extensions:', $eol, $le, $eol;
if (!$cli)
{
echo '</pre></body></html>', $eol;
}
?>