Jump to content


Photo

inserting php in SQL statement??


  • Please log in to reply
2 replies to this topic

#1 gabs

gabs
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 30 June 2006 - 12:01 PM

Hi, I want to insert PHP in an SQL statement..how do I do this? This is what I want to do...

         
$A4 = "Depth = 297 AND Width = 210 ";
	

	[color=red]*[/color]$query = "SELECT Quantity FROM Enquiries WHERE $A4";
	$result = odbc_exec($conn, $query) or die (odbc_error());

I get this error message...
Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near ''., SQL state 37000 in SQLExecDirect in C:\Program Files\xampp\htdocs\valuesx.php on line 93
37000

line 93 is *

#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 30 June 2006 - 12:08 PM

You need to match it against a field in the database, for example:
$query = "SELECT Quantity FROM Enquiries WHERE measurement = '$A4'


#3 gabs

gabs
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 30 June 2006 - 12:09 PM

Ok, I have found my own answer....

$papertype = "SELECT Quantity FROM Enquiries WHERE Depth = 297 AND Width = 210"
}


$query = $papertype;
$result = odbc_exec($conn, $query) or die (odbc_error());







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users