Jump to content

completeNewb

Members
  • Posts

    18
  • Joined

  • Last visited

    Never

Everything posted by completeNewb

  1. kicken, not only did you explain why my efforts failed but your solution works like a charm! endless thanks, Steve
  2. Thanks for your replies... first, auto increment is not an option, unfortunately I have two databases to juggle, one is a subset of the other (products on the website). The master database is ms sql which won't run on a unix server (the website). The master database is on an office server with a poor connection unsuited for web users to connect to. second, fetch_num_rows to get the latest id (assuming you dont delete any rows)-- but, hey, rows will get deleted. So, I need a web database that will accept updated IDs from the master database. I searched long and hard and tried numerous solutions. Sorry but the my meaningless procedure is the best I could come up with. Believe me, i would be overjoyed if anyone's got another. $sql = "SELECT * FROM prods ORDER BY IDCOL DESC limit 0,1" ; looks to me like it would select every column (?) when i only want the last ID, but I just tried it and sadly it also returns 0. This sql: SELECT IDCOL FROM prods ORDER BY IDCOL DESC LIMIT 1 works in phpMyAdmin, but once i write it as php... $newid = mysql_query('SELECT IDCOL FROM prods ORDER BY IDCOL DESC LIMIT 1'); it returns 0. I don't understand why. Steve
  3. Hi, I'm trying to get the last number from a column of numbers, add 1 to it and use this to insert a new value in the column. The column is not the primary key, indexed, or auto insert, it's just a plain old int field. $newid = mysql_query('SELECT IDCOL FROM prods ORDER BY IDCOL DESC LIMIT 1'); // the above just doesn't work--it returns 0, there are over 1200 products--I'm going nuts over this. //$newid += 1; I've commented this out, it works though (in that it adds 1 to 0) $sql = mysql_query("INSERT INTO prods (IDCOL , Prod_Code, blah... blah..) VALUES('$newid','$prod_code','blah... blah...')") or die (mysql_error()); //this works (but inserts 0 as the newID) You'd think this would be so easy. Thanks Steve
  4. If anyone else ever experiences this particular horror, the answer is to uncheck rich text formatting on the posted pdf fields. Thanks to everyone who helped me. I'm immensely grateful for your efforts. I know how to make this work now--I can dump the address array--but I'd rather not. So I do have one last question. Why isn't my if ( $addrItem = 'pharmName' ) statement working? Somehow it appears to put the wrong value (the account number) into $pharmName when, of course, I'm tryying for the input pharmacy name. Here's my page code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php echo 'This is post: <br>'; print_r( $_POST ); echo '<br>'; echo '<br>'; echo '<br>'; $address = $_POST['addr']; $orders = $_POST['prodCode']; foreach( $address as $addrItem => $addrLine ) { if ( $addrItem = 'pharmName' ) { echo 'fld name: '.$addrItem.' user typed: '.$addrLine; $pharmName = $addrLine; break; } echo '<br>'; } echo '<br>'; echo ("Pharmacy: <input class=\"inputbox\" type=\"text\" name=\"pharmName\" maxlength=\"40\" value=\"$pharmName\"><br>"); ?> <form name="form1" method="post" action=""> <input name="name" type="text" id="name" value="<?php echo $pharmName; ?>"> <form action="orderSent.php" method="post"> <input type="submit" /> </p> </form> </body> </html> And here's the source (if that helps) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> This is post: <br>Array ( [addr] => Array ( [Acc] => Acc num [contactName] => contact name [pharmName] => Pharm name [suburbName] => A suburb [wSalerName] => wsaler ) [prodCode] => Array ( [6722] => 2 [6724] => 2 ) [button6] => ) <br><br><br>fld name: pharmName user typed: Acc num<br>Pharmacy: <input class="inputbox" type="text" name="pharmName" maxlength="40" value="Acc num"><br> <form name="form1" method="post" action=""> <input name="name" type="text" id="name" value="Acc num"> <form action="orderSent.php" method="post"> <input type="submit" /> </p> </form> </body> </html> Steve
  5. Hi, looking at the above (the IE source) I'm thinking that if I turn the address fields into an array like the prodCode array I might get clean variables. Will try that after lunch. Thanks all. Steve
  6. Oops, I just looked with IE (was using firefox) seems there's a lot more on offer. Sorry, Steve <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> Array ( [Acc] => <?xml version="1.0"?><body xfa:APIVersion="Acroform:2.6.7116.0" xfa:spec="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;font-family:Arial;font-size:12pt">1234</p></body> [contactName] => <?xml version="1.0"?><body xfa:APIVersion="Acroform:2.6.7116.0" xfa:spec="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;font-family:Arial;font-size:12pt">me</p></body> [pharmName] => <?xml version="1.0"?><body xfa:APIVersion="Acroform:2.6.7116.0" xfa:spec="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;font-family:Arial;font-size:12pt">Some pharm</p></body> [prodCode] => Array ( [6722] => 2 [6724] => 2 ) [suburbName] => <?xml version="1.0"?><body xfa:APIVersion="Acroform:2.6.7116.0" xfa:spec="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;font-family:Arial;font-size:12pt">Somewhere</p></body> [wSalerName] => wholesaler [button6] => ) <?xml version="1.0"?><body xfa:APIVersion="Acroform:2.6.7116.0" xfa:spec="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;font-family:Arial;font-size:12pt">Some pharm</p></body>Pharmacy: <input class="inputbox" type="text" name="pharmName" maxlength="40" value="<?xml version="1.0"?><body xfa:APIVersion="Acroform:2.6.7116.0" xfa:spec="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;font-family:Arial;font-size:12pt">Some pharm</p></body>"><br> <form name="form1" method="post" action=""> <input name="name" type="text" id="name" value="<?xml version="1.0"?><body xfa:APIVersion="Acroform:2.6.7116.0" xfa:spec="2.1" xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"><p dir="ltr" style="margin-top:0pt;margin-bottom:0pt;font-family:Arial;font-size:12pt">Some pharm</p></body>"> <form action="orderSent.php" method="post"> <input type="submit" /> </p> </form> </body> </html>
  7. Sorry, I don't get it. I did look at the source but it doesn't seem to have much info (all the php is server side). Here it is though. Is this what you're after? If not, please advise. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> Array ( ) <br /><br> </body> </html> The above is from the pdf with the prod array working but the bung value = fields (i.e. pdf saved with acrobat) But view source is the same for bung product array with working value= fields (i.e. pdf saved with designer)
  8. Hi, here's the whole submit page. Currently all this page does is: print_r($_Post) echo a single posted var ($pharmName) (changed from clientName) And try to fill two html fields (each time in a slightly different fashion) with the variable $pharmName. If I can get the formatting issues to work I'll be adding your code (xyph ) from the earlier question you helped me with (i.e. where prodCode => qty was matched to product descriptions). This current page is a test to see if I can fill an HTML form with all the values from a pdf catalog. There will (if this works) be several catalogs. Each will have the same address fields but different brands. Then will follow a list of ordered products and quantities. The client will be able see their pdf order as a single web page before finally submitting it. As it's a form they'll also be able to make last minute changes. [code] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php print_r( $_POST ); $pharmName= $_POST['pharmName']; echo $pharmName; echo ("Pharmacy: <input class=\"inputbox\" type=\"text\" name=\"pharmName\" maxlength=\"40\" value=\"$pharmName\"><br>"); ?> <form name="form1" method="post" action=""> <input name="name" type="text" id="name" value="<?php echo $pharmName; ?>"> <form action="orderSent.php" method="post"> <input type="submit" /> </p> </form> </body> </html> The attached pic shows the output when sent from an acrobat saved pdf. Only two products were ordered [6722] and [6724]. The problem is "<?xml version=" appears in the input box with the actual input below the box followed by these chars " /> Sending from a Adobe designer saved pdf correctly fills in the form (no extraneous chars) but the print_r($_Post) displays every field and button in the pdf and the products are in the form: [prodCode_6723_] => 7 [prodCode_6730_] => [prodCode_6731_] => Meaning the products are not in an array and all products are present whether ordered or not. So I won't be able to loop through the prodCode array and display ordered products alongside their product descriptions. (Although possibly I could find a way to do this). Steve [attachment deleted by admin]
  9. Thanks PFMaBiSmAd, Well, your suggestion sure lifted my mood for a while, and in fact it might lead to a workaround, but it didn't quite work. I've been using acrobat to edit the pdf. It seems acrobat's HTML submit feature comes with weird formatting (as described above) and there's no way to remove it with acrobat (or Foxit). If anyone knows how i can remove this extra formatting with php after the POST then please let me know (all suggestions appreciated). Acrobat won't let me change this formatting, however Adobe's life cycle designer does. Designer has format="urlencoded" as the default setting. The bummer is that designer won't pass my product code as quantity array. Rather it simply posts every field in the pdf (all mashed together, [prodCode_6747_] rather than prodCode[6747]). So at the moment it seems I can post values but lose the product array or visa versa (am still playing with this). Once again If anyone knows how i can remove the extra formatting with php after the POST then please let me know (all suggestions appreciated). Steve
  10. Sorry Pikachu2000, the 'too' is the name (!) i.e. not John but too. (I was in a hurry). And that (above) is all the code in the current submit.php which receives the post--the actual source (of the post vars) is a pdf button (in a pdf catalog) set to 'submit a form to html' this sends the post to submit.php. But I've just discovered the script above works fine by declaring: $clientName = 'John'; i.e. hard code the var instead of getting it from $_POST. So there're 'invisible' lines in the post received from the pdf, only revealed by a "value=" statement. Any ideas how to strip them from the $_POST? Steve
  11. Thanks for trying to help me here. I'm beginning to suspect it's something to do with the fact the post come from a pdf, since no one's saying "You can't use value=\"$clientName\" I'll try making a test submit html page and see if I can insert values that way (won't help with the problem though, the catalog is a pdf). Here's the offending code: I'll see if I can attach a pic of the output. (The clientName is 'too' sorry, was in a hurry & not thinking.) <body> <?php print_r( $_POST ); $clientName= $_POST['clientName']; echo $clientName; echo ("client Name: <input class=\"inputbox\" type=\"text\" name=\"clientName\" maxlength=\"40\" value=\"$clientName\"><br>"); ?> <form name="form1" method="post" action=""> <input name="name" type="text" id="name" value="<?php echo $clientName; ?>"> <form action="orderSent.php" method="post"> <input type="submit" /> </p> </form> </body> [attachment deleted by admin]
  12. Hi, assuming that it is the pdf adding the extra characters (lines): <?xml version= John Smith " /> (Which echo on its own doesn't display, but value="<?php echo $clientName; ?>" does): How might I remove them? Steve
  13. Thanks for replying Pikachu2000. The var is posted from a pdf and declared with: $clientName = $_POST['clientName']; As an earlier test I simply echoed all the posted variables & they were simply that--whatever was typed in the appropriate pdf entry field. So if John Smith is the client's name then: echo $clientName is John Smith But value="<?php echo $clientName; ?>" is: <?xml version= John Smith " /> where only the first line is in the input box. Steve
  14. Hi, I've got a pdf catalog which posts an order to a php form. The idea is that that the php page looks like an order form that the client can check before finally hitting 'submit' (i.e. along the lines of go to shopping cart). I'd like the php page to be editable. Meaning clients can not only look at their echoed order, but change it before committing to it. So the catalog order gets put into a php submit form with editable fields. I've read that others have accomplished this with statements like: value="<?php echo $clientName; ?>" Which should fill the client name input box on the order form with the posted variable. But it doesn't work properly for me, instead, the form field is filled with "<?xml version=" with the expected name on the line benath the input box and " /> on the line beneath that. Placing the input box declaration entirely within php tags doesn't work either (exactly the same output). <?php echo ("Name: <input class=\"inputbox\" type=\"text\" name=\"clientName\" maxlength=\"40\" value=\"$clientName\"><br>"); ?> Can anyone help? Steve
  15. Hi, solved it with: $products_raw = file('http://correctURL.com/prodDB.txt'); Thanks again btherl & xyph, especially xyph I'm going to use your code http://www.phpfreaks.com/forums/Smileys/nrg_alpha/cool.gif Steve
  16. Hi, the above (last) script is failing at: $products_raw = file(prodDB.txt); The array $products_raw is not created. If I use the code as supplied by xyph (with a locally constructed test array) the script works perfectly. (Thanks again xyph) Any ideas why $products_raw = file(prodDB.txt); might fail? The text file is in the same folder as the submit.php page. Also this has gone off topic, what's the procedure? Start a new thread--i.e. "$newArray = file(textArray.txt) not working" or keep going here? Steve
  17. Many thanks for your prompt replies. btherl, I did try strPos early on but had no luck with it. Output was odd to say the least. I'm happy to try again if my latest efforts fail (I'm going to have to come to terms with it at some stage). xyph, I've been trying your 1st suggested solution--which looked really straight-forward--but ended up with a blank return page every time. No idea why--I'm trying to do this by changing the sumbmission page and uploading it after every change, my server doesn't provide any feedback, either it works or it doesn't. I have yet to try with the constructed data (I went onto your 2nd suggested solution), but my problem may lie with $products = file(prodDB.txt); meaning that line wasn't working for me (and the products array wasn't being populated). So I've now tried your 2nd suggested solution... I added a line: echo "line: $line , product: $product <br/>"; Hoping to see if prodDB.txt was indeed making it into an array. I ordered just 2 products. Got back the following: Could not match 6722 Could not match 6724 So the code did execute, but I didn't get back the products array, which makes me suspect I'm doing something wrong with $products_raw = file(prodDB.txt); Anyway, here's the code I used (can't seem to get the multicoloured code feature working): $products_raw = file(prodDB.txt); // Initialize our formatted array $products = array(); // Loop through products and create an organized array // This assumes it's formatted like ProdNumber{SPACE}Product Name foreach( $products_raw as $line => $product ) { echo "line: $line , product: $product <br/>"; // Make sure there's a space in the line, and grab it's position if( ($split = strpos($product,' ')) === FALSE ) { // No space found, report it in some way echo 'Error trying to parse line '.($line+1).' ('.$product.')<br>'; // And skip the rest of the code for this line continue; } // Split the string based on where the space is. $id = substr($product,0,$split); $name = substr($product,$split+1); // Populate the formatted array $products[$id] = $name; } // Destroy the raw array because we don't need it anymore unset($products_raw); // Loop through orders foreach( $orders as $item => $quantity ) { // Now we don't have to use array_search, which is a slow function, especially when // dealing with big arrays if( isset($products[$item]) ) { echo 'Matched! You want '.$quantity.' of '.$products[$item]; } else { echo 'Could not match '.$item; } echo '<br>'; } Steve
  18. Hi, preg_match isn't working the way I feel it should. The idea, when i finally get this script working, is to echo an order form back to the client (so they can see what they've ordered). At the moment I'm just trying to get the product description for each ordered product. $aryOrder: prodCode[6722] with a value of (for instance) 2 prodCode[6724] with a value of (for instance) 1 etc (only ordered products present in the array) prodDB.txt 6722 Hydrocolloid Blister Care 6724 Toe Spreader etc All products present in text file (prode code Description) BUT I get an echo with no matches for any ordered product (or any prod for that matter) i.e. no match: 6724, 6724 TOE SPREADER when clearly, the product code (6724 $aryItem) is present in the text file line ($line_of_text). I just don't get it! foreach($aryOrder as $aryItem => $qty) { $file_handle = fopen("prodDB.txt", "r"); while (!feof($file_handle)) { $line_of_text = fgets($file_handle); if (preg_match($aryItem, $line_of_text)) { echo "Matched! $aryItem, $line_of_text QTY: $qty <br>"; } else { echo "no match: $aryItem, $line_of_text <br>"; } } fclose($file_handle); } I'm completely new to PHP, trying to work it out from the manual, so I've probably made a very basic mistake, and may even be going about this in entirely the wrong way. Any help much appreciated, Steve
×
×
  • 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.