Hello -
I'm having a little problem with a database query string. The $grev and $year vars are collected by an input box in the same script. They are coming in as string vars and seem to be goofing up my query string. Actually, you can see the page here:
http://zegelin.com/php/home/addmovie.php
If I hard code arbitrary values into the query string, it does work. When i substitute the variables, the mysql_query() fails.
[CODE]if ( $grev == "" )
$gf = n;
else
{
$gf = y;
settype( $grev, "integer");
if ( !is_int( $grev ) ) $gf = n;
}
if ( $seen == "on" ) $haseen = 1;
$flag = $tf . $yf . $gf;
switch( $flag ) {
case "yyy":
// connect to DB
$socket = connectDb('movieuser','linux','localhost', $db);
// create query command using above array
// this first one works properly
$qstr = "INSERT INTO grossRevenue ( revenue, title, year ) VALUES ( 45, '".$title."', 1945 )";
// these two do not
$qstr = "INSERT INTO grossRevenue ( revenue, title, year, viewed ) VALUES ( ".$grev.", '".$title."', 1978, ".$haseen." )";
$qstr = "INSERT INTO grossRevenue ( revenue, title, year, viewed ) VALUES ( $grev, '".$title."', 1978, ".$haseen." )";
//perform the query
$query = mysql_query( $qstr, $socket );
mysql_close( $socket );
break;[/CODE]
The $haseen var is declared $haseen = 0; and does work.
The revenue field is a bigint(20)
The year field is an int(11)
I have tried to declare the data type $year = 0; but that doesn't help.
The settype() & is_int() functions are working, as well, the query string just doesn't want to work..
Thanks in advance for any help you can provide.