Jump to content

siric

Members
  • Posts

    116
  • Joined

  • Last visited

Everything posted by siric

  1. You create a port in Windows which is mapped to the USB port - in my case named Terow. You then create your text file and copy it to the port. $file = "print.txt"; $handle = fopen($file, 'w'); $linefeed = chr(10); $Data = "This is a test\n"; $Data .= "\n"; $Data .= "Line 1"; $Data .= "\n"; $Data .= "Line 2"; $Data .= $linefeed; $Data .= $linefeed; fwrite($handle, $Data); fclose($handle); copy($file, "//localhost/terow"); If I do the same with an image, as expected it prints junk. Can't find information on how to convert the image file to data that will be accepted by the printer.
  2. I am trying to print an image to a thermal POS printer from a PHP script. I have managed to get a text file to print by saving it to a file and copying to the USB port and that works fine. Am running PHP on Windows. Would appreciate any assistance. Thanks Steve
  3. Never mind. WAY too early in the morning. Config.inc.php was being called but I had an typo in the database selection string.
  4. Hello, I have the following code (which opens a database connection and then links to a table.) include("config.inc.php"); at the beginning of a script, but the file (which exists in the same directory as the script) is not being called. I have verified that the file is there and that the spelling is correct (there is no complaint for PHP not being able to read the file) Since it is not being read, the mysql search is not working. If I copy the lines from the config.inc.php file to this file, everything works. I have tried using the full directory structure to no avail. Any ideas? Thanks Steve
  5. Sorry to take so long to respond, but that worked. Thanks
  6. This is where the field name is defined in the javascript // Last updated 2006-02-21 function addRowToTable() { var tbl = document.getElementById('tblSample'); var lastRow = tbl.rows.length; // if there's no header row in the table, then iteration = lastRow + 1 var iteration = lastRow; var row = tbl.insertRow(lastRow); // left cell var cellLeft = row.insertCell(0); var textNode = document.createTextNode(iteration); cellLeft.appendChild(textNode); // right cell var cellRight = row.insertCell(1); var el = document.createElement('input'); el.type = 'text'; el.name = 'txtRow' + iteration; el.id = 'txtRow' + iteration; el.size = 40; How would I then define it as an array? Thanks
  7. Hi, I have a dynamic form which uses javascript to add rows on the fly. The name of the element on my test page is txtRow1, txtRow2, etc; the number is added when I add a new row. I am trying to figure out how I will extract the data once the form had been POSTED. I have tried $tags = $_POST['txtRow']; foreach ($tags as $t) { echo "$t<br />"; } but that shows nothing. I would be grateful for any assistance. Thanks
  8. This should help http://roshanbh.com.np/2007/12/change-dropdown-list-options-values-from-database-with-ajax-and-php.html
  9. HI, I am running the following script which allows me to have a filter on a second dropdown box depending on what was chosen in the first one. function getState(countryId) { var strURL="findState.php?country="+countryId; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('statediv').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } <form method="post" action="" name="form1"> <table width="60%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="150">Country</td> <td width="150"><select name="country" onChange="getState(this.value)"> <option value="">Select Country</option> <option value="1">USA</option> <option value="2">Canada</option> </select></td> </tr> <tr style=""> <td>State</td> <td ><div id="statediv"><select name="state" > <option>Select Country First</option> </select></div></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table> and it works. If I however add another set of dropdown boxes with the same criteria, the second one does not work and I have to change the name of the function in the onChange statement and add that new function to the script at the top to get it to work. function getState(countryId) { var strURL="findState.php?country="+countryId; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('statediv').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } function getState1(countryId) { var strURL="findState.php?country="+countryId; var req = getXMLHTTP(); if (req) { req.onreadystatechange = function() { if (req.readyState == 4) { // only if "OK" if (req.status == 200) { document.getElementById('statediv').innerHTML=req.responseText; } else { alert("There was a problem while using XMLHTTP:\n" + req.statusText); } } } req.open("GET", strURL, true); req.send(null); } } <form method="post" action="" name="form1"> <table width="60%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="150">Country</td> <td width="150"><select name="country" onChange="getState(this.value)"> <option value="">Select Country</option> <option value="1">USA</option> <option value="2">Canada</option> </select></td> </tr> <tr style=""> <td>State</td> <td ><div id="statediv"><select name="state" > <option>Select Country First</option> </select></div></td> </tr> <tr style=""> <td>City</td> <td ><div id="citydiv"><select name="city"> <option>Select State First</option> </select></div></td> </tr> </table> <table width="60%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="150">Country</td> <td width="150"><select name="country" onChange="getState1(this.value)"> <option value="">Select Country</option> <option value="1">USA</option> <option value="2">Canada</option> </select></td> </tr> <tr style=""> <td>State</td> <td ><div id="statediv"><select name="state" > <option>Select Country First</option> </select></div></td> </tr> </table> </form> Isn't there a way that I can reuse the function with the same name as many times as I want without having to use a new name each time??
  10. Hi, I have a PHP form to gather information on products e.g. Product name, size, weight Rather than having a page with about 10 or so lines, I want to display 1 entry line and then give the user the option to add a new line at which time a new line will appear underneath. I am a newbie when it comes to Ajax and would appreciate any assistance. Thanks
  11. siric

    Background image

    Perfecto... Thanks very much..
  12. siric

    Background image

    What I am saying is that the size of the image depends on the font size - if I reduce the font I get less of the image. I have attached the results and what I really want to get. Thanks [attachment deleted by admin]
  13. siric

    Background image

    Sorry, here is CSS and HTML only <!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> <style type='text/css'> .bizinfomask{ position: relative; overflow: hidden; margin: 0px auto; width: 100%; padding-top: 10px; } .bizinfocolleft{ position: relative; width: 100%; right: 50%; } .bizinfocol1{ position: relative; overflow: hidden; float: left; width: 48%; left: 95%; padding-top: 10px; position: relative; text-align:center; height:70px; } .bizinfocol2{ position: relative; overflow: hidden; float: left; width: 48%; left: 3%; } .button { font-family: Georgia, serif; position:relative; font-size: 42px; font-weight: bold; color:red; padding-top: 10px; position: relative; height:170px; background-image:url('csindex.png'); background-repeat:no-repeat; background-position:center right; } </style> </head> <body> <div class='bizinfomask'> <div class='bizinfocolleft'> <div class='bizinfocol1'> <span class='button'>100</span> </div> <div class='bizinfocol2'> <span class='bizname'>Acme</span><br /><span class='bizinfo'>123 Fourth Street</span><br/><span class='description'>description</span> </div> </div> </div> </body> </html>
  14. Hi, I am trying to display a button image (70px * 70px) with text positioned above it. However, the size of the button scales with the size of the font of the text. How can I get the image displayed at full size? Image attached. <!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> <title>2 Column CSS Layout - parellel design</title> <style type='text/css'> .bizinfomask{ position: relative; overflow: hidden; margin: 0px auto; width: 100%; padding-top: 10px; } .bizinfocolleft{ position: relative; width: 100%; right: 50%; } .bizinfocol1{ position: relative; overflow: hidden; float: left; width: 48%; left: 95%; padding-top: 10px; position: relative; text-align:center; height:70px; } .bizinfocol2{ position: relative; overflow: hidden; float: left; width: 48%; left: 3%; } .button { font-family: Georgia, serif; position:relative; font-size: 42px; font-weight: bold; color:red; padding-top: 10px; position: relative; height:170px; background-image:url('csindex.png'); background-repeat:no-repeat; background-position:center right; } </style> </head> <body> <? $button_text = "100"; $business = "Acme"; $address = "123 fourth street"; $description = "description"; echo "<div class='bizinfomask'>"; echo "<div class='bizinfocolleft'>"; echo "<div class='bizinfocol1'>"; echo "<span class='button'>$button_text</span>"; echo "</div>"; echo "<div class='bizinfocol2'>"; print "<span class='bizname'>$business</span><br /><span class='bizinfo'>$address</span><br/><span class='description'>$description</span>"; echo "</div> "; echo "</div> "; echo "</div>"; ?> </body> </html> Thanks for the help [attachment deleted by admin]
  15. http://www.plus2net.com/php_tutorial/php_drop_down_list.php
  16. Have a look at this http://www.plus2net.com/php_tutorial/php_drop_down_list.php
  17. Do a search on the drive for the name of the database. I am running 5.1 and my databases are stored in a data directory under the MySQL directory.
  18. You need to use LIKE and the wildcard %. $search_word."%" would look for all product which begin with what was inputted whereas "%".$search_word."%" would search for all products that contain the search word. You must be careful about SQL injection however - have a read of http://www.tizag.com/mysqlTutorial/mysql-php-sql-injection.php $search_word = mysql_real_escape_string($search_word): $search_word = $search_word."%"; //or $search_word = "%".$search_word."%"; $search_query = 'select * from product_list where product_name like '$search_word';
  19. AFAIK, You would have to store it in a csv and then import it into Excel.
  20. Hi, Problem was a misspelling on the variable that I assigned when I did the mysql_real_escape_strring :-\ Working too late at night!! Thanks for the help.
  21. If I pass "" OR 1 in the $contains variable, I end up with $searchstring being equal to %% which then displays everything in the table.
  22. Hi, I am doing a search on a table with a string that will be submitted by a user and want to prevent sql injection and am using mysql_real_escape_string. The thing is that my search is a wildcard search $search = mysql_real_escape_string($contains); $search = "%".$search."%"; If attempts an injection, the $search string equates to '%%', when then returns results for the entire table. Even if I add if ($calysponiansearch == '%%') { $calypsoniansearch = "%a"; } that does not work as the escaped characters are there but not displayed. How can I prevent this? Thanks 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.