User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 374,185 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,495 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 313 | Replies: 1
Reply
Join Date: Mar 2008
Posts: 8
Reputation: cmax is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
cmax cmax is offline Offline
Newbie Poster

mysql

  #1  
Apr 21st, 2008
hello to every body,
i have a problem in mysql database
i dont know where i made mistake, i wrote a database this one dow,
please show me where is my mistake or how i can use in simple way


  1. <?
  2. trim($searchterm);
  3. if (!$searchtype || !$searchterm)
  4. {
  5. echo "You have not enter search details. please go back and try again.";
  6. exit;
  7. }
  8.  
  9. $searchtype=addslashes($searchterm);
  10. $searchtype=addslashes($searchterm);
  11.  
  12. @ $db=mysql_pconnect("localhost","root","cmax");
  13.  
  14. if (!$db)
  15. {
  16. echo "Error:could not connect to database.please try again later.";
  17. exit;
  18. }
  19. mysql_select_db("book");
  20. $query="select*from books where ".$searchtype." like
  21. '%".$searchterm."%'";
  22. $num_results=mysql_num_rows($result);
  23. echo "<p>Number of book found: ".$num_results."</p>";
  24. for ($i=0; $i <$num_results; $i++)
  25. {
  26. $row=mysql_fetch_array($result);
  27. echo "<p><strong>".($i+1).".Title: ";
  28. echo htmlspecialchars( stripslashes($row["title"]));
  29. echo "</strong><br>Author: ";
  30. echo htmlspecialchars (stripslashes($row["author"]));
  31. echo "<br>ISBN: ";
  32. echo htmlspecialchars (stripslashes($row["isbn"]));
  33. echo "<br>price: ";
  34. echo htmlspecialchars (stripslashes($row["price"]));
  35. echo "</p>";
  36. }
  37.  
  38. ?>
Last edited by peter_budo : Apr 22nd, 2008 at 5:10 am. Reason: Keep It Organized - please use [code] tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2007
Posts: 102
Reputation: mwasif is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 12
mwasif mwasif is offline Offline
Junior Poster

Re: mysql

  #2  
Apr 21st, 2008
What do you expect from the code and how it is behaving?

  1. trim($searchterm);
  2. should be
  3. $searchterm = trim($searchterm);
Last edited by peter_budo : Apr 22nd, 2008 at 5:11 am. Reason: Keep It Organized - please use [code] tags
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MySQL Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the MySQL Forum

All times are GMT -4. The time now is 4:50 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC