Jump to content

mikePhp

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Posts posted by mikePhp

  1. right this is the code what i have got

     

    I am calling am function in

     

    //INCLUDE CREDENTIALS
    include('libaries/config.php');
    
    function dbConnect($hostname, $user, $pass, $database) 
    {
    
    
    		//COUNT THE CONNECTIONS DATABASES AND CREDENTIALS
    		for($i=0; $i<count($user) && $i<count($pass) && $i<count($database); $i++)
    		{
    			$connection[$i] = mysql_connect($hostname, $user[$i], $pass[$i]);
    
    			if(!$connection[$i])
    			{
    			echo "Sorry there has been a Database error " . mysql_error();
    			mysql_close($connection[$i]);
    			}
    			else
    			{
    			mysql_select_db($database[$i], $connection[$i]);
    			}
    		}
    
    
    }

     

    My Index.php is the main page for all my pages, it calls the content of the rest of my pages,

     

    http://www.planet-group.co.uk/magazines/foodanddrink/index.php

     

    you will understand and these are the queries from the home page..

     

    //START IF MYSQL
    $query = mysql_query("SELECT id, title, caption, text, thumbName FROM planetFDBrochure ORDER BY id DESC LIMIT 0,1");	
    list($id, $title, $caption, $text, $thumbnail) = mysql_fetch_array($query);
    
    
    $rodEdit = mysql_query("SELECT ID, post_content, post_title, post_name FROM wp_posts ORDER BY ID DESC");
    list($wpID, $wpContent, $wpTitle, $wpName) = mysql_fetch_array($rodEdit);

     

    have a look....??

     

     

  2. You are going to need to post the relevant code. It is likely that you are reusing a variable someplace, resulting in queries overwriting each other.

     

     

    The relevant code was in my first post mate, i was using aray's to get through the process, but i think it is connecitng to the first connection and then overwriting on the second connection.

  3. $connection2 - mysql_connect($hostname, $user[1], $pass[1]);

    $connection2 = mysql_connect($hostname, $user[1], $pass[1]);

     

    might have just been a typo here on the forums but be sure that that '-' is a '=' in your code.

     

    yea matey, just a typo  ::)

     

    I cant seem to get both connections on the same page to display there quiers, one seems to overwrite the other...??

     

     

  4. $link = mysql_connect($h, $u, $p) or die(mysql_error());

    $link2 = mysql_connect($h2, $u2, $p2) or die(mysql_error());

     

    example: mysql_query($query, $link);

     

    ----------------

    Now playing: Red Hot Chili Peppers - Breaking The Girl

    via FoxyTunes

     

    Cheers Matey,

     

    Tried that but doesn't seem to work....

     

    This is what i put.

     

    $database = array('db1','db2');
    $user =array('user1','user2');
    $pass = array('pass1','pass2');
    
    
    
      $connection = mysql_connect($hostname, $user[0], $pass[0]);
      $connection2 - mysql_connect($hostname, $user[1], $pass[1]);
    
    
    if((!connection) || (!$connection2))
    {
    $noCon = 'Sorry there has been an issue connecting to the database';
    }
    else
    {
        mysql_select_db($database[0], $connection);
        mysql_select_db($database[1], $connection2);
      }
    }

     

    I have separate queries for either connection,

     

    But only one of the queries has completed,

     

    Do you thing one is overwriting the other...??

     

    Cheers

    Mike

  5. Hiya

     

    i am currently trying to access 2 different DB's on the same host, but they have different pass's and user names, on the same page.

     

    I am getting a connection, But the second connection is OVERWRITING the first Query, so i am only seeing the display on the mainpage of the second DB Query

     

    I am putting the INFO in to ARRAYS and then calling them I.e

     

    $database = array('db1','db2');
    $user =array('user1','user2');
    $pass = array('pass1','pass2');
    
    
    for($i=0; $i<count($database) && $i<count($user) && $i<count($pass); $i++)
    {
      $connection = mysql_connect($hostname, $user[$i], $pass[$i]);
    }
    
    if(!connection)
    {
    $noCon = 'Sorry there has been an issue connecting to the database';
    }
    else
    {
       for($i=0; $i<count($database); $i++)
      { 
        mysql_select_db($database[$i], $connection);
      }
    }

     

    Now i did try the:

     

     foreach($user as $newUser)
    {
    }

     

    but i needed to get the rest of the foreach's then if you get me...

     

     

    I hope you can help in some sort of way matey

     

    cheers

    Mike

     

     

×
×
  • 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.