0810
12-04-2002, 08:23 PM
Simple php script
Hi how are you doing? What I am doing is that Let's say I have 15 images(gif and jpg) in my database with search enjine(type what you are looking for). First page it comes 10 images but when I click next link, it comes my error message "you have not entered search details. Please go back and try again." I think that it is because of search engine function. Without search engine function is fine,but with it, it is problem.
Why I am getting "you have not entered search details. Please go back and try again." this error
could you tell me how to fix this script.
Thanks
<?php
if(!isset($_POST['searchtype']) || !isset($_POST['searchterm']))
{
echo"you have not entered search details. Please go back and try again.";
exit;
}
else
{
$searchtype = $_POST["searchtype"];
$searchterm = $_POST["searchterm"];
}
trim($searchterm);
$dbconnect = mysql_connect("localhost", "itohideo_hide", "0810");
if (!$dbconnect) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
if (! mysql_select_db("itohideo_japan") ) {
echo( "<p>Unable to locate the host " .
"database at this time.</p>" );
exit();
}
if($searchterm==""){
exit("You should specify your request<a href=\"lookforgirl.html\">Go Back</a>");
}
$sql = "SELECT count(*) as cnt FROM girls ";
$result = mysql_query($sql);
$row=mysql_fetch_array($result);
$dtcnt=$row["cnt"];
$lim=10;
$p = intval($_GET["p"]);
if($p<1){
$p=1;
}
$st = ($p - 1) * $lim;
$prev = $p - 1;
if($prev<1){
$prev=1;
}
$next=$p + 1;
$sql="select name, images,country,age from girls WHERE " . $searchtype . " LIKE '%" . $searchterm . "%' order by name limit $st, $lim;";
$result=mysql_query($sql);
$num_results = mysql_num_rows($result);
echo("<p>itohideo.com found: " . $num_results . "</p>");
while($row=mysql_fetch_array($result))
{
echo"<table border=0 cellpadding=5 cellspacing=3 width=50% align=center>";
echo"<tr>";
echo"<td width=70% align=right>";
echo "<strong>".($i+1).".Name: ";
echo htmlspecialchars( stripslashes($row["name"]));
echo"</td>";
echo"<td valign=top rowspan=3 align=right>";
echo"<img src=\"$row[images]\" width=180 height=160>";
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td width=70% align=right>";
echo"Country: ";
echo htmlspecialchars( stripslashes($row["country"]));
echo"</td>";
echo"<tr>";
echo"<td width=70% align=right>";
echo"Age:";
echo htmlspecialchars( stripslashes($row["age"]));
echo"<td>";
echo "</tr>";
}
echo"<table>";
if($p>1){
echo "<a href=\"".$_SERVER["PHP_SELF"]."?=$prev\">Previous Page</a>";
}
if(($next - 1)*$lim<$dtcnt){
echo "<a href=\"".$_SERVER["PHP_SELF"]."?p=$next\">Next Page</a>";
}
mysql_close( $dbconnect)
?>
Hi how are you doing? What I am doing is that Let's say I have 15 images(gif and jpg) in my database with search enjine(type what you are looking for). First page it comes 10 images but when I click next link, it comes my error message "you have not entered search details. Please go back and try again." I think that it is because of search engine function. Without search engine function is fine,but with it, it is problem.
Why I am getting "you have not entered search details. Please go back and try again." this error
could you tell me how to fix this script.
Thanks
<?php
if(!isset($_POST['searchtype']) || !isset($_POST['searchterm']))
{
echo"you have not entered search details. Please go back and try again.";
exit;
}
else
{
$searchtype = $_POST["searchtype"];
$searchterm = $_POST["searchterm"];
}
trim($searchterm);
$dbconnect = mysql_connect("localhost", "itohideo_hide", "0810");
if (!$dbconnect) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>" );
exit();
}
if (! mysql_select_db("itohideo_japan") ) {
echo( "<p>Unable to locate the host " .
"database at this time.</p>" );
exit();
}
if($searchterm==""){
exit("You should specify your request<a href=\"lookforgirl.html\">Go Back</a>");
}
$sql = "SELECT count(*) as cnt FROM girls ";
$result = mysql_query($sql);
$row=mysql_fetch_array($result);
$dtcnt=$row["cnt"];
$lim=10;
$p = intval($_GET["p"]);
if($p<1){
$p=1;
}
$st = ($p - 1) * $lim;
$prev = $p - 1;
if($prev<1){
$prev=1;
}
$next=$p + 1;
$sql="select name, images,country,age from girls WHERE " . $searchtype . " LIKE '%" . $searchterm . "%' order by name limit $st, $lim;";
$result=mysql_query($sql);
$num_results = mysql_num_rows($result);
echo("<p>itohideo.com found: " . $num_results . "</p>");
while($row=mysql_fetch_array($result))
{
echo"<table border=0 cellpadding=5 cellspacing=3 width=50% align=center>";
echo"<tr>";
echo"<td width=70% align=right>";
echo "<strong>".($i+1).".Name: ";
echo htmlspecialchars( stripslashes($row["name"]));
echo"</td>";
echo"<td valign=top rowspan=3 align=right>";
echo"<img src=\"$row[images]\" width=180 height=160>";
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td width=70% align=right>";
echo"Country: ";
echo htmlspecialchars( stripslashes($row["country"]));
echo"</td>";
echo"<tr>";
echo"<td width=70% align=right>";
echo"Age:";
echo htmlspecialchars( stripslashes($row["age"]));
echo"<td>";
echo "</tr>";
}
echo"<table>";
if($p>1){
echo "<a href=\"".$_SERVER["PHP_SELF"]."?=$prev\">Previous Page</a>";
}
if(($next - 1)*$lim<$dtcnt){
echo "<a href=\"".$_SERVER["PHP_SELF"]."?p=$next\">Next Page</a>";
}
mysql_close( $dbconnect)
?>