Jump to content

recklessgeneral

Members
  • Posts

    67
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.therecklessgeneral.co.uk

Profile Information

  • Gender
    Male
  • Location
    Newcastle, UK

recklessgeneral's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi all, I have been reworking the layout of my website but have run into problems with IE - every other browser renders it correctly. It's basically a 3 column layout with header and footer, but the columns are scrollable instead of the entire page. A mock up can be seen here: http://www.therecklessgeneral.co.uk/tmp/layout.html When viewed in IE, the columns expand to enclose their content rather than taking up the entire space between header and footer. The middle column disappears beneath the footer and out the bottom of my monitor somewhere. I have been fumbling around with it for a while now and only succeeded in making things worse, so if anyone can shed any light on the problem then that's be a huge help. Cheers, Darren.
  2. Hi, First off, a few things immediately jump out at me: The use of =. instead of .= in your string concatenation looks wrong. I tried a sample piece of code using =. and I got parse errors, so I don't know if that was just a typo. Second, you're using the string concatenation operation to assign a string to an array item - again, this looks wrong. Use $myinfo[0] = $printpages; I'm not sure why you need an array there and not just return a string - maybe you have some constraints on your function signatures? Cheers, Darren.
  3. Hi, This tutorial looks like it might be useful: http://www.phpfreaks.com/tutorials/62/0.php Cheers, Darren.
  4. Hi Chris, You can't achieve this strictly through PHP as PHP only deals with server-side processing and uploading a file is instigated by the client. To get scp-like encryption, the browser would have to encrypt the file before posting the data to the server - this would require Javascript or some other client side processing, but I'm not that familiar with javascript. You would also need a way to synchronize the keys between client and server. Alternatively, you could set up a secure server, then all communication would be encrypted. Note: md5 is not an encryption function but a digital message digest function. The difference is that encryption can be reversed if you know the key, whereas md5 is only a oneway function useful for authentication. Check out mcrypt function for php encryption. Cheers, Darren.
  5. Hi, You can use the SELECT DISTINCT keywords instead of just SELECT in your query. Everything else would be the same and that should get you what you're after. Cheers, Darren.
  6. Hi, The problem is that you're initializing the array with a value, then checking whether there are any values in the array, which will return true or 1 or whatever. What you can do instead is initialize $products to an empty array, and I used the count function instead of array_count_values: <?php $products = array(); // This Works If The Above Array Does Not Exist At All // But It Will Not Work; If The Above Array Is Present With An Empty Value if (count($products) == 0) { $products[] = "Item Not Available"; } foreach($products as $key => $value) { echo "$value<br>"; } ?>
  7. Hi, It looks like you have an error in you patterns for last name and first name (although the first name pattern isn't fatal). Remove the first backslash from the patterns, and that should get you further: $lname = preg_match("/Last Name: [a-zA-Z]{1,300}/", $details, $matches); The backslash is an escaping character - I used it in the regular expression for phone numbers as I wanted to search for literal parentheses. Usually, parentheses are interpreted as part of the regular expression. '\L' happens to have a special meaning also, which was confusing the regexp parser. The code snipped I provided was meant as an alternative to using regular expressions all over the place. Basically, if you got rid of my $info assignments at the top and replaced it with $info = $_POST['details]; the rest of the could replace the approach you provided. Its just an alternative way of extracting information - the way I presented allows the data to be extracted more contextually, so you know a particular name belongs to a service address or billing address for example. A couple of points about your code: 1. Your if statements following your preg_match don't do anything. What is the intention of that? 2. There seems to be a lot of unnecessary reassignment of variables - $lnamedata, $lname and $_POST['lastname'] are all assigned to $matches[0] (which may or may not exist as this is accessed even if there weren't any matched). Regards, Darren.
  8. Hi, To extract all phone numbers, just replace preg_match with preg_match_all, then access each one from the $matches array. See http://uk3.php.net/manual/en/function.preg-match-all.php for more examples. As for extracting more info, based on the extract you supplied, there is quite a bit of scope for interpreting data. It all depends on how different the data will be presented to you. For the data presented in the extract, here is a simple bit of code that will extract the first and last names from the service address section. <?php /** * Set up the info. This is an extract of what would be posted in the form. * Lines are separated by the newline character, as they would be if typed or * pasted in. */ $info = "... blah ...\n"; $info .= "\n"; $info .= "Service Address\n"; $info .= "Last Name: SCHMO\n"; $info .= "First Name: DARRELL\n"; $info .= "Address Line 1: 5162 ANYWHERE STREET\n"; /* Split the info string into an array of strings, one for each line */ $lines = explode ("\n", $info); $currLine = 0; $totalLines = count ($lines); /* Iterate over each line, extracting the interesting stuff. Here, we'll just * extract the service address, but we could do the same for any other sections * such as "Billing Address" or "Current Services". I have separated the finer * grained processing into functions to make the main loop easier to read. */ while ($currLine < $totalLines) { $line = $lines[$currLine++]; if ($line == "Service Address") { getServiceAddress ($firstName, $lastName); echo "Fist name = " . $firstName . "<br/>"; echo "Last name = " . $lastName . "<br/>"; } } /** * This function extracts the first and last name from the service address * block, and returns those values to the caller. This function is called * when the line containing "Service Address" has been encountered. */ function getServiceAddress (&$firstName, &$lastName) { /* Need access to the info lines, where we currently are and how many * lines there are in total. This info is shared with the main code so * the current location can be updated. */ global $lines, $currLine, $totalLines; while ($currLine < $totalLines) { $line = trim ($lines[$currLine]); /* Search for the bits we're interested in. Here we're just using substr * instead of the more expensive preg_match. Less expressive, but should * be fine if the format is this strict. */ if (substr ($line, 0, 11) == "First Name:") { /* The first name is just the last part of the line. */ $firstName = trim (substr ($line, 12)); } /* Do the same for last name */ else if (substr ($line, 0, 10) == "Last Name:") { $lastName = trim (substr ($line, 11)); } else { /* We're not interested in anything else in the block, so just return * to the main section. */ break; } $currLine ++; } } ?> There are some limitations with this code - the getServiceAddress function isn't great - it won't handle the case where the 2 bits of info it wants are separated by something it doesn't like. There's no support for handling missing info. However, with a fairly well-defined structure to the data, this approach could be honed to pick out most of what you're looking for. Regards, Darren.
  9. Hi, This sounds like a tricky problem. The easiest part is the extraction of the phone number, as this can be done with a relatively simple regular expression, as long as the format of the phone number doesn't vary at all from how you expect it. The following example will extract a phone number of that format: <?php $text = "My phone number is (123)456-7890. Please dial carefully."; $phone = preg_match ("/\([0-9]{3}\)[0-9]{3}\-[0-9]{4}/", $text, $matches); if ($phone == 1) { echo "Matched phone number: " . $matches[0] . "<br/>"; } ?> If the contractor paste the phone numbers in differently (miss out the parenthetical part, or add extra whitespace), the above code will fail to find a match. You'll then have to play around with the structure a bit. The rest sounds almost impossible. Unless you are imposing a strict format for name details, like a particular form field only containing names and phone number, I don't reckon you could arbitrarily extract name info. Could you post an example of what you expect this info to look like? Cheers, Darren.
  10. Hi, The $walkerarray variable is local to the WalkerArray function, so it can only be used in the scope of that function. In order to use it (or more precisely, a copy of it) outside the function, you assign the result of the function to a new variable and that will then work: $walkerarray = WalkerArray(); print_r($walkerarray); This should now print the same results as inside the function. The point to bear in mind is that the $walkerarray in the code above is a different variable to the one declared in the function. Cheers, Darren.
  11. Hi, Your while loop needs to wrap the html code for displaying the image and title. You are also running two queries, ordering by different fields. This will have the effect of displaying different titles with the images. <?php mysql_select_db($database_localhost, $localhost); $query_Rs = "SELECT * FROM featuredprop order by featurename"; $Rs = mysql_query($query_Rs, $localhost) or die(mysql_error()); $totalRows_Rs = mysql_num_rows($Rs); while ($row_Rs = mysql_fetch_assoc($Rs)) { echo "<img src=\"featuredimages/" . $row_Rs['featurename'] . "\" height="100" width="100" >"; echo $row_Rs['featuredtitle']; } ?> You'll probably want to play around with formatting, but that should get you all the images and titles on your screen. Cheers, Darren.
  12. Hi, What you'd need to do is use some kind of fancy regular expression stuff to replace the "ยท " with a <li> element, the next newline or break with a </li>. The trickier part then comes in placing the <ul> and </ul> tags before the first and after the last of a block of bullets. For reference, the WikiParser class might be worth a look. It can be downloaded from http://code.blitzaffe.com/pages/phpclasses/files/wiki_parser_52-13/view/1. Basically, it can convert lines beginning with asterisks into proper ul style html lists. It will also do a bunch of other conversions as well. Take a look at it and strip out the bits you don't need. Hope this helps, Darren.
  13. Hi, A handy tip for finding out which process caused the core dump is to run the unix/linux command 'file' on it. Once you've identified the program causing the crashes, you'll have to decide what to do about it. You'd probably want to fix what is causing the core dumps instead of fixing the symptoms in the crontab. However, if you do go down that route, try setting the ulimits to 0 for the core file (run: ulimit -c 0) to prevent any core files being dumped. Regards, Darren.
  14. Hi, Roopurt18 just beat me to this, but I'll post anyway... It's always worthwhile wrapping your calls to mysql_query in some error checking code - it makes debugging a lot quicker if you can get mysql to give you a hint to what's wrong. Try: if (!mysql_query ("insert into ....")) { echo mysql_error(); } As a first stab though, I'd say you'd need single quotes before and after you call addslashes ($md5), as you have done with title and descr. Hope this helps, Darren.
  15. Hi, The manual page for crypt (http://www.php.net/manual/en/function.crypt.php) raises a few issues to be wary of with this function. I haven't used it myself - I favour the md5 function myself, which seems to work fine. Cheers, Darren.
×
×
  • 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.