Author Topic: Need help with variables in Query  (Read 271 times)

0 Members and 1 Guest are viewing this topic.

Offline elentzTopic starter

  • Enthusiast
  • Posts: 134
    • View Profile
Need help with variables in Query
« on: February 16, 2010, 04:35:00 PM »
I have a select and an update query that work perfectly if I manually enter the record numbers for cf_565,  and id.  The  fields get updated as they should.  as soon as I try to use the variables $cf_565 and $id it fails.  I get no error messages.  Here is my code

$result15 mysql_query("SELECT

vtiger_crmentity.description,

vtiger_troubletickets.solution,

vtiger_troubletickets.ticketid

FROM

vtiger_troubletickets

Inner Join vtiger_crmentity ON vtiger_troubletickets.ticketid = vtiger_crmentity.crmid

WHERE

vtiger_troubletickets.ticketid =  
$cf_565");



$row mysql_fetch_array($result15);

$trouble$row['description'];

$fix =$row['solution'];

$sql "Update communiq_vtcrm1.vtiger_invoice x, communiq_vtcrm1.vtiger_crmentity z Set x.terms_conditions= '$fix' , z.description='$trouble' Where z.crmid = $id and x.invoiceid = $id";

$result mysql_query($sql);



I would also like to use an IF statement to ignore the above code and continue using another variable  such as $cf_581 which is a checkbox and it would be true with a 1
Thanks for suggestions where I am going wrong

Offline fenway

  • MySQL Si-Fu / PHP Resident Alien
  • Global Moderator
  • 'Mind Boggling!'
  • *
  • Posts: 15,443
  • Gender: Male
    • View Profile
Re: Need help with variables in Query
« Reply #1 on: February 23, 2010, 12:49:46 PM »
Other than the fact that you're not quoting (or santizing, for that matter) your input value, it's hard to say without seeing the actual sql statements and errors.
:anim_rules: Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.