Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts

    How connect two or more database

    How to work with two or more datebase,i making search engine so will be a lot of informations over the milion so i need to have more datebase and tables.Right now i have been working with one datebase so if can help to do search from more datebase or tables.




    PHP Code:
    $constructs ="SELECT * FROM search WHERE $construct";
    $run mysql_query($constructs);
        
    $foundnum mysql_num_rows($run);
        
    if (
    $foundnum==0)
    echo 
    "Sorry, there are no matching result for <b>$search</b>.</br></br>1. 
    Try more general words. for example: If you want to search 'how to create a website'
    then use general keyword like 'create' 'website'</br>2. Try different words with similar
     meaning</br>3. Please check your spelling"
    ;
    else

      
        
      
    $per_page 6;
    $start $_GET['start'];
    $max_pages ceil($foundnum $per_page);
    if(!
    $start)
    $start=0
    $getquery mysql_query("SELECT * FROM search WHERE $construct LIMIT $start, $per_page");
    $mysql=" SELECT * FROM search WHERE MATCH(www.youtube.com) AGAINST('url')";
    while(
    $runrows mysql_fetch_assoc($getquery))
    {
    $title $runrows ['title'];
    $desc $runrows ['description'];

    $keywords $row['keywords']; 
    $url $runrows ['url'];
    $image $runrows ['image'];
     echo 
    "
    <a href='$image'><h2>$image</h2></b></a><br>"
    ;

    ?> 



    I tried with some adding code from google didn't work and also tried to mix this code didn't work too so any suggestions will be appreciate.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,592
    Thanks
    0
    Thanked 645 Times in 635 Posts
    You have posted this in the wrong forum. This forum isn't for asking questions, it is for sharing code that works.

    Why do you need two databases to start with? That's like asking how to connect two universes. The plural of database is database as the concept of a database is that it contains ALL data and so there should only ever be one.

    You control what data in the database is accessible to which user in order to restrict certain accesses to selected tables or fields - you don't do it by creating extra universes.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts

    database

    I making search engine and almost done but right i need explore more tables to echo that like search result.It will be a lot of information's into datebase over the millions so want use more tables.I am beginner but i now somethings.I good with css,html,dreamweaver,flash,photoshop php and my sql still learning.

  • #4
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,216
    Thanks
    12
    Thanked 338 Times in 334 Posts
    Quote Originally Posted by Pearl_9 View Post
    It will be a lot of information's into datebase over the millions so want use more tables.
    a single DB can easily contain millions of data. that’s what they’re build for.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    There's no explicit need to use multiple databases. You can of course do so, but when you do you must establish multiple connections and operate on them independently.

    When using the old mysql library, it means you must track your connections and use them in your functions as well. So your mysql_query call would provide a second argument to the appropriate dbms link. So if you haven't been doing this, than you will need to rewrite all function calls which require a database resource connection and provide it with the appropriate link. On the plus side, the mysql library is disappearing very soon.

    MySQLi library on the other hand already (rightly) requires the connection on every call either procedurally with an argument or as an object to operate on, so the change is minimal if you want to use a different dbms.

    Also, more tables or more properties are often a flaw of rigid designs. Adding more tables since one is getting "big" is just silly. I'm not even sure if mysql has a theoretical maximum on the number of records, but if its does it'll be in the billions or higher. If you're concerned, simply switch to an enterprise dbms system like Oracle instead.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #6
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,282
    Thanks
    57
    Thanked 523 Times in 510 Posts
    Blog Entries
    5
    Quote Originally Posted by felgall View Post
    The plural of database is database as the concept of a database is that it contains ALL data and so there should only ever be one.
    So presumably Google with all their datacentres also connect to one single server and database?

    Oh.. ok (Lets hope that hard disk powering half the planets searches doesn't give up anytime soon )
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #7
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    They could be.
    You can specify multiple volumes and spanning for the data as well. Its one of the most annoying things I have to do when performing production to development refreshes. Some of the databases have dozens of data drives for single instances.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #8
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,592
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Quote Originally Posted by tangoforce View Post
    So presumably Google with all their datacentres also connect to one single server and database?

    Oh.. ok (Lets hope that hard disk powering half the planets searches doesn't give up anytime soon )
    A single database replicated across hundreds of servers is still a single database even if it does take forever for the servers to sync.

    Being able to have the same database mirrored across multiple servers is one of the more important things that databases need to support in order to handle medium to large applications. Sure you can get away with a single server for small applications that only have a few tens of millions of rows but the same data needs to be distributed across multiple servers in order that the concept of a single database can cover medium to large systems as well.

    google.com search definitely runs a single database - when I accessed 17 separate servers running that database I only ever found two different versions of the information stored there with the servers changing from one order to the other as the database synchronised the copies.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #9
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts

    I messed up datebase

    The first i want thank you for all posts,i have been really thought that all discussions have positive affect on and on you.I found really good opinions here and i will hope that those are discussions will be in future.




    I have small problem


    I truncate database and when i want echo id i got just one number(always same number) from record set Before that, i made that every time someone hit submit button new id is out(just one and different number ).Any suggestions to fix that maybe restore database on yesterday date or something like that.

  • #10
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,592
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Quote Originally Posted by Pearl_9 View Post
    I truncate database and when i want echo id i got just one number(always same number) from record set Before that, i made that every time someone hit submit button new id is out(just one and different number ).Any suggestions to fix that maybe restore database on yesterday date or something like that.
    Can you post the SQL for the table create and the call that retrieves the id.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #11
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts

    I messed up databse

    I truncate database and now i am getting id which is always same,before i truncated every time someone hit submit new id is echo is out.Any suggestion how can fix it.By the way i echo id from record set.

  • #12
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,011
    Thanks
    2
    Thanked 312 Times in 304 Posts
    There's usually no good reason to regularly truncate a database/table, only during development or if you are running a demo site, in which case any autoinrement id value is not important.

    If retaining the last autoinrement value is important to your application, then that says that your application shouldn't be truncating any of the data in the database.

    Without more details of what you are trying to accomplish, I don't think we can directly tell you how to solve the problem.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #13
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Database

    I am sorry because i did truncated database i messed up everything.On monday i spouse sell this website.Id is very important because it is for booking system so every id mean what person is booking that room and what date he took.I don't understand how before truncated worked perfectly record set and echo ID.Every time when someone hit submit button for booking new ID was echoing out.

  • #14
    Regular Coder
    Join Date
    Aug 2013
    Posts
    181
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Database

    I checked all errors i didn't find any.

  • #15
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,592
    Thanks
    0
    Thanked 645 Times in 635 Posts
    Quote Originally Posted by CFMaBiSmAd View Post
    If retaining the last autoinrement value is important to your application, then that says that your application shouldn't be truncating any of the data in the database.
    It also says you shouldn't be using autoincrement.

    Autoincrement should only ever be used where you need unique values but don;'t care what those values are.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •