943,708 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1029
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
May 20th, 2009
0

problem with php mysql query....sos

Expand Post »
php Syntax (Toggle Plain Text)
  1. <?php
  2. if ($_SERVER['REQUEST_METHOD'] == 'POST'){
  3. $getLima=$_POST['Onoma'];
  4. include "connect.php";
  5.  
  6.  
  7. $rsSelectOnomata=mysql_query("SELECT * FROM titloslimmatos WHERE LimmatikosTypos='$getLima'");
  8. //$result=mysql_query($query);
  9.  
  10.  
  11.  
  12. while($rsRow=mysql_fetch_assoc($rsSelectOnomata)) {
  13.  
  14. echo $rsRow[titloslimmatos.LimmatikosTypos];
  15. $rsRow[titloslimmatos.MerosLogoy];
  16. $rsRow[titloslimmatos.YfologikoEpipedo];
  17. $rsRow[titloslimmatos.GlwssikoEpipedo];
  18. //$rsRow[extralimmatikoitypoi.ExtraLimmatikosTypos];
  19. //$rsRow[extralimmatikoitypoi.YfologikoEpipedo];
  20. //$rsRow[Simasia.XrisiLeksis];
  21. //$rsRow[synonimo.Synonimo];
  22. //$rsRow[synonimo.Example];
  23. //$rsRow[antitheto.Antitheto];
  24. //$rsRow[antitheto.Example];
  25. }
  26.  
  27.  
  28. }
  29. else {
  30. ?>
  31. <html>
  32. <body bgcolor="#FFFFCC">
  33. <h3><center><b>Δώστε το λήμμα που ψάχνετε</b></center></h3>
  34.  
  35. <table>
  36. <form method="post" action="<? echo $PHP_SELF ?>">
  37. <input name="onoma" type="text">
  38. <input type="Submit" name="set" >
  39. </form>
  40. </table>
  41.  
  42. </body>
  43. </html>
  44. <?
  45. }
  46. ?>
Last edited by Ezzaral; May 20th, 2009 at 10:44 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anna05 is offline Offline
5 posts
since May 2009
May 20th, 2009
0

Re: problem with php mysql query....sos

Might help to state what the problem is. I don't want to sit here looking through your code without knowing what I am looking for.

Also, use code tags.
Reputation Points: 96
Solved Threads: 124
Master Poster
Will Gresham is offline Offline
728 posts
since May 2008
May 21st, 2009
0

Re: problem with php mysql query....sos

i want to make a site on line dictionary, i use the programm xampp,
when i run this code (localhost) and insert a word that exist in my database the result is a blank page...
can someone help me? its emergency!

also sometimes when i run this code it's show me:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\index.php on line 12
Last edited by anna05; May 21st, 2009 at 1:06 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anna05 is offline Offline
5 posts
since May 2009
May 21st, 2009
0

Re: problem with php mysql query....sos

Print and execute the query in phpmyadmin / mysql console. Check the error message.
OR
Use
php Syntax (Toggle Plain Text)
  1. $rsSelectOnomata=mysql_query("SELECT * FROM titloslimmatos WHERE LimmatikosTypos='$getLima'") or die(mysql_error());
This will print the error message on failure. This is good for testing purpose (and not in the production environment as it exposes your table structure and all that!)
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
May 21st, 2009
0

Re: problem with php mysql query....sos

What nav33n said.

Also, if you want to search for values which I guess you will do for a dictionary, look into the LIKE operator for your SQL query.
Reputation Points: 96
Solved Threads: 124
Master Poster
Will Gresham is offline Offline
728 posts
since May 2008
May 21st, 2009
0

Re: problem with php mysql query....sos

index.php

php Syntax (Toggle Plain Text)
  1. <?php
  2. if ($_SERVER['REQUEST_METHOD'] == 'POST'){
  3. $getLima=$_POST['Onoma'];
  4. include "connect.php";
  5.  
  6.  
  7. $rsSelectOnomata=mysql_query("SELECT * FROM titloslimmatos WHERE LimmatikosTypos='$getLima'") or
  8.  
  9. die(mysql_error());
  10. $result1=mysql_query($query);
  11.  
  12.  
  13.  
  14. while($rsRow=mysql_fetch_assoc($rsSelectOnomata)) {
  15.  
  16. echo $rsRow[titloslimmatos.LimmatikosTypos];
  17. $rsRow[titloslimmatos.MerosLogoy];
  18. $rsRow[titloslimmatos.YfologikoEpipedo];
  19. $rsRow[titloslimmatos.GlwssikoEpipedo];
  20. //$rsRow[extralimmatikoitypoi.ExtraLimmatikosTypos];
  21. //$rsRow[extralimmatikoitypoi.YfologikoEpipedo];
  22. //$rsRow[Simasia.XrisiLeksis];
  23. //$rsRow[synonimo.Synonimo];
  24. //$rsRow[synonimo.Example];
  25. //$rsRow[antitheto.Antitheto];
  26. //$rsRow[antitheto.Example];
  27. }
  28.  
  29.  
  30. }
  31. else {
  32. ?>
  33. <html>
  34. <body bgcolor="#FFFFCC">
  35. <h3><center><b>Δώστε το λήμμα που ψάχνετε</b></center></h3>
  36.  
  37. <table>
  38. <form method="post" action="<? echo $PHP_SELF ?>">
  39. <input name="onoma" type="text">
  40. <input type="Submit" name="set" >
  41. </form>
  42. </table>
  43.  
  44. </body>
  45. </html>
  46. <?
  47. }
  48. ?>

-------------------------------------------------------------
connect.php

php Syntax (Toggle Plain Text)
  1. <?php
  2. $link = mysql_connect('localhost', 'root', '');
  3. if (!$link) {
  4. die('Could not connect: ' . mysql_error());
  5. }
  6. echo 'Connected successfully';
  7. mysql_close($link);
  8. ?>

when i run the file index.php the result was:
Connected successfully No database selected

any idea please?
Last edited by Ezzaral; May 21st, 2009 at 4:02 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anna05 is offline Offline
5 posts
since May 2009
May 21st, 2009
0

Re: problem with php mysql query....sos

Yeah. You don't have mysql_select_db("Databasename"); in your script.
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007
May 21st, 2009
0

Re: problem with php mysql query....sos

Why oh why did I even bother writing the FAQ that answers this very issue if no one is going to read it? It never stops baffling me when I see these posts.
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
May 21st, 2009
0

Re: problem with php mysql query....sos

sorry.. that was by mistake...

the code of connect.php is:

php Syntax (Toggle Plain Text)
  1. <?php
  2. $link = mysql_connect('localhost', 'root', '');
  3. if (!$link) {
  4. die('Could not connect: ' . mysql_error());
  5. }
  6. echo 'Connected successfully';
  7.  
  8. mysql_select_db("annadb");
  9.  
  10. //mysql_close($link);
  11. ?>

i run again the file index.php and the result was:
Connected successfully

whay it doesn't show me the word that i insert?
Last edited by Ezzaral; May 21st, 2009 at 4:01 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anna05 is offline Offline
5 posts
since May 2009
May 21st, 2009
0

Re: problem with php mysql query....sos

Click to Expand / Collapse  Quote originally posted by ShawnCplus ...
Why oh why did I even bother writing the FAQ that answers this very issue if no one is going to read it? It never stops baffling me when I see these posts.
Newbies prefer to skip the first post I believe ! Sigh.
Moderator
Featured Poster
Reputation Points: 524
Solved Threads: 356
Purple hazed!
nav33n is offline Offline
3,878 posts
since Nov 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Ajax Tabs integrate SMF
Next Thread in PHP Forum Timeline: Restrict Image not to cache





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC