Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Let's say someone built an internal search engine for his website, and there is the text box where visitors can enter the words they want, and all goes well and it returns a set of results.
My question is, how does the PHP do it, without anyone logged in in the valid way? Don't we have to log in using a correct password first, if we want to take advantage of search engines running on PHP? Is it called the anonymous log-in? If yes, how do I do that? (as a php builder)
Well you don't need to log anyone in to call a function. All it needs to do is pass the search string to whatever search function you have. This function should ideally sanitise the search string, then use a mysql query.
I don't understand where the login element to your question is coming from, perhaps you could expand on this? Paste your code? etc.
Incidentally, this ought to be in the PHP programming subforum if a mod is about to do this?
Thanks for your quick answer~~ by the way, where is the best forum to receive help regarding php? Did you mean within LQ or some other place on the internet?
What I *think* the OP is saying is that usually you need a username/password to access the MySQL database. This is supplied by PHP to login to the MySQL database. Much as any other language would, such as Java or whatever.
What I *think* the OP is saying is that usually you need a username/password to access the MySQL database. This is supplied by PHP to login to the MySQL database. Much as any other language would, such as Java or whatever.
Arashi, is it possible to access and search for information without a login/password? Isn't that what's happening, when we use the built-in search engines of the websites?
If that is possible and that is what's happening, how do php builders do that? Just like jamescondon stated?
Right, theres a lot of confusion here. What do you want, to be able to access a database without having the password to the database? Or do you want to know whether a user can search without having to login to the web-app it's self?
Basically, are you talking about accessing the database? Or doing it as search engines do; as in you don't need to have an account on google to use google
Arashi, is it possible to access and search for information without a login/password? Isn't that what's happening, when we use the built-in search engines of the websites?
If that is possible and that is what's happening, how do php builders do that? Just like jamescondon stated?
I don't understand what you mean. A search engine is accessing a database, which presumably has a username and password attached to it. This username and password is supplied to the database by PHP - you don't enter anything manually.
Something like: -
Code:
<?php
// Connect to database server
$hd = mysql_connect("myhost", "username", "password") or die ("Unable to connect");
// Select database
mysql_select_db ("database", $hd) or die ("Unable to select database");
// Execute sample query
$res = mysql_query("SELECT * FROM customer", $hd) or die ("Unable to run query");
// Query number of rows in rowset
$nrows = mysql_num_rows($res);
// Output
echo "The query returned $nrows row(s):\n\n";
// Iteration loop, for each row in rowset
while ($row = mysql_fetch_assoc($res)) {
// Assigning variables from cell values
$data1 = $row["title"];
$data2 = $row["fname"];
$data3 = $row["lname"];
$data4 = $row["phone"];
// Outputting data to browser
echo "ROW# $nr : $data1 $data2 $data3 $data4\n";
}
mysql_close($hd);
?>
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.