5
Contributors
20
Replies
21
Views
5 Years
Discussion Span
Last Post by rayidi
0

you need to have access to the database outside the script

check if you have access to phpMyAdmin or a direct console access

and if you have no idea if you have access to one of those, check with your network admin

0

so any answer or any ideas from you

I would suggest you use "GOOGLE" below is a link which is searched by looking for "PHP and MYSQL", this will go over basic db connection, unless you are using PDO, then google DB connection using PDO, or even use the search function on this forum.

http://www.w3schools.com/php/php_mysql_intro.asp

Edited by Squidge

0

im traying to make good work and you are saying me how to make a question so i have to say you how to response to a question.

0

im asking just for help if i know how to do that i wasnt here spending my life with you.

0

im asking just for help if i know how to do that i wasnt here spending my life with you.

Please put the code you have used to try and connect to the database, and your SQL string.

Then perhaps people can help. DB conection is very basic PHP and MySQL. Help us to help you.

POST YOUR CODE

0

thnx for that i have it in my bookmark that page,the problem is when i search a word in db from the php it must display that because it is in the db but it shows this:Your search for andi returned no results.it must show anothers data

0
 this is the index page:
 if (isset ($_POST['keywords'])){
$keywords =mysql_real_escape_string(htmlspecialchars(trim($_POST['keywords'])));
$keywords =$_POST['keywords'];
$errors = array ();

if (empty ($keywords)){
$errors[] = ('Please enter a serch terms');
}else if (strlen($keywords)<3){
$errors[] = ('Your search terms must be three or more characters');
}else if (search_results ($keywords) == false){
$errors []= ('Your search for '.$keywords.' returned no results');
}
if(empty($errors)) {
print_r(search_results ($keywords));
}else {
foreach ($errors as $error){
0

i have a funck.inc.php page it is connect with this if you wont its code i can send you

0

f you wont its code i can send you

Yes

the problem is when i search a word in db from the php it must display that because it is in the db but it shows this:Your search for andi returned no results.

I dont see any SQL query to the database!! If you want to query a database you MUST have a query and connection.

"SELECT * FROM [TABLE_NAME] WHERE [TABLE_COLUMN] = '$keywords'"
0

To the OP you need to first learn basic 'netiquette.'

See my link in my original post.

  1. You have no idea how to correctly word your question so people can help you.
  2. You make vague statements, ' I can't search my database' with no background.
  3. You've already started a thread which is pretty much the same problem you're having here. Keep all the same questions in the SAME thread.
  4. Unfortunately, I and many others have lost the patience to help you as you are blatantly rude. Comments such as:

im asking just for help if i know how to do that i wasnt here spending my life with you.

Do you no favours. I for one, will no longer be replying to any of your questions.

Votes + Comments
And you sir, well stated :)
0
<?php include('db.inc.php');


function search_results ($keywords){
$returned_results = array ();

$where = "";

$keywords= preg_split ('/[\s]+/',$keywords);
$total_keywords = count($keywords);

foreach ($keywords as $key=> $keyword){
$where .= "'keywords' LIKE '%$keyword%'";
if($key !=($total_keywords - 1)) {
$where .= " AND ";
}
}
$results ="SELECT 'title', LEFT('description',70) as 'description' , 'url' FROM  'articles' WHERE $where";
$results_num = ($results = mysql_query ($results)) ? mysql_num_rows($results): 0 ;

if ($results_num == 0){
return false;
}else{

while ($results_row = mysql_fetch_assoc($reults)){
$returned_results [] = array (
                       'title' => $results_row ['title'],
                       'description' => $results_row ['description'],
                       'url' => $results_row ['url']


);

}
return $returned_results;

}
}
 ?>
0

hey plz i need help i told you if i know this thing i wouldn't be here if i would be rich i should lerning this thing in a college is so hard to help me ??

0

hey plz i need help i told you if i know this thing i wouldn't be here if i would be rich i should lerning this thing in a college is so hard to help me ??

People have jobs!!!! I wipe my hands

0

@Andyy121

You need to follow the syntax, for a beginer string concatnation is very difficult. Better to use the follow syntax.

// Connecting a database host using username & password
$con = mysql_connect("host", "username", "password");
// Selecting the database
$db = mysql_select_db("database", $con);

Now you have to query the db for results.

// Quering db
$results = mysql_query("SELECT * FROM user");
the above statement will select all the records from user table.

$results = mysql_query("SELECT * FROM user WHERE id=1");
//the above statement will only display the first row.
//(note:- where id is the unique number. )

If you have 5 rows with id = 1 it will display the 5 records.

If you have any questions feel free to write me.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.