mysql_query

mysql_query

am 06.06.2011 23:11:06 von Chris Stinemetz

Hello all,

Not sure what I am doing wrong.

I have a simple form that populate the variables in a mysql query. I
know the selected values are making it to the form porcessing script
because I can echo them on the processing script as indicated below.

You Selected Cell_Sect = 1_1
You Selected Date = 03/10/11 18:15
You Selected Market = MCI

For some reason the above is all I am getting when I submit my form.

I beleive it has somthing to do with my results query below.

$result = mysql_query("select * FROM evdo WHERE Market like '%$term'
and Cell_Sect = '$cat' and Date = '$subcat' LIMIT 10");

Beow is my whole script for processing the form in case it maybe something else.

Thanks,

Chris






// database access parameters
$dbservertype='mysql';
$servername= left out for privacy;
// username and password to log onto db server
$dbusername='$$$$';
$dbpassword='$$$$';
// name of database
$dbname='pcmd';

connecttodb($servername,$dbname,$dbusername,$dbpassword);
function connecttodb($servername,$dbname,$dbuser,$dbpassword)
{
global $link;
$link=mysql_connect ("$servername","$dbuser","$dbpassword");
if(!$link){
die('Could not conect: ' . mysql_error());
}
echo 'YOU ARE CONNECTED TO PCMD DATABASE';

mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
}
//////// End of connecting to database ////////
?>
'http://www.w3.org/TR/xhtml1-transitional.dtd'>

Demo Multiple drop down list box for PCMD data






$cat=$_POST['cat'];
$subcat=$_POST['subcat'];
$term=$_POST['term'];

$result = mysql_query("select * FROM evdo WHERE Market like '%$term'
and Cell_Sect = '$cat' and Date = '$subcat' LIMIT 10");


$firstRow=1;
$rowNum = 0;
echo "

";
while($row = mysql_fetch_assoc($result)) {
if($firstRow == 1) {
echo "";

foreach($row as $key => $value) {
echo "";
}
echo "";
$firstRow=0;
$rowNum++;
}
else {
if( ($rowNum++ % 2) == 1) {
echo "";
} else {
echo "";
}
}
foreach($row as $key => $value ) {
echo "" ;
}
echo "";
}
echo "
" . $key . "
" . $value . "
";

echo "You Selected Cell_Sect = $cat
You Selected Date =
$subcat
You Selected Market = $term";


?>





--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: mysql_query

am 06.06.2011 23:40:50 von Niel Archer

> Hello all,
>
> Not sure what I am doing wrong.
>
> I have a simple form that populate the variables in a mysql query. I
> know the selected values are making it to the form porcessing script
> because I can echo them on the processing script as indicated below.
>
> You Selected Cell_Sect = 1_1
> You Selected Date = 03/10/11 18:15
> You Selected Market = MCI
>
> For some reason the above is all I am getting when I submit my form.
>
> I beleive it has somthing to do with my results query below.
>
> $result = mysql_query("select * FROM evdo WHERE Market like '%$term'
> and Cell_Sect = '$cat' and Date = '$subcat' LIMIT 10");
>
> Beow is my whole script for processing the form in case it maybe something else.
>
> Thanks,
>
> Chris
>
>
>
>
>
> >
> // database access parameters
> $dbservertype='mysql';
> $servername= left out for privacy;
> // username and password to log onto db server
> $dbusername='$$$$';
> $dbpassword='$$$$';
> // name of database
> $dbname='pcmd';
>
> connecttodb($servername,$dbname,$dbusername,$dbpassword);
> function connecttodb($servername,$dbname,$dbuser,$dbpassword)
> {
> global $link;
> $link=mysql_connect ("$servername","$dbuser","$dbpassword");
> if(!$link){
> die('Could not conect: ' . mysql_error());
> }
> echo 'YOU ARE CONNECTED TO PCMD DATABASE';
>
> mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error());
} <- What's this doing here
> //////// End of connecting to database ////////
> ?>
> > 'http://www.w3.org/TR/xhtml1-transitional.dtd'>
>
> Demo Multiple drop down list box for PCMD data
>
>
>
>
>
>
> > $cat=$_POST['cat'];
> $subcat=$_POST['subcat'];
> $term=$_POST['term'];
>
> $result = mysql_query("select * FROM evdo WHERE Market like '%$term'
> and Cell_Sect = '$cat' and Date = '$subcat' LIMIT 10");
>
>
> $firstRow=1;
> $rowNum = 0;
> echo "

";
> while($row = mysql_fetch_assoc($result)) {
> if($firstRow == 1) {
> echo "";
>
> foreach($row as $key => $value) {
> echo "";
> }
> echo "";
> $firstRow=0;
> $rowNum++;
> }
> else {
> if( ($rowNum++ % 2) == 1) {
> echo "";
> } else {
> echo "";
> }
> }
> foreach($row as $key => $value ) {
> echo "" ;
> }
> echo "";
> }
> echo "
" . $key . "
" . $value . "
";
>
> echo "You Selected Cell_Sect = $cat
You Selected Date =
> $subcat
You Selected Market = $term";
>
>
> ?>
>
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

After your mysql_select_db() there is a closing brace without matching
open. This will be causing an error in that php block.

--
Niel Archer
niel.archer (at) blueyonder.co.uk


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php