Jump to content

scottybwoy

Members
  • Posts

    532
  • Joined

  • Last visited

    Never

Everything posted by scottybwoy

  1. Sorry, thought it was a simple question //If product already exists, update the row. if (array_key_exists($modelId, $_SESSION['item_buy'])) { $price = number_format($price, 2, '.', ''); $session_qty = $_SESSION['item_buy'][$modelId][1] + $qty; $prod_net = number_format($qty * $price, 2, '.', ''); $prod_vat = number_format($prod_net * VAT, 2, '.', ''); $prod_gross = number_format($prod_net + $prod_vat, 2, '.', ''); $_SESSION['item_buy'][$modelId] = array($price, $session_qty, $prod_net, $prod_vat, $prod_gross); } else { $_SESSION['item_buy'][$modelId] = array($price, $qty, $prod_net, $prod_vat, $prod_gross); }
  2. When, the going to the other pages is it being set anywhere else, and then not going through the unset process? We won't be able to help you with the code you provided, you would need to look through the code that it flows through to bring the message up.
  3. I have a number of sql abstraction functions, but this one always displays a notice message, but returns the correct result. What do I need to iron out? function selectRecord($record, $tbl, $col, $val) { $sql = "SELECT $record FROM $tbl WHERE $col = "; if (is_int($val)) { $sql .= "$val"; } else { $sql .= "'" . $val . "'"; } //echo $sql; $qry = mssql_query($sql); $res = mssql_result($qry, 0, 0) or trigger_error("$sql Failed", E_USER_NOTICE); return $res; } Thanks.
  4. Is their a problem using $_SESSION variables in array_key_exists? I use it, it works but brings up a notice. Is there any reason why I shouldn't use it, if the session var is actually an array?
  5. I think this can be done, just using an SQL query, but I'm not sure of the syntax, your Joins are the right way about it though. It would certainly be quicker.
  6. Ok, I've tried that and it doesn't seem to return anything. What am I doing wrong? $arr = array($prod_array['purchasing'], $prod_array['technical']); $rand = array_rand($arr, 1); $prod_array['display'] = $rand[0]; echo $prod_array['display']; [edit] No worries, sussed it using this : $arr = array($prod_array['purchasing'], $prod_array['technical']); $rand = array_rand($arr, 1); $prod_array['display'] = $arr[$rand]; Is this the best way to go about it?
  7. Hi, I have two bits of data in an array, and I just want to choose one randomly. How can this be done? Basically I get two blurbs of information, but it is two long to display them both so I want to just display one at a time randomly. I had a look for how to do it in MSSQL but there only seems to be ways of getting a random row, not column. Thanks.
  8. Is this : if($cat !== 1|6) { The right way to go about it. If so why doesn't it seem to work? P.S. $cat is an integer between 1-8.
  9. You may want to look at this article from "A List Apart" which looks into the use of tabloid style columns for reading on the web. I've not used it myself and don't know how affective it is but is worth a go.
  10. lol, sorry that last bit was funny. Anyway, if you don't want to lose performance with an abstraction layer, I started off using MSSQL in my company, developed my own db class. Since then I've just copied it for MySQL and changed it all to do the MySQL features. You can do that for any db you like, call the functions the same and you just have a bunch of DB classes to choose from depending on what project you do, simple.
  11. Hi Obsidian, Sorry I've been doing other stuff, but I have come back to it and found that when I replace the pound sign with what you suggested, it displays the '£' symbol. Sorry, I'm not to hot on this area and am getting confused as to what parts get encoded when and for where? Thanks for your help though.
  12. The comment block is fairly standard <!-- footer //--> Although one guy did have the same issue, deleted the comment block and left a blank line, and it still reported an error on that line. I posted a link to the site, so people can see for themselves what is going on. Thanks.
  13. I seem to have stumbled upon an issue, that I have been trawling around the web for only to return with more confusion. I tried running W3C HTML Validator on this e-commerce site I've been working on, and it returned this error : Sorry, I am unable to validate this document because on line 284 it contained one or more bytes that I cannot interpret as utf-8 (in other words, the bytes found are not valid values in the specified Character Encoding). Please check both the content of the file and the character encoding indication. The error was: utf8 "\xA3" does not map to Unicode I had a look at the output and line 284, it is just a comment block, like many others in the same file. I tried converting the php file to UTF8 encoding but that just cocked up how the file executed (strange). But I really don't know what the problem is. All other sites php generated pages can be validated. My doctype declaration is correct. Could is be something to do with the server? I'm really lost, anyone solved this before?
  14. Thanks Wildteen88, I think we are finally getting somewhere. That produced this : stdClass Object ( [scalar] => PCIDS/LP/R [stock] => -20 ) What I really need is (using examples in above post): stdClass Object ( [network_card] => stdClass Object ( [stock] => 60 ) ) I finally got that by using : $modObj = new stdClass(); $modObj->$modelId->stock = $stockTotal; Thanks everyone that helped me get there. Cheers again
  15. I am using php version 5.2.5. If you look at my first bit of code you can see that I tried that first. All it returns via print_r is the value of $modelId it doesn't convert it to an object. Any other ideas?
  16. I tried that first and I got a fatal error. But I can see how this exec() could work, even though it may be a bit slower.
  17. Do I need to use a set_var declaration along with output in my exec to use the object? What would I need to put for those parameter?
  18. Thanks for your help, it's just annoying, coming from one language to another, and knowing what you want to do, but not knowing the syntax. I went with the undifined version, works like a charm thanks.
  19. <a href="control.php?link=www.google.com" target="_blank">google</a> I think thats what you want
  20. Ok, lets say the value of $modelId is "network_card" and the value of $file is "models5" and $stockTotal = 60. I want $models_stockArr to look something like this : $models_stockArr = array("models5" => Obj["network_card" -> stock : 60]) There will be different models for the files and then different files, so I'm trying to build something like : $models_stockArr = array("models5" => (Obj["network_card" -> stock : 60],["24port_switch" -> stock : 10]), "models6" => (Obj["firewire_card" -> stock : 35])) etc. I hope that clears things up a bit. Cheers
  21. Thanks samshel, I tried using your code, but it still only gives the $modelId as a value in the $file array. Which is what I had before. It won't be run 1,000,000's of times, only by the amount of products sold in an order, so the maximum is dependant on how many products we have, which at present is ~ 150. Strangely if I change the name to $obj, and dump the result it is empty, whilst $modelId remains the actual modelId, so therefore, it doesn't seem to be doing anything. Do I need to have specific settings to use this exec? Also I wanted the object name to be the same as the modelId so I changed it a bit. My code looks like such now, let me know where I've gone wrong $modelId = $v['modelId']; $stockTotal = $stockArr['stockTotal']; $file = "models$cat"; $class = $modelId; exec("class $class { var stock = $stockTotal; } $obj = new $strTime();"); $fnames = array($file => $obj); array_push($models_stockArr, $fnames); As I said with your code it just returns $modelId as $modelId not an object, with my ammended one, it is blank. Thanks
  22. You can rewrite your SQL statement to do it in one go : INSERT INTO level1 ('idnum', 'name') VALUES (1, 'Abarquez-Agcaoili, Carmencita')
  23. Browser Error, I hope one of the moderators can clean the other one up. Sorry for the mess
  24. give your page a .php extension and replace <emptyempty> with <?php include(date&time.php); ?> But really you shouldn't use & in your file name and it would be better to have a file that gets all your data for your page at the top, and then just use <?=$var?> wherever you want your data. Also as masterAce14 says, you can probably just get away with using the date function if that's what you want. Good luck
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.