Jump to content

MortimerJazz

Members
  • Posts

    60
  • Joined

  • Last visited

    Never

Everything posted by MortimerJazz

  1. Afternoon all - I'm hoping you might be able to help me with a DB design issue I've got. Let's say for example, I'm building a website which will track the price of shares over the course of a 7 day period. These prices will be initially downloaded to a database and then extracted to be displayed in a graph using something like FusionCharts. My question is that I really don't know where to start in terms of designing the database to ensure that data is stored in the most efficient manner. I don't suppose anyone can point me in the direction of a good tutorial/book which would help me out with this could they? Thanks very much in advance!
  2. Just wanted to give this a bump? Can anyone help at all? I can't seem to find anything about this anywhere and I'm starting to pull my hair out! Thanks,
  3. Definitely - thanks for the replies so far. Here's the code I'm using in my index page. You can see the include function four lines from the bottom: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="http://www.mydomain.com/style.css" type="text/css" media="screen" /> <link rel="stylesheet" href="../style.css" type="text/css" media="screen" /> <? include "functions/getStyle.php"; ?> <link rel="icon" href="http://www.playpokeronline.net/favicon.ico" type="image/x-icon"> <meta name="google-site-verification" content="cwKF364Iet1xHF8hrPgV2prykHYo4I2vN7JU3p2GufQ" /> The getStyle.php contains this code which basically queries a Maxmind Database to determine a player's location. Dependant on the results, the script should then load one of a handful of CSS files. <?php include("geoip.inc"); // Uncomment if querying against GeoIP/Lite City. // include("geoipcity.inc"); $gi = geoip_open("/home/user/public_html/geoIP/GeoIP.dat",GEOIP_STANDARD); $ip=$_SERVER['REMOTE_ADDR']; $country=geoip_country_code_by_addr($gi, "$ip"); geoip_close($gi); switch ($country) { case US: echo '<link rel="stylesheet" href="../style/us.css" type="text/css" media="screen" />'; break; case GB: echo '<link rel="stylesheet" href="../style/gb.css" type="text/css" media="screen" />'; break; case CA: echo '<link rel="stylesheet" href="../style/ca.css" type="text/css" media="screen" />'; break; case AU: echo '<link rel="stylesheet" href="../style/au.css" type="text/css" media="screen" />'; break; default: echo '<link rel="stylesheet" href="../style/default.css" type="text/css" media="screen" />'; } ?> Technically it works - the correct style sheet loads up, but I'm left with this extra HTML tag in the middle of my original <head> tag. <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> </body> </html> I hope that makes sense - feel free to ask any more questions if not. I really appreciate the help!
  4. Are there any problems with calling an include file from within the <header> tags? The reason I'm asking is that I'm trying to load a speficied Style sheet based on a user's location and so I'm running a short script to determine which Style sheet needs to be displayed ... and that script is called from within the header tag. I haven't heard of any problems with doing this in the past, but the script seems to be generating an extra set of <HTML> tags in my source code and I can't figure out why this might be! Thanks,
  5. This is a bit of a wierd problem, but I haven't been able to solve it so I thought I'd post it up here. Basically, I'm using the following function to access Maxmind's GEO IP database (so that I can target visitors to my site based on their location): <?php // This code demonstrates how to lookup the country by IP Address include("geoip.inc"); // Uncomment if querying against GeoIP/Lite City. // include("geoipcity.inc"); $gi = geoip_open("/home/bounce6/public_html/geoIP/GeoIP.dat",GEOIP_STANDARD); $ip=$_SERVER['REMOTE_ADDR']; $country=geoip_country_code_by_addr($gi, "$ip"); geoip_close($gi); ?> The function is being called using this line from a separate file: include "/home/username/public_html/mydomain.com/functions/getCountry.php"; Now the code does what it's supposed to do, in as far as it's able to give me a string which details where a visitor is located. However, for some strange reason it seems to be adding a new HTML tag into my existing header tag. The code which has been inserted is as follows: <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> </body> </html> I've managed to isolate the problem to this script, so I know that there must be an issue with it, but I'm not quite sure what it is. Can anyone suggest why this extra source code is being produced? Is there a particular function that I'm using which is forcing additional headers or something?! Any thoughts would be really appreciated!
  6. Thanks for the response David, but I thought that section of code listed basic wildcard patterns as opposed to Regular Expressions which would be ok for sscanf ()
  7. Ok, now I'm a little confused. This is the print out I get on the screen when the script is run: It would seem that I'm not getting any keywords in my array, which I'm pretty sure wasn't happening before ...
  8. Ok, quick update as this hasn't quite worked. Here's the ammended code (the ammended part is the print_r() function at the end) <? function parse_ga_cookie($cookie) { $values = sscanf($cookie, '%d.%d.%d.%d.utmcsr=%[^|]|utmccn=%[^|]|utmcmd=%[^|]|utmctr=%[^|]'); if (count($values) !== { // return false; trigger_error(...); ... or whatever you like throw new InvalidArgumentException("Cookie value '$cookie' does not conform to the __utmz pattern"); } $keys = array('domain', 'timestamp', 'visits', 'sources', 'campaign', 'source', 'medium', 'keyword'); return array_combine($keys, $values); } // Cooookkkkkkiiiiiiieeeeeeeeeeee, om nom nom... $keyword=print_r((parse_ga_cookie($_COOKIE['__utmz']))); ?> The output has changed now, but it's still not quite correct. Instead, I'm getting the value '1' in the $keyword variable now. I'm trying to figure out if that's a string or a value from the array. Can anyone help out at all? Cheers,
  9. Morning all, I hope I'm posting this in the correct section - if not, please feel free to move it. What I'm trying to do is extract keyword information from the Google Analytics cookie and pass it into the header when a click is generated. Having hunted around I understand that I need to extract the utmctr value from the __utmz campaign cookie, which looks like this: So here's a short function that I wrote to try and extract the keyword information: function parse_ga_cookie($cookie) { $values = sscanf($cookie, '%d.%d.%d.%d.utmcsr=%[^|]|utmccn=%[^|]|utmcmd=%[^|]|utmctr=%[^|]'); if (count($values) !== { // return false; trigger_error(...); ... or whatever you like throw new InvalidArgumentException("Cookie value '$cookie' does not conform to the __utmz pattern"); } $keys = array('domain', 'timestamp', 'visits', 'sources', 'campaign', 'source', 'medium', 'keyword'); return array_combine($keys, $values); } // Cooookkkkkkiiiiiiieeeeeeeeeeee, om nom nom... $keyword=(parse_ga_cookie($_COOKIE['__utmz'])); Unfortunately though when I go to print out the value $keyword I'm just getting the value 'Array' Is anyone able to help me out at all here? I can't see where the problem lies. Thanks a lot for your help ...
  10. Could you give me a simple example at all fenway? Thanks a lot for your help ...
  11. Afternoon everyone, Here's the rough layout of a page I'm currently working on - it's a bit like a 'profile' page I suppose: Apologies for the rather quick Photoshopping ... but you can see roughly where I am. What I'd like to make happen is to allow visitors to the page to click on Pic2 or Pic3 and have that image swap with the main image, so that the smaller pics can be seen larger. Now the problem is that I somehow need to be able to check which of the three images are currently in the Main Image area, so that I know which two to swap. So my question is, how can I see exactly which picture is currently being displayed in the main image area? And how do I update this each time that one of the smaller images are clicked on. ANY help would be really appreciated! Thanks,
  12. Hi Fenway, Thanks for the reply. Most of the content is stored in VARCHAR fields or short text fields. Stuff like the number of doors is stored in NUMBER fields and any features like (leather seats, 4WD to keep the example above going) is recorded by a "TRUE" in the relevant field name. Does that help at all?
  13. That's not a very descriptive title, so let me try and explain what I want to do. Basically, when a user searches through the database, I don't want the results page to show up blank if nothing matches the criteria which the user has inputted. Therefore if the database doesn't find an exact match, it would be nice if it brought up records which were similar to what the user wants. So let's say someone's looking for a car and wants a 4 Door Red Audi. Nothing like that is in the database, but I'd like my script to effectively say "We don't have that, but we do have a 4 Door Blue Audi" Can anyone suggest the best way of doing this please? Thanks,
  14. Thanks lilman. The code's quite simple so far: [code] $message="The following person has expressed an interest in your toy: <p> Reference Number: <a href="http://www.mysite.com/viewtoy.php?toy=$ref <p> User: $username"; $sql = mysql_query("INSERT INTO prv_msg (sender, recipient,         subject, message, sell_msg, date_sent, ip_sender)         VALUES('$username', '$recipient', '$subject', '$message', '1', now(), '$ip')")         or die (mysql_error()); [/code]
  15. Hiya - I wasn't quite sure where to post this ... I've designed a type of PM system. The idea is that a dynamically generated PM is sent to a user. However, I'd like this PM to include clickable links and also format it with new lines etc. So my question is, is it possible to store HTML in a MySQL database? When I've tried storing regular href's, I keep getting error messages on my page. Am I doing something wrong? Thanks,
  16. Hi there, I'm trying to calculate the time since a registered user last logged into a website. I have two variables: $last_login (timestamp from DB showing the last time a particular user logged in) now() - Timestamp showing current time/date I've tried subtracting one from the other, but I'm not getting the result that I needed. Can anyone help me at all? Thanks,
  17. Is it possible to do it through a standard FTP package? Thanks,
  18. I'm not sure that's the best title for my question, but it pretty much sums up something that I've been seeing on a few websites recently. Especially property sites. If you look on something like [url=http://www.PropertyFinder.com]PropertyFinder[/url], they have a search box which asks you to "Enter a Property ID, Location or Postcode" My question is, when a user hits the submit button, how does the processing script know which DB table to search through in order to get the relevant information. How does the processing script know whether the user has inputted an ID, a location or a postcode? Thanks very much
  19. Thanks Paul. I'm getting the following error message: [quote]right syntax to use near 'string), 3) = 'SL9'' at line 3[/quote] SL9 is what I typed into the form field.
  20. I know this might be a silly question, but I was wanting to know if there's any way to fire a particular PHP function when a user clicks on a certain image or link. At the moment I'm having to refresh the page, passing the script a certain variable called "action" or something similar. Is this the only way to go about this? Thanks,
  21. Hi there, I'm currently writing a form where a user will input the first three characters of a postcode. In my database I have registered users full postcodes, but when I run my query I only want to match the from the form to the first three letters of the database value. I'm currently using the following query: [code]$sql_postcode_check = mysql_query("SELECT username, postcode   FROM users   WHERE left(cast(postcode as string), 3) = '$postcode'");[/code] But I'm getting an error message saying that the supplied argument is not a valid MySQL result resource. Can anyone tell me what I'm doing wrong? 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.