Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. With this code preg_match("/[\&\?]q=([^&]*)/", $referer, $matches); if($matches[1]) { $cityName = "xyz"; } else { // not a google referer $cityName = "abc"; } If the referer is from google then $cityName will be xyz. If they are refered from anywhere else including your own site then it is set to abc. If you have the city name in the url then you must bypass this code so it does not change the $cityName variable. i.e. $cityName = (strlen($_GET['location'])) ? $_GET['location'] : false; // no location passed through url - check the referer if(!$cityName) { preg_match("/[\&\?]q=([^&]*)/", $referer, $matches); if($matches[1]) { $cityName = "xyz"; } else { // not a google referer $cityName = "abc"; } }
  2. You would have to emphasise more on the database design. If your database is properly normalised and contains the correct indexes on the required fields then it doesn't matter how large the table gets (you can store millions of rows). You must make sure you write the most optimised queries. From your description I picture the db as: person ======= personId name location ======= locationId name personToLocation ============== id personId locationId events ======= eventId name personToEvents ============== id personId eventId and so on
  3. A much better method would be to use a full text search engine rather than your database. On a large number of records using a query like SELECT FROM ... WHERE ... LIKE %...% will be slow. Building a search index is much more efficient and can rank your search results as well as do plenty of other stuff. However seen as you are on a shared hosting account you may have trouble installing these tools. I would opt for better web hosting and go for a dedicated server. http://sphinxsearch.com/ http://framework.zend.com/manual/en/zend.search.lucene.html
  4. No because this line is looking for a Google search string in the referer preg_match("/[\&\?]q=([^&]*)/", $referer, $matches); if($matches[1]) { You would have to set the value preg_match("/[\&\?]q=([^&]*)/", $referer, $matches); if($matches[1]) { } else { // not a google referer $cityName = "abc"; }
  5. No, there is no predefined function for this however $str = addcslashes($str, '/'); is probably no more efficient than $str = str_replace('/', '\/', $str); They both perform the same operation
  6. You should store the exchange rate and possibly check for an update i.e. once a day PHP: http://pear.php.net/package/Services_ExchangeRates
  7. str_replace('/', '\/', $str); This is faster than any regular expression operation.
  8. It is your web server log files that should be analysed for search engine keywords. Look at AWStats, Webalizer, etc.. however the $_SERVER['HTTP_REFERER'] will contain the url of the page that referred the user. This part is looking at the url to see if it matches a Google query string: preg_match("/[\&\?]q=([^&]*)/", $referer, $matches); The keyword is then extracted. http://awstats.sourceforge.net/ http://www.webalizer.org/
  9. Bad Syntax $title = mb_convert_encoding($_POST['title'], "ISO-8859-1", "auto"); $content = mb_convert_encoding($_POST['content'], "ISO-8859-1", "auto"); $date = date("Y-m-d");
  10. Try converting the character set of the string once it has been posted. This is a real ballache of an issue. mb_convert_encoding($string, "ISO-8859-1", "auto")
  11. Not that I am aware of unless you created a string from an array in PHP to pass into the IN operator. Normal operation would be WHERE column_name >= 1 AND column_name <= 100 http://dev.mysql.com/doc/refman/5.0/en/where-optimizations.html
  12. PHP is a server side language and has no way of affecting your web browser's functionality or detecting browser actions. You should modify your scripts so that a user clicking back or refresh will not affect the expected output.
  13. Update it with what. You haven't stated what you are trying to achieve or what the issue is. Test in what way. Is it outbound email you have an issue with?
  14. Building that is going to take a long time. I'd go out the box for this http://www.hotscripts.com/listing/triolive-php-ajax-powered-live-chat-solution/ http://www.hotscripts.com/listing/liveresponse/
  15. PHP is an Object-Oriented Programming language if your programming code is based around the OOP concepts in PHP. PHP applications can also be procedural. I don't think you understand the concept of OOP. Do some more research.
  16. Modifying it is an option as the xml can be read into a variable prior to being used with simpleXML. For this you will not make use of simplexml_load_file() but simplexml_load_string() Read the contents of the xml file into a variable. Scan for any bad characters and remove. Pass the cleaned xml ino simplexml_load_string() Also XML that contains HTML markup should be contained in a CDATA node. You could specify this in the simpleXML function parameter with the following constants http://uk3.php.net/manual/en/libxml.constants.php
  17. I would not use the item you have chosen to pass through the url. It looks like your product code. Im assuming these products are in a database table so instead you should pass the primary key which is an integer. Your cart.php can get the rest of the product information from the database using this value.
  18. If you are the only person working on the system then you can make it entirely how you wish. In another scenario where a developer may work on many systems providing upgrades, extra features, bug fixes then an OOP design is favoured. For example I may create a blog feature for a website that logged in users can view. With an OOP system I can add the components without affecting any of the underlying code so I know I am not creating bugs in the rest of the system. In a procedural system I may need to add extra code to files / functions that are live and potentially create bugs in the system that affect the users. When deciding on OOP or procedural I ask myself the following questions: 1. Is it just myself that will be working on the system 2. Is the system fixed or is it likely that the client may ask for large modifications, extra features 3. Is the system likely to be ported to other servers or other types of database servers 4. What is the deadline for system completion
  19. Is this OOP? $x = 1; print $x; No it isn't
  20. This is not valid syntax $count["'LastName' + ', ' + 'FirstName'"] Use . for concatonation $count['LastName'].' '.$count['FirstName']
  21. Your code is incorrect. You need to detect the buttons value before inserting anything. i.e. if(isset($_POST['submit']) && $_POST['submit'] == 'create') { // add a new record to the database // reload page header("Location:index.php"); exit(); }
  22. Custom (and very poor looking). Have a search through http://www.hotscripts.com to see if there is one available.
  23. Dont use a url for the file. Grab the file from its location and use headers to display it. Place the code in a file i.e. pdf.php then this will always be the url yourdomain.com/pdf.php
  24. $result="UPDATE tea_tbl SET sick=$sick WHERE LastName = '$lastname' AND proc = 'no' "; $lastname is not set. This will not work. Make sure all your variables have values or you will end up with unexpected results in your database tables $result="UPDATE tea_tbl SET sick=$sick WHERE LastName = '".$row['LastName']."' AND proc = 'no' ";
  25. Swiftmailer http://swiftmailer.org/ PEAR::Mail http://pear.php.net/package/Mail PEAR::Mail_Queue http://pear.php.net/package/Mail_Queue Dont loop through thousands of email addresses using the mail() function. This is a bad idea as it will open and close an SMTP socket for every email which is inefficient.
×
×
  • 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.