Page 1 of 1

$_GET not being recognised by SQL statements

Posted: Wed Jan 05, 2005 4:09 am
by TheOracle
Hi All,

I have a couple of SQL statements which I'm struggling with. I'm passing a variable called 'lea' in the url, but when I try and 'get' it using SQL it seems to ignore it.

I know the variable is set as if I print it to the screen it displays correctly.

The first statement is

Code: Select all

select * from table where column = '".$_GETї'lea']."'
I haven't had this problem with other similar statements.

The other statement is an insert

Code: Select all

insert into table (site_id, site_name) values ('".$_GETї'lea']."','".$_POSTї'sitename']."')
Again no problems with other similar statements. The insert seems to simply ignore this and insert the default value of 0, but the select returns an error stating an error in in SQL syntax:

Code: Select all

select * from table where column =
so it effectively can't see the $_GET variable?

Any ideas?

Posted: Wed Jan 05, 2005 4:57 am
by AVATAr
Show the complete code ;)

Posted: Wed Jan 05, 2005 5:06 am
by TheOracle
This is the statement which is passed when no errors are found.

Code: Select all

$result=mysql_query("insert into ora_details (site_id, site_name, dba_subscriber, os_used, os_version, ora_version, 
                    conn_type, server_ip, server_subnet, server_gateway, ora_port_no, db_name1, db_name2, server_use, 
                    ras_user, ras_pass, ras_sp_det, ras_dial, direct_dial, pc_any_user, pc_any_pass, os_user, os_pass, 
                    vpn_name, vpn_user, vpn_pass, vpn_det, web_url, add_det, timestamp) 
                    values 
                    ('".$_GET['lea']."','".$_POST['sitename']."','".$_POST['dbasub']."','".$_POST['osused']."','".$_POST['osversion']."', 
                    '".$_POST['oraver']."','".$_POST['conntype']."','".$_POST['serverip']."','".$_POST['serversub']."', 
                    '".$_POST['servergate']."','".$_POST['oraportno']."','".$_POST['dbname1']."','".$_POST['dbname2']."', 
                    '".$_POST['serveruse']."','".$_POST['rasuser']."','".$_POST['raspass']."','".$_POST['rasspdet']."','".$_POST['rasdial']."', 
                    '".$_POST['directdial']."','".$_POST['pcanyuser']."','".$_POST['pcanypass']."','".$_POST['osuser']."', 
                    '".$_POST['ospass']."','".$_POST['vpnname']."','".$_POST['vpnuser']."','".$_POST['vpnpass']."', 
                    '".$_POST['vpndet']."','".$_POST['weburl']."','".$_POST['adddet']."', now())") or die(mysql_error());
As I said before, it inserts all the data, but puts the default value of 0 into the site_id column. I have tried this when the lea=1 in the url and it doesn't work, but when I replace the varibale in the insert with the number 1 it does work?

Any other ideas?

Posted: Wed Jan 05, 2005 5:09 am
by AVATAr
change this '".$_GET['lea']."' for '.$_GET['lea'].' (i remove double quotes)

Posted: Wed Jan 05, 2005 9:12 am
by feyd
quick guess here, maybe 'lea' technically doesn't exist? Do a

Code: Select all

var_export($_GET)
to see.