elentz Posted July 29, 2007 Share Posted July 29, 2007 Given the code below, I need to run the queries according to the IF statement. Can some one show me how to do this?? Thanks alot! $taxablequote = "SELECT `vtiger_quotes`.`quoteid`, `vtiger_accountscf`.`cf_455` FROM `vtiger_quotes` Inner Join `vtiger_account` ON `vtiger_quotes`.`accountid` = `vtiger_account`.`accountid` Inner Join `vtiger_accountscf` ON `vtiger_accountscf`.`accountid` = `vtiger_account`.`accountid` WHERE `vtiger_quotes`.`quoteid` = '$record'"; $RESULT = MYSQL_QUERY($taxablequote,$conn); if (cf_455 = 1) { $quotetaxable = "update vtiger_quotes set salestax = subtotal * .06 Where quoteid = $record"; $result = mysql_query($quotetaxable,$conn)} else {$quotenontaxable = "update vtiger_quotes set salestax = "0.00" where quoteid = $record"; $result = mysql_query($quotenontaxable,$conn)}; $grandtotal = "update vtiger_quotes set total = subtotal + s_h_amount + salestax - adjustment"; $result = mysql_query($grandtotal,$conn); Link to comment https://forums.phpfreaks.com/topic/62268-can-some-one-show-me-what-i-have-wrong/ Share on other sites More sharing options...
Daniel0 Posted July 29, 2007 Share Posted July 29, 2007 It is probably if (cf_455 = 1) { which is wrong. It should probably be if ($cf_455 = 1) { Link to comment https://forums.phpfreaks.com/topic/62268-can-some-one-show-me-what-i-have-wrong/#findComment-309928 Share on other sites More sharing options...
Barand Posted July 29, 2007 Share Posted July 29, 2007 or even if ($cf_455 == 1) { Link to comment https://forums.phpfreaks.com/topic/62268-can-some-one-show-me-what-i-have-wrong/#findComment-309977 Share on other sites More sharing options...
elentz Posted July 29, 2007 Author Share Posted July 29, 2007 Well, I tried if ($cf_455 = 1){ and if ($cf_455 ==1){ Neither one worked any other suggestions? Thanks Link to comment https://forums.phpfreaks.com/topic/62268-can-some-one-show-me-what-i-have-wrong/#findComment-310001 Share on other sites More sharing options...
AndyB Posted July 29, 2007 Share Posted July 29, 2007 "didn't work" doesn't help. If $cf_455 is a defined value it should work with the comparison operator == (as Barand posted). On the other hand, if $cf_455 is taken from a database, you need to abstract it from the query result before using it. Link to comment https://forums.phpfreaks.com/topic/62268-can-some-one-show-me-what-i-have-wrong/#findComment-310009 Share on other sites More sharing options...
elentz Posted July 29, 2007 Author Share Posted July 29, 2007 Sorry about the doesn't work. If I comment out the If / Else statements my page loads just fine (without doing what I want). I think you might have something there about abstracting the cf_455. I tried to echo it to the screen without the if/Else and I got nothing, other than what I got with all the if/else commented out. I'll see what I can do to extract it. If I am right I should be OK if/when I can echo it to the screen along with the page itself. Thanks Link to comment https://forums.phpfreaks.com/topic/62268-can-some-one-show-me-what-i-have-wrong/#findComment-310011 Share on other sites More sharing options...
PC Nerd Posted July 29, 2007 Share Posted July 29, 2007 isset($cf_455) and empty($cf_455) might help Link to comment https://forums.phpfreaks.com/topic/62268-can-some-one-show-me-what-i-have-wrong/#findComment-310013 Share on other sites More sharing options...
elentz Posted July 29, 2007 Author Share Posted July 29, 2007 PC Nerd, Where would I apply that? Sorry just enough of a nerd to be dangerous! Thanks Link to comment https://forums.phpfreaks.com/topic/62268-can-some-one-show-me-what-i-have-wrong/#findComment-310015 Share on other sites More sharing options...
AndyB Posted July 29, 2007 Share Posted July 29, 2007 Where would I apply that? Nowhere if the value of $cf_455 is coming from the database - it'll always be 'set' and never 'empty'. Where does $cf_455 come from - database or user input? Link to comment https://forums.phpfreaks.com/topic/62268-can-some-one-show-me-what-i-have-wrong/#findComment-310026 Share on other sites More sharing options...
elentz Posted July 29, 2007 Author Share Posted July 29, 2007 The very first query is where cf_455 comes from. Although I can't get it to even echo on the page. If I run that query in phpmyadmin I get either a 1 or 0 result depending on the quoteid I use. The quoteid is in a session that is used elsewhere on the page in other queries down the page from this one. So I think I might not be getting the cf_455 info and that might be why it is failing. Thanks Link to comment https://forums.phpfreaks.com/topic/62268-can-some-one-show-me-what-i-have-wrong/#findComment-310030 Share on other sites More sharing options...
Barand Posted July 29, 2007 Share Posted July 29, 2007 After the mysql_query, you could extract (mysql_fetch_assoc($RESULT)); Link to comment https://forums.phpfreaks.com/topic/62268-can-some-one-show-me-what-i-have-wrong/#findComment-310033 Share on other sites More sharing options...
elentz Posted July 30, 2007 Author Share Posted July 30, 2007 Well, I think I have the problem identified. I believe I am not getting the value of cf_455. So I have changed my query to only get the field cf_455. I can't seem to get the output of that query. Here is what I have not: $sql = 'SELECT ' . ' `vtiger_accountscf` . `cf_455` ' . ' FROM ' . ' `vtiger_quotes` ' . ' Inner Join `vtiger_account` ON `vtiger_quotes` . `accountid` = `vtiger_account` . `accountid` ' . ' Inner Join `vtiger_accountscf` ON `vtiger_accountscf` . `accountid` = `vtiger_account` . `accountid` ' . ' WHERE ' . ' `vtiger_quotes` . `quoteid` = \ '16124\' LIMIT 0, 30; $RESULT = MYSQL_QUERY($sql,$conn); Print '$cf_455'; At this point if I could get the information onto the page I will be happy. Then I need to get it to get the other queries to work. Thanks for looking at my stuff! Ed Link to comment https://forums.phpfreaks.com/topic/62268-can-some-one-show-me-what-i-have-wrong/#findComment-310608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.