Jump to content

ale1981

Members
  • Posts

    65
  • Joined

  • Last visited

Everything posted by ale1981

  1. Thanks, I knew there would be a regex way, I am just useless when it comes to regex! I am guessing the .replace is quicker as it is done with one function?
  2. sorry, yes, i would like the string 'products.0.name' converted to string 'products[0][name]'
  3. I have a string e.g. products.0.name and I want to change the string to; products[0][name] I have come up with some code that works but is a bit of a hack, my code is below; var array = field.split("."); field = array[0]+'['+array[1]+']['+array[2]+']'; Is there a better way, I am sure there is using regex? Thanks
  4. Thanks for the detailed response. I am adding the fields dynamically so I do not know how many the user is going to have, I guess I could use a bit of JS to determine this. Yes the SQL query will be one query, I used the above as an example of what I needed. Thanks for all responses.
  5. Thanks Ch0cu3r that worked, I knew there would be a simple answer! I have 2 input fields that use the same variable array, e.g. <input type="text" name="productVariations[name][]" /> <input type="text" name="productVariations[price][]" /> Is there a different way?
  6. It's late in the day and I can't figure this one out, I know it's going to be pretty easy! I have a form which sends the following array; array:2 [▼ "names" => array:3 [▼ 0 => "Default" 1 => "100ml" 2 => "150ml;" ] "prices" => array:3 [▼ 0 => "12.99" 1 => "9.99" 2 => "14.99" ] I want to loop the array and do an insert using this array like so, the index from "names" and "prices"; INSERT INTO DB VALUES('Default',12.99); INSERT INTO DB VALUES('100ml',9.99); INSERT INTO DB VALUES('150ml',14.99); Thanks
  7. Hi BlueSky I have since amended the files, i have removed session_id() and the second instance of session_start() in the function. I used the session_save_path to make sure the session files were being created. With more testing, if I call the function get_user_details() every time in the header.php file then $_POST works fine, however if i only call it once to store the user details then $_POST doesnt work!? Is it something inside the function that is authenticating?
  8. New update! I think it is something in the function affecting $_POST. I have removed the function call and tried to create a session and everything seems to work, what in the function could be affecting the $_POST details, could it be the header calls?
  9. Sorry by break I mean that $_POST is always empty. If i remove; session_save_path($_SERVER['DOCUMENT_ROOT']. 'tmp/sessions'); session_id(); session_start(); from the top of my header.php file then $_POST works again!
  10. UPDATE: This breaks $_POST on all pages, however $_GET seems to work fine, this is giving me a huge headache!
  11. PHP 5.2.6 Apache 2.2.9 I am trying to store windows username / domain / workstation details into a session for our company intranet. I found a script on the internet that I can use to retrieve the information which I made into a function; function get_user_details() { // loune 25/3/2006, updated 22/08/2009 // For more information see: // http://siphon9.net/loune/2007/10/simple-lightweight-ntlm-in-php/ // // This script is obsolete, you should see // http://siphon9.net/loune/2009/09/ntlm-authentication-in-php-now-with-ntlmv2-hash-checking/ // // NTLM specs http://davenport.sourceforge.net/ntlm.html $headers = apache_request_headers(); if (!isset($headers['Authorization'])){ header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: NTLM'); exit; } $auth = $headers['Authorization']; if (substr($auth,0,5) == 'NTLM ') { $msg = base64_decode(substr($auth, 5)); if (substr($msg, 0, != "NTLMSSP\x00") die('error header not recognised'); if ($msg[8] == "\x01") { $msg2 = "NTLMSSP\x00\x02\x00\x00\x00". "\x00\x00\x00\x00". // target name len/alloc "\x00\x00\x00\x00". // target name offset "\x01\x02\x81\x00". // flags "\x00\x00\x00\x00\x00\x00\x00\x00". // challenge "\x00\x00\x00\x00\x00\x00\x00\x00". // context "\x00\x00\x00\x00\x00\x00\x00\x00"; // target info len/alloc/offset header('HTTP/1.1 401 Unauthorized'); header('WWW-Authenticate: NTLM '.trim(base64_encode($msg2))); exit; } else if ($msg[8] == "\x03") { function get_msg_str($msg, $start, $unicode = true) { $len = (ord($msg[$start+1]) * 256) + ord($msg[$start]); $off = (ord($msg[$start+5]) * 256) + ord($msg[$start+4]); if ($unicode) return str_replace("\0", '', substr($msg, $off, $len)); else return substr($msg, $off, $len); } $user = get_msg_str($msg, 36); $domain = get_msg_str($msg, 28); $workstation = get_msg_str($msg, 44); session_start(); $_SESSION['username'] = $user; $_SESSION['domain'] = $domain; $_SESSION['workstation'] = $workstation; } } } What i would like to do is store the information in a session so I can access the information without having to call the function on every page. I have a header.php file which is called on each page, so in this file i have added; require_once 'functions.php'; session_id(); session_start(); if (!$_SESSION['username']) { get_user_details(); } This works, but seems to be breaking certain pages that retrieve $_POST details but I can not figure out why?? I have tried to work it out for the past 3 days but cant seem to get it to work, any help would be greatly appreciated!
  12. SOLUTION for anybody interested; <table> <?php while ($ord_inf = mssql_fetch_array($result)) { if($lastOrderNo != $ord_inf['ORDERNO'] || $lastOrderNo == "") { $trclass = ($trclass == 'alt2') ? 'alt1' : 'alt2'; } $lastOrderNo = $ord_inf['ORDERNO']; ?> <tr class="<?php echo $trclass; ?>"> <td><?php echo $ord_inf['ORDERNO']; ?></td> </tr> <?php } ?> </table>
  13. Hi, thanks for your reply but all rows end up the same colour, using alt1.
  14. I can not figure this out, what I want to do is alternate the row colour of a table depending on a variable when looping through results from a db query, example; ORD123 ORD123 ORD124 and so on.. <table> $trclass = 'alt1' $trclass = 'alt2' while ($ord_inf = mssql_fetch_array($result)) { if ($ordinf['ORDERNO'] == $orderNo) { 'keep same tr class as its the same order' } else { 'its a different order so change the tr class' } <tr class="$trclass"> <td>$ord_inf['ORDERNO']</td> </tr> $orderNo = $ord_inf['ORDERNO']; } </table> something like that, i just cant seem to get it to work! any help appreciated... [/]
  15. Thanks obsidian, works great; foreach ($groupID as $k => $v) { $groupID[$k] = '"' .$v. '"'; } $groupNos = implode(',', $groupID); echo $groupNos;
  16. If I have an array similar to; Array ( [0] => 0010 [1] => 0020 [2] => 0030 [3] => 0040 [4] => 0050 [5] => 0060 ) How can i convert that array to a string, so the string will be like; "0010", "0020", "0030", "0040", "0050", "0060" Notice the "," is missing from the last part of the array. If the array has only one entry then it would be; "0010" Any help appreciated. Thanks in advance.
  17. Is it possible for me to combine these 2 SQL queries so I just get a combined Sales figure from both tables? SELECT SUM(SUBTOTAL) AS Sales FROM SOP30200 WHERE (CUSTNMBR = 'HLS0003') AND (SOPTYPE = 2) AND (PRSTADCD = '0012') SELECT SUM(SUBTOTAL) AS Sales FROM SOP10100 WHERE (CUSTNMBR = 'HLS0003') AND (SOPTYPE = 2) AND (PRSTADCD = '0012') Thanks in advance.
  18. I would use the solution above or by storing the disallowed names in lowercase form in a db table and query the table; strtolower($_POST['username']); $sql = 'SELECT * FROM dissallowed_users WHERE username="' .$_POST['username']. '"';
  19. Hi sasa, Can you explain a bit further what exactly this will achieve? Thanks
  20. Unfortunately not! One query is done on a MSSQL db and the other a MYSQL. The inventory system we use at work uses MSSQL, but i prefer to use MySQL where i can and i am in the process of doing our intranet.
  21. That still repeats, like; Driver Manifest Date The following 1 PDF(s) have been found: PW 22/10/2007 View The following 1 PDF(s) have been found: PW 19/10/2007 View I would like it to just show; The following 2 PDF(s) have been found: Driver Manifest Date PW 22/10/2007 View PW 19/10/2007 View
  22. Thanks for your reply Wuhtzu, I knew it would be fairly simple, but I think i thought of that, and then failed on how to get the num of PDFs to display correctly?
  23. I have been trying to work this out all afternoon and there is probably an easy solution, but I can not think of it! My current code loops through a result of order number's. Now if there is just one manifest returned for that order number, this is fine, BUT, if there is more than one i obviously get the 2 tables instead of just the one with 2 rows. I know its because the while is looping through each order number and therefore showing the code below for each manifest. How can i re-arrange this so that just one table is shown ? while($man_inf = mssql_fetch_array($result)) { $man_date = convert_date($man_inf['PDATE']); $sql2 = 'SELECT pid, title, driver, man_date, size FROM manifestPDF WHERE (man_date = ' .$man_date. ') AND (driver = "' .trim($man_inf['UPSZONE']). '")'; $result2 = mysql_query($sql2); $num_PDFs = mysql_num_rows($result2); echo '<p>The following ' .$num_PDFs. ' PDF(s) have been found: </p>'; ?> <table class="sep" width="250"> <tr> <td class="title">Driver</td> <td class="title" colspan="2">Manifest Date</td> </tr> <? if ($num_PDFs > 0) { while($PDF_inf = mysql_fetch_array($result2)) { $man_date = date('d/m/Y', $PDF_inf['man_date']); ?> <tr> <td><?=$PDF_inf['driver'];?></td> <td><?=$man_date?></td> <td><a href="view_manifest.php?id=<?=$PDF_inf['pid']?>">View</a></td> </tr> <? } echo '</table> <p><a href="javascript: history.go(-1)">SEARCH AGAIN</a></p>'; } else { echo '<p>No Manifests found with that criteria.</p> <p><a href="javascript: history.go(-1)">SEARCH AGAIN</a></p>'; } } Thanks in advance and apologise if its a simple solution, my brain is dead today.
  24. Hi guys, I am a bit stuck! Here is what I need to do; User scans a document in and sends the document to a mailbox. I then need a script to log into that mailbox every x minutes to check to see if there is any new emails. If there is I need to download the attachment to a location and then once the file has been saved succesfully, i need to mark it so it wont get read again. The purpose of this is so that I can then display these PDFs on an intranet page so that users can view the documents, i would prefer it to be all automated instead of me going through the inbox manually and moving them myself. I have had experience in sending emails with attachments, but never reading them and saving the attachments. Any help would be very much appreciated. Thanks.
×
×
  • 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.