we can always fetch from one database and rewrite to another. Here is a nice solution of it.$db1 = mysql_connect("host","user","pwd") mysql_select_db("db1", $db1); $res1 = mysql_query("query",$db1);$db2 = mysql_connect("host","user","pwd") mysql_select_db("db2", $db2); $res2 = mysql_query("query",$db2);At this point you can only fetch records from you previous ResultSet, i.e $res1 â€“ But you cannot execute new query in $db1, even if you supply the link as because the link was overwritten by the new db.so at this point the following script will fail $res3 = mysql_query("query",$db1); //this will failSo how to solve that?
take a look below. $db1 = mysql_connect("host","user","pwd") mysql_select_db("db1", $db1); $res1 = mysql_query("query",$db1);
So mysql_connect has another optional boolean parameter which indicates whether a link will be created or not, as we connect to the $db2 with this optional parameter set to 'true', so both link will remain live.
Now the following query will execute successfully. $res3 = mysql_query("query",$db1);
There is a decent page in the php manual on the subject, in short mysql_pconnect() makes a persevering association with the database which implies a SQL join that don't close when the execution of your script closes. mysql_connect()provides just for the database new association while utilizing mysql_pconnect , the capacity would first attempt to locate a (relentless) connection that is as of now open with the same host, username and password. On the off chance that one is found, an identifier for it will be returned as opposed to opening another connection... the connection with the SQL server won't be terminated when the execution of the script ends. Rather, the link will stay open for future use.
The principle distinction amongst sessions and cookies is that sessions are put away on the server, and cookies are put away on the client's PCs in the content record position. Cookies can not hold various variables,But Session can hold numerous variables.We can set expiry for a cookie,The session just stays dynamic the length of the program is open.Users don't have admittance to the information you put away in Session,Since it is put away in the server. Session is mostly utilized for login/logout reason while cookies utilizing for client movement following.