Jump to content

matthew_ellis24

Members
  • Posts

    16
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

matthew_ellis24's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have access to these, but don't know which to change. Can you give me a push in the right direction? is that in the config.inc file?
  2. the secondary database is on a different host to the website - is that a problem?
  3. Obviously when I said "but when the primary server goes down I get can't connect errors for both of them" I meant I get connect errors from both and can't connect to either. Sorry, couldn't see how to edit my original post!
  4. I've been trying to get this working using the code below, but when the primary server goes down I get can't connect errors for both of them. I'm certain the login details for the other server are correct because they work fine from that site, but they don't seem to work from a different site. What did I miss? Many thanks <?php $username=""; $password=""; $database=""; $dberror=""; $link= mysql_connect('mysql2.freehostia.com',$username,$password); mysql_select_db($database); if (!$link) { $username1=""; $password1=""; $database1=""; $dberror= "<b>WARNING</b>Our primary database is down. You are currently using our secondary database which may not be as up to date. We apologise for any inconvenience<br>"; $link1= mysql_connect('193.62.81.10',$username1,$password1); mysql_select_db($database1) or die( "Unable to select database"); } ?>
  5. Hi, I've had a look for this, but I'm not sure it's possible without specialist software. So what I want to know is, is it possible to set up your queries in such a way that if your connection to one database fails (because your host is naff and keeps crashing) it connects to an alternate server? I use this to connect to my database: mysql_connect($host,$username,$password); mysql_select_db($database) or die( "Unable to select database"); and I've tried replacing the "or die" command with a new mysql connect, but no luck. Is it possible? Thanks Matt
  6. sorry even more embarrassingly I figured out (after 12 hours!) that this doesn't work because of a typo. Think I'd better give up on web design and go back to biological science!
  7. Hello, I've had a crack at this using JOIN, and as shown below, but so far no luck. I decided against using JOIN because I don't want it to list habitats that don't have associated countries. $habitatcountry_id was defined from a database populated dropdown limited to countries with habitats as the country_id. But the code below produces the following error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /export/users/mbe/pages/carabus/habitat_country.php on line 6 If I echo $habitatcountry_id it echos the right code, so obviously my query is wrong. (???) As always, any help greatly appreciated! Thanks Matt $query= " SELECT DISTINCT habitat.habitat_name, habitat_country.habitat_id FROM habitat, habitat_country WHERE habitat.habitat_id = habitat_country.habitat_id AND habitat_country.country_id= $habitcountry_id ORDER BY habitat.habitat_name"; $result = mysql_query ($query); while ($myrow = mysql_fetch_array($result, MYSQL_ASSOC)){ echo $myrow['habitat_name']; }
  8. there aren't any more records, I just inserted those ones to have a play with it. Thanks for your help, I'll get right on it. Many thanks Matt
  9. so I need to have something like this, where this is my habitat table: <pre> habitat_id habitat_name habitat_text 1 <i>Calluna-Erica</i> heath <i>Calluna-Erica</i> heath consists of scrubby hea... 2 Deciduous Forest <i>Quercus</i> and <i>Fagus</i> etc etc </pre> and this is the table that relates habitats to species? <pre> habitat_species_id habitat_id species_id 1 1 9 2 1 37 3 2 37 4 2 1 </pre> My only concern is this seems a pain to do anything with. For instance if I add a new habitat then I need to add it in the habitat table, and then add (in some instances) up to 200 new rows to the habitat_species table. Then again, if it's the best way to do it, it's the best way to do it... thanks for your help
  10. Hi, I'm trying to set up a directory of habitat types, that also displays what species are found in association with them. I think I need my table to be set up like this: habitat_id habitat_name habitat_description habitat_countries and then in the species table have a link to the habitat_id field. There are a few problems, but I think they're essentially the same: Species can occur in more than one habitat. So how do I enter that in the species table? Can I have 1, 2, 3 (for habitat ids) in the same column, or do I need to have multiple columns to allow for multiple number of habitats? And then the same problem with multiple countries having similar habitats. I'm just worried that if I have 1, 2, 3 and I search for "like 1" will I not then recall all the 10...19, 21...91 etc etc? The ultimate goal being to allow a user to select: - habitats, the countries it's found in and the species found in it - countries and the habitats found in them - species and the habitats it's found in Doing the above should be easy once I'm certain of the database tables thanks Matt
  11. excellent thanks. All sorted now. Always quite embarrassing when it's something so simple! Cheers Matt
  12. Changing that gives me the following error (which just confuses me even more!): Warning: main(menu_.html): failed to open stream: No such file or directory in /export/users/mbe/pages/carabus/index.php on line 48
  13. I am trying to set up a php based multilanguage site. I thought about using the database for the multilingual content, but it seems more hassle than it's worth for the amount of actual writing on the site. The site is www.carabusonline.co.uk. If you select a language then all fine, but as soon as you navigate away it loses the variable and resorts to english. As always, any help greatly appreciated! Code below: the l: in the top right is my attempt at debugging and is set to: echo $lang; as defined by session.php, which is included right at the top of the page (on every page before any HTML, with no white space included): <?php SESSION_START(); if (isset($_GET['lang'])) { $lang=$_GET['lang']; $_SESSION['lang'] = $lang; } if(!isset($lang)){ $lang="en"; } ?> The language links are just: <a href="?lang=es"><img src="flags/es.jpg"></a> To call a page I use <?php $menu = "menu_".$lang.".html"; include($menu); ?>
  14. Hello, I am using an HTML form to upload data to my MySQL database. The form automatically populates select dropdowns with existing categories and also provides a textbox to allow you to enter one if the category you want isn't on the list. The dropdown outputs an id number, the text box outputs the name. Both are stored in the database. I think the code is correct so far, all I need to do now is figure out how to set subdiv_id if you enter info in the text field. It should be set by going into the database, finding the maximum current subdiv_id and adding one. Cheers Matt ///// ////get subdivision name from database or if no subdiv_id get from form ///////// if(!empty($_POST['subcat'])) { $subdiv_id=$_POST['subcat']; $query1= "select subdivision from speciescomplete where subdiv_id='$subdiv_id'"; $result1 = mysql_query ($query1); While ($row1 = mysql_fetch_array($result1)) { $subdivision = $row1[subdivision]; } }else{ $subdivision = $_POST['subdiv']; $subdiv_id = }
  15. many thanks - I had hoped I'd be able to do it without needing a third page, but this will work just as well. Cheers
×
×
  • 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.