954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

problem with php mysql query....sos

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$getLima=$_POST['Onoma'];
include "connect.php";


$rsSelectOnomata=mysql_query("SELECT * FROM titloslimmatos WHERE LimmatikosTypos='$getLima'");
//$result=mysql_query($query); 



while($rsRow=mysql_fetch_assoc($rsSelectOnomata)) {

echo $rsRow[titloslimmatos.LimmatikosTypos];
$rsRow[titloslimmatos.MerosLogoy];
$rsRow[titloslimmatos.YfologikoEpipedo];
$rsRow[titloslimmatos.GlwssikoEpipedo];
//$rsRow[extralimmatikoitypoi.ExtraLimmatikosTypos];
//$rsRow[extralimmatikoitypoi.YfologikoEpipedo];
//$rsRow[Simasia.XrisiLeksis];
//$rsRow[synonimo.Synonimo];
//$rsRow[synonimo.Example];
//$rsRow[antitheto.Antitheto];
//$rsRow[antitheto.Example];
}


}
else {
?>
<html>
<body bgcolor="#FFFFCC">
<h3><center><b>Δώστε το λήμμα που ψάχνετε</b></center></h3>

<table>
<form method="post" action="<? echo $PHP_SELF ?>">
<input name="onoma" type="text">
<input type="Submit" name="set" >
</form>
</table>

</body>
</html>
<?
}
?>
anna05
Newbie Poster
5 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

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.

Will Gresham
Master Poster
755 posts since May 2008
Reputation Points: 96
Solved Threads: 125
 

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

anna05
Newbie Poster
5 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

Print and execute the query in phpmyadmin / mysql console. Check the error message.
OR
Use

$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!)

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

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.

Will Gresham
Master Poster
755 posts since May 2008
Reputation Points: 96
Solved Threads: 125
 

index.php

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$getLima=$_POST['Onoma'];
include "connect.php";


$rsSelectOnomata=mysql_query("SELECT * FROM titloslimmatos WHERE LimmatikosTypos='$getLima'") or 

die(mysql_error());
$result1=mysql_query($query); 



while($rsRow=mysql_fetch_assoc($rsSelectOnomata)) {

echo $rsRow[titloslimmatos.LimmatikosTypos];
$rsRow[titloslimmatos.MerosLogoy];
$rsRow[titloslimmatos.YfologikoEpipedo];
$rsRow[titloslimmatos.GlwssikoEpipedo];
//$rsRow[extralimmatikoitypoi.ExtraLimmatikosTypos];
//$rsRow[extralimmatikoitypoi.YfologikoEpipedo];
//$rsRow[Simasia.XrisiLeksis];
//$rsRow[synonimo.Synonimo];
//$rsRow[synonimo.Example];
//$rsRow[antitheto.Antitheto];
//$rsRow[antitheto.Example];
}


}
else {
?>
<html>
<body bgcolor="#FFFFCC">
<h3><center><b>Δώστε το λήμμα που ψάχνετε</b></center></h3>

<table>
<form method="post" action="<? echo $PHP_SELF ?>">
<input name="onoma" type="text">
<input type="Submit" name="set" >
</form>
</table>

</body>
</html>
<?
}
?>


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

<?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>


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

any idea please?

anna05
Newbie Poster
5 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

Yeah. You don't have mysql_select_db("Databasename"); in your script.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

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.

ShawnCplus
Code Monkey
Team Colleague
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
 

sorry.. that was by mistake...

the code of connect.php is:

<?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';

mysql_select_db("annadb");

//mysql_close($link);
?>


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

whay it doesn't show me the word that i insert?

anna05
Newbie Poster
5 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 
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.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

sorry.. that was by mistake...

the code of connect.php is:

<?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';

mysql_select_db("annadb");

//mysql_close($link);
?>

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

whay it doesn't show me the word that i insert?

Okay! Now I am totally lost. Where are you inserting the values ? Check this link. I hope that link will answer your question.

And pleaseee(eee). Wrap your code in [code=php] code here [/code] tags.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

Line 16 has echo, but lines 17 to 26 not. if php is in safe mode the error not appear, only show a blank page. May be this help.

artsist
Newbie Poster
1 post since May 2009
Reputation Points: 10
Solved Threads: 0
 
Line 16 has echo, but lines 17 to 26 not. if php is in safe mode the error not appear, only show a blank page. May be this help.


This actually isn't an error, it just won't do anything. Those are completely valid statements (like I said, they just don't do anything)

ShawnCplus
Code Monkey
Team Colleague
1,583 posts since Apr 2005
Reputation Points: 526
Solved Threads: 268
 

You help me very much...
Thanks a lot all of you....!!!

anna05
Newbie Poster
5 posts since May 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You