Welcome to WebmasterWorld Guest from 54.226.27.104

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

why isnt mysql value displaying

$min_id doesnt have a value when diplayed

     

nil111

10:37 am on Aug 25, 2008 (gmt 0)

5+ Year Member



here values for $val_name and $val gets displayed.
but $min_id seems to be null coz nothing is displaying there.
there's no problem with tha database connection as well.
wats wron here? thanks in advance....

[CODE:PHP]

<?php
echo"value name is: $val_name";
echo "<br />";
echo"the value is: $val";

if($val_name == 'medium')
{
$q_min = "SELECT min(p_painting_id) FROM paintings where p_painting_medium like '".$val."'";
}

elseif($val_name == '_cid')
{
$q_min = "SELECT min(p_painting_id) FROM paintings join paintings_categories on paintings_categories.pc_paint_id = paintings.p_painting_id where pc_category_id = {$val}";
}

elseif($val_name == 'tag')
{
$q_min = "SELECT min(p_painting_id) FROM paintings join tags on tags.t_painting_id = paintings.p_painting_id where t_text like '".$val."'";
}

$db = new dbConn();
$db->connect();
$res_min = mysql_query($q_min) or mysql_error();
while ($row_min = mysql_fetch_assoc($res_min))
{
$min_id = $row_min['p_painting_id'];
}
echo "$min_id";
?>
[\CODE:PHP]

nil111

11:23 am on Aug 25, 2008 (gmt 0)

5+ Year Member



hey I found the error..

for anyone interested the error is near min(p_painting_id).

it should b,
min(p_painting_id) as min_val

(min_val can be any other name)
and
$min_id = $row_min['min_val'];

:)

jatar_k

1:47 pm on Aug 25, 2008 (gmt 0)

WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member



good eye nil111 :)
 

Featured Threads

Hot Threads This Week

Hot Threads This Month