Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old December 18th, 2003, 04:44 PM
The Squirrel The Squirrel is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mid-Indiana, USA
Posts: 153 The Squirrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to The Squirrel
Questions: users, insert, tips/advice

In MySQL I'm trying to create a user that I will be using for access to the database when someone visits the site and uses the search function but I cannot get it to work.

Here is what I insert into MySQL:

Code:
grant all
    on *
    to admin identified by 'my_password'
    with grant option;


when I execute that command here is what I get:

Code:
ERROR 1044: Access denied for user: '@localhost' to database 'engineering'


I've searched the forum for similar problems and came across a couple, but the solutions to their problems didn't help any.

Also I am seeking advice on how to build my database so that it is most effective.
I have close to 35 pages of content on our company website and it all needs to be searchable. That is not including pages that I will have to include for each individual product.

Now would you guys build a table for each individual page? That is the way I'm leaning towards doing it. Then in each table I plan on having it search a .txt file to get the content for the value fields that will be displayed.
Each table will have the values of page and/or product id#, text (all the text describing the item or the text on that particular page), and then a link field that contains the link to that page, and possibly a date added field.

I would like to build my first database efficiently so that I do not get into the habit of using unwise methods. Any advice would be appreciated in this regard.

I had a question regarding the insert command but I seem to have forgotten it. If I remember I will post again in this thread.

My apologies for being so long winded in this post. But thanks for the help!

The Squirrel

Reply With Quote
  #2  
Old December 18th, 2003, 09:02 PM
brut brut is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 367 brut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 30 sec
Reputation Power: 2
RE: Questions: users, insert, tips/advice

I'm not sure I follow what you're doing. If you just need a search function for a small site(35 pages), you could look into ht://Dig (*nix).

The command you're trying to use is for the DB admin to grant others access to certain DBs or tables with a specific set of permissions. This would have nothing to do with someone browsing you're website.

Reply With Quote
  #3  
Old December 19th, 2003, 12:37 PM
The Squirrel The Squirrel is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mid-Indiana, USA
Posts: 153 The Squirrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to The Squirrel
RE: RE: Questions: users, insert, tips/advice


Quote:
I'm not sure I follow what you're doing. If you just need a search function for a small site(35 pages), you could look into ht://Dig (*nix).

The command you're trying to use is for the DB admin to grant others access to certain DBs or tables with a specific set of permissions. This would have nothing to do with someone browsing you're website.


In order to access the DB to run a search query of the site you must define a username and password in order to open the DB and then the query will take place, and then return the results back to the site.
I could just leave that part empty and it will default to the default username and password for MySQL and access it, but I feel more comfortable selecting a specific user that can access it.

I'll check out that link you gave and see if that is what I need.

Thanks!
The Squirrel

Reply With Quote
  #4  
Old December 19th, 2003, 04:53 PM
brut brut is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 367 brut User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 30 sec
Reputation Power: 2
RE: Questions: users, insert, tips/advice

Sorry for the misunderstanding.
You're statement should be fine. How are you issuing this command? The error would suggest that you aren't even connecting to the database server due to not specifying a username.

Reply With Quote
  #5  
Old December 19th, 2003, 06:08 PM
The Squirrel The Squirrel is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Mid-Indiana, USA
Posts: 153 The Squirrel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to The Squirrel
RE: RE: Questions: users, insert, tips/advice

Quote:
Sorry for the misunderstanding.
You're statement should be fine. How are you issuing this command? The error would suggest that you aren't even connecting to the database server due to not specifying a username.


No worries.
I am doing this in the MySQL Monitor, and I issue the command just as I typed in my first post:
Code:
GRANT ALL
ON *
TO username IDENTIFIED BY 'my_password'
WITH GRANT OPTION;


Here is the PHP I use to get the results from the query on the site:
php Code:
Original - php Code
  1. <?php
  2. trim($searchterm);
  3. if (!$searchterm)
  4. {
  5.     echo "You have not entered any search criteria. Please try again.";
  6.     exit;
  7. }
  8.  
  9. $searchterm = addslashes($searchterm);
  10.  
  11. @ $db = mysql_pconnect("localhost", "user", "password");
  12.  
  13. if (!$db)
  14. {
  15.     echo "Error: Could not connect to database. Please try again later.";
  16.     exit;
  17. }
  18.  
  19. $query = "select * from products where ".$searchtype." like
  20. '%".$searchterm."%'";
  21. $result = mysql_query($query);
  22. $num_results = mysql_num_rows($result);
  23.  
  24. echo "<p><font size=3 font color=#7d93ab><strong>Number of results found:</strong> ".$num_results."</font></p>";
  25.  
  26. for ($i=0; $i <$num_results; $i++)
  27. {
  28. //Code to display results in fashion I want.   
  29. }
  30.  
  31. ?>


On the following line I can connect to the database if I use this, as it just uses MySQL defaults for username and password to connect to the DB.
php Code:
Original - php Code
  1. @ $db = mysql_pconnect();


But as I said before, I feel more secure if I have specific user name and password to use when querying the DB.

The Squirrel

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Questions: users, insert, tips/advice


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT