PHP - Trying To Get A Simple Php Sql Search To Work
Hey all,
I need your help! So, I am the web designer for a small company, but I use that term loosely as I for the most part am limited to design through Dreamweaver and Muse. I know a decent amount of HTML off the top of mey head, but when it comes to PHP, yikes... My company asked me to make a simple searchable web page based on their price guide/catalog, built into their website. I have MySQL set up within their godaddy. I can use the SQL search functions to get the exact results back that I need, and the SQL cPanel gives me the following code: SELECT * FROM `SMQSQL` WHERE `Scott` = '(Whatever I search for)' ORDER BY `LINEID` ASC This makes sense to me up to here; this is very simple language, However, I have been pulling my hair out for days trying to get a simple search function as an actual PHP *PAGE* going. Basically, I need to set up a PHP form search (not hard) that will go back and log in to my SQL database named SMQ (not too bad yet), perform a search out of a specific column named Scott (getting a little harder, and somewhat lost), take the search results from specific columns (getting harder), and display them in a neat little table (now I'm lost). My SQL database is set up with the following columns: LINEID, Scott, Den, Color, Cond, 70, 70J, 75, 75J, 80, 80J, 85, 85J, 90, 90J, 95, 95J, 98, 98J, 100 Where LINEID is the index. LINEID is set to INT (5 char), the next 4 are TEXT (255 char, item descriptors), and the rest INT (9 char; prices). When the results are displayed, I would like all but the LINEID visible. I have tried and tried and tried playing with my PHP coding but am ready to shoot my computer. Here it is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Online Search</title> </head> <body> <h3>Search Online</h3> <p>You may search by Catalog number. Please use the exact Catalog number or you may receive an error. Please note that if searching for more than a basic item, include the full Catalog number WITHOUT spaces.</p> <form method="post" action="search.php?go" id="searchform"> <input type="text" name="Scott"> <input type="submit" name="submit" value="Search"> </form> <?php if(isset($_POST['submit'])){ if(isset($_GET['go'])){ $Scott=$_POST['Scott'];; $db=mysql_connect ("localhost", "guestuser", "guestuser") or die ('Error connecting to the database. Error: ' . mysql_error()); $mydb=mysql_select_db("SMQ"); $sql="SELECT Scott, Den, Color, Cond, 70, 70J, 75, 75J, 80, 80J, 85, 85J, 90, 90J, 95, 95J, P98, 98J, 100 FROM SMQ WHERE Scott LIKE '%" . $Scott . "%'; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ $Scott=$row['Scott']; $Den=$row['Den']; $Color=$row['Color']; $Cond=$row['Cond']; $70=$row['70']; $70J=$row['70J']; $75=$row['75']; $75J=$row['75J']; $80=$row['80']; $80J=$row['80J']; $85=$row['85']; $85J=$row['85J']; $90=$row['90']; $90J=$row['90J']; $95=$row['95']; $95J=$row['95J']; $98=$row['98']; $98J=$row['98J']; $100=$row['100']; echo "<ul>\n"; echo "<li>" . "<a href=\"SMQ.php?id=$Scott\">" .$Scott . " " . $Den . " " . $Color . " " . $Cond . " " . $70 . " " . $70J . " " . $75 . " " . $75J . " " . $80 . " " . $80J . " " . $85 . " " . $85J . " " . $90 . " " . $90J . " " . $95 . " " . $95J . " " . $98 . " " . $98J . " " . $100 . "</a></li>\n"; echo "</ul>"; } } else{ echo "<p>Please enter a search query</p>"; } ?>I know it's probably pretty bad, but hopefully at least you can get an idea of what I'm trying to accomplish. Please dear God tell me what I am doing wrong! I'm sure it will take a knowledgeable user 5 minutes to fix this, but you would be saving my skin! THANKS!!! Edited by mac_gyver, 14 August 2014 - 11:04 AM. removed link to op's cp and code tags please when posting code Similar TutorialsHi everyone, Would someone be able to help me out here, I cannot get this to work. Basically I have 3 pages, I with a search box which then run's a search script to display the results. Then the results are clickable, the idea is when the user clicks the result it takes them to another page which I want to display the info from the database.....if that makes sense, but when the link is clicked nothing is displaying. So here is what I have done so far: index.php - This is the page with the search box, code is : Code: [Select] <?php $dbhost = 'localhost'; $dbuser = '*********'; $dbpass = '********'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = '***********'; mysql_select_db($dbname); ?> <form name="form" action="search.php" method="get"> <input type="text" name="q" /> <input type="submit" name="Submit" value="Search" /> </form> When they hit submit it takes them to the results page, code is: Code: [Select] <?php // Get the search variable from URL $var = @$_GET['q'] ; $trimmed = trim($var); //trim whitespace from the stored variable // rows to return $limit=10; // check for an empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search...</p>"; exit; } // check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } //connect to your database ** EDIT REQUIRED HERE ** mysql_connect("localhost","********","********"); //(host, username, password) //specify database ** EDIT REQUIRED HERE ** mysql_select_db("**********") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "select * from Fish where Commonn like \"%$trimmed%\" order by Commonn"; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; echo "<p><a href=\"http://www.google.com/search?q=" . $trimmed . "\" target=\"_blank\" title=\"Look up " . $trimmed . " on Google\">Click here</a> to try the search on google</p>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $var . ""</p>"; // begin to show results set echo "Results<br><br>"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["Commonn"]; echo "$count.) <a href='info.php?ID=$ID'>$title</a>" ; $count++ ; } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> When they click the results from this page it takes them to another page which should (but doesnt) display the info from the mysql database, code is: Code: [Select] <?php // now you can display the results returned echo "$title" ; ?> Im really sorry if this is obvious or if I have dont something completely wrong but im very new to php and trying to learn on the job. Many Thanks in advance Jay Good evening, I am a newbie when it comes to programming, and I am yet learning. With several help from this forum, and other websites, I am able to finish my very first PHP project. It worked fine, as well as the search engine. However, it is foreseen that the application will be utilizing huge amount of data which would require pagination when viewing. And so I found a tutorial from php freaks as well. However, after I integrated the codes from my web application, the search engine suddenly stopped working. It is still, when I leave the field blank, which would display all data. However, if I type down a search query on the field, it still displays all data. Can anyone help me on this? Here's my complete code: <link href="add_client.css" rel="stylesheet" type="text/css"> <?PHP include("dbconnection.php"); $query = "SELECT * FROM records"; if(isset($_POST["btnSearch"])) { $query .= " WHERE last_name LIKE '%".$_POST["search"]."%' OR first_name LIKE '%".$_POST["search"]."%'OR territory LIKE '%".$_POST["search"]."%'OR job_title LIKE '%".$_POST["search"]."%'OR title LIKE '%".$_POST["search"]."%'OR employer LIKE '%".$_POST["search"]."%' ORDER BY territory ASC" ; $result = mysql_query($query, $connection) or die(mysql_error()); } ?> <table width="760" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="199" align="center" valign="top"><a href="login.html"><img src="invent-asia.gif" alt="" width="152" height="58" border="0" /></a> <script type="text/javascript" src="menu.js"></script></td> <td width="176" align="right" valign="bottom"><a href="main.php"><img src="Home.jpg" width="104" height="20" border="0"/></a></td> <td width="130" align="right" valign="bottom"><img src="View.jpg" width="104" height="20" border="0"/></td> <td width="146" align="right" valign="bottom"><a href="add_client.php"><img src="Add.jpg" width="104" height="20" border="0"/></a></td> <td width="109" align="right" valign="bottom"> </td> </tr> </table></td> </tr> <tr> <td><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="200" height="3" bgcolor="#1B1C78"><img src="images/topspacerblue.gif" alt="" width="1" height="3" /></td> <td width="560" bgcolor="#0076CC"><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /></td> </tr> </table></td> </tr> <tr> <td height="553" align="center" valign="top" bgcolor="#F3FAFE"><br /> <form name="form" action="view_client.php" method="post"> <br /> <table width="351" border="0"> <tr> <td width="137" align="left" valign="middle">SEARCH RECORD:</td> <td width="144" align="center" valign="middle"><input type="text" name="search" /></td> <td width="56" align="left" valign="middle"><input type="submit" name="btnSearch" value="Search" /></td> </tr> </table> <br /> <table border="0" cellpadding="3" cellspacing="1" bordercolor="38619E" > <tr> <th width="80" align="center" bgcolor="#E0E8F3">Territory</th> <th width="330" align="center" bgcolor="#E0E8F3">Employer</th> <th width="160" align="center" bgcolor="#E0E8F3">Name</th> <th width="80" align="center" valign="middle" bgcolor="#E0E8F3"> </th> </tr> <?php $conn = mysql_connect('localhost','root','') or trigger_error("SQL", E_USER_ERROR); $db = mysql_select_db('invent-asia',$conn) or trigger_error("SQL", E_USER_ERROR); $sql = "SELECT COUNT(*) FROM records"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); $r = mysql_fetch_row($result); $numrows = $r[0]; $rowsperpage = 10; $totalpages = ceil($numrows / $rowsperpage); if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { $currentpage = (int) $_GET['currentpage']; } else { $currentpage = 1; } if ($currentpage > $totalpages) { $currentpage = $totalpages; } if ($currentpage < 1) { $currentpage = 1; } $offset = ($currentpage - 1) * $rowsperpage; $sql = "SELECT * FROM records LIMIT $offset, $rowsperpage"; $result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR); if($result) { for($i=0; $i<mysql_num_rows($result); $i++) { $id = trim(mysql_result($result, $i, "id")); $territory = trim(mysql_result($result, $i, "territory")); $employer = trim(mysql_result($result, $i, "employer")); $first_name = trim(mysql_result($result, $i, "first_name")); $last_name = trim(mysql_result($result, $i, "last_name")); echo "<td>".$territory."</td>"; echo "<td>".$employer."</td>"; echo "<td>".$last_name.", ".$first_name."</td>"; echo "<td><a href='edit_client.php?id=".$id."'>edit</a> | <a href='delete_client.php?id=".$id."'>delete</a> </td>"; echo "</tr>"; } } $range = 3; if ($currentpage > 1) { echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> "; $prevpage = $currentpage - 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> "; } for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { if (($x > 0) && ($x <= $totalpages)) { if ($x == $currentpage) { echo " [<b>$x</b>] "; } else { echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> "; } } } if ($currentpage != $totalpages) { $nextpage = $currentpage + 1; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> "; echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> "; } ?> </table> <p> <br /> </p> </form> <p> </p></td> </tr> <tr> <td height="38"><table width="760" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="200" height="35" align="center" bgcolor="#1B1C78" class=white><img src="images/topspacerblue.gif" alt="" width="1" height="3" /> <a href="disclaimer.html"><font color="#FFFFFF">Legal Disclaimer</font></a> </td> <td width="560" align="center" bgcolor="#0076CC" class=white><img src="images/topspacerlblue.gif" alt="" width="1" height="3" /> Copyright © 2006 - 2010 InventAsia Limited. All rights reserved. </td> </tr> </table></td> </tr> </table> Immediate response is very well appreciated. Thank you very much ^^ As per the code below I am trying to create a search page which enable people to search different databases in a simple method. However, the code searches each other. So if I put "What is your name?" into "Questions" it shows: Questions: "What is your name?" Answer: "Sorry, but we can not find an entry to match your query" But I am not searching the Answer database so it should just remain blank and should show: Questions: "What is your name?" Answer: (Blank) Does anyone know why it is doing this? Code: [Select] <h2>Questions</h2> <form name="search" method="post" action="<?=$PHP_SELF?>"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="category">Category</option> <Option VALUE="question">Question</option> <Option VALUE="notes">Notes</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> <? //This is only displayed if they have submitted the form if ($searching =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Now we search for our search term, in the field the user specified $data = mysql_query("SELECT * FROM questions WHERE upper($field) LIKE'%$find%'"); //And we display the results while($result = mysql_fetch_array( $data )) { echo $result['category']; echo " <br>" ; echo $result['question']; echo "<br>"; echo $result['notes']; echo "<br>"; echo "<br>"; } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$find; } // close connection mysql_close(); ?> <h2>Answers</h2> <form name="search" method="post" action="<?=$PHP_SELF?>"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="answer">Answer</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> <? //This is only displayed if they have submitted the form if ($searching =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Now we search for our search term, in the field the user specified $data = mysql_query("SELECT * FROM answers WHERE upper($field) LIKE'%$find%' LIMIT 0,10 "); //And we display the results while($result = mysql_fetch_array( $data )) { echo $result['answer']; echo " <br>"; } //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$find; } ?> OK, I am new to PHP I am wanting to create a property search using drop down boxes. I have a database with 4 main fields to search: Bedrooms (beds), Area (area), Price Range (price) and Type (type) Here is the code so far, can someone please correct it. Thanks... +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ <?php // Get the search variable from URL $var1 = @$_GET['beds'] ; $var2 = @$_GET['area'] ; $var3 = @$_GET['price'] ; $var4 = @$_GET['type'] ; $trimmed = trim($var1, $var2, $var3, $var4); // rows to return $limit=10; // check for an empty string and display a message. if ($var1 == "") { echo "<p>Please enter a search...</p>"; exit; } // check for a search parameter if (!isset($var1)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } $host = "localhost"; $username = "root"; $password = ""; //connect to your database ** EDIT REQUIRED HERE ** $link = mysql_connect($host, $username, $password) or die("Unable to connect to SQL Server"); //(host, username, password) $db = "property_db"; //specify database ** EDIT REQUIRED HERE ** mysql_select_db($db, $link) or die("Unable to select database"); //select which database we're using // Build SQL Query $results = mysql_query("SELECT * FROM house_src", $link); $numresults = mysql_num_rows($results); // get results $result = mysql_query($results) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: ". $var4 . "property, with ". $var1 . " bedrooms, in the " . $var2 . "area, with a price range of " . $var3 .""; // begin to show results set echo "Results"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["1st_field"]; echo "$count.) $title" ; $count++ ; } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> OK, I am new to PHP I am wanting to create a property search using drop down boxes. I have a database with 4 main fields to search: Bedrooms (beds), Area (area), Price Range (price) and Type (type) Here is the code so far, can someone please correct it. Thanks... ****************************** When I run it it says: Warning: trim() expects at most 2 parameters, 4 given in C:\wamp\www\search222.php on line 8 Warning: mysql_query() expects parameter 1 to be string, resource given in C:\wamp\www\search222.php on line 45 Couldn't execute query +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ <?php // Get the search variable from URL $var1 = @$_GET['beds'] ; $var2 = @$_GET['area'] ; $var3 = @$_GET['price'] ; $var4 = @$_GET['type'] ; $trimmed = trim($var1, $var2, $var3, $var4); // rows to return $limit=10; // check for an empty string and display a message. if ($var1 == "") { echo "<p>Please enter a search...</p>"; exit; } // check for a search parameter if (!isset($var1)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } $host = "localhost"; $username = "root"; $password = ""; //connect to your database ** EDIT REQUIRED HERE ** $link = mysql_connect($host, $username, $password) or die("Unable to connect to SQL Server"); //(host, username, password) $db = "property_db"; //specify database ** EDIT REQUIRED HERE ** mysql_select_db($db, $link) or die("Unable to select database"); //select which database we're using // Build SQL Query $results = mysql_query("SELECT * FROM house_src", $link); $numresults = mysql_num_rows($results); // get results $result = mysql_query($results) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: ". $var4 . "property, with ". $var1 . " bedrooms, in the " . $var2 . "area, with a price range of " . $var3 .""; // begin to show results set echo "Results"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["1st_field"]; echo "$count.) $title" ; $count++ ; } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> I found this nice search database script on line but the pagination does not work can someone tell me what is wrong with it ???? so i can work with it !!! here is the full code : Code: [Select] <?php // Get the search variable from URL $var = @$_GET['q'] ; $trimmed = trim($var); //trim whitespace from the stored variable // rows to return $limit=10; // check for an empty string and display a message. if ($trimmed == "") { echo "<p>Please enter a search...</p>"; exit; } // check for a search parameter if (!isset($var)) { echo "<p>We dont seem to have a search parameter!</p>"; exit; } //connect to your database ** EDIT REQUIRED HERE ** mysql_connect("localhost","username","password"); //(host, username, password) //specify database ** EDIT REQUIRED HERE ** mysql_select_db("database") or die("Unable to select database"); //select which database we're using // Build SQL Query $query = "select * from the_table where 1st_field like \"%$trimmed%\" order by 1st_field"; // EDIT HERE and specify your table and field names for the SQL query $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; echo "<p><a href=\"http://www.google.com/search?q=" . $trimmed . "\" target=\"_blank\" title=\"Look up " . $trimmed . " on Google\">Click here</a> to try the search on google</p>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $query .= " limit $s,$limit"; $result = mysql_query($query) or die("Couldn't execute query"); // display what the person searched for echo "<p>You searched for: "" . $var . ""</p>"; // begin to show results set echo "Results"; $count = 1 + $s ; // now you can display the results returned while ($row= mysql_fetch_array($result)) { $title = $row["1st_field"]; echo "$count.) $title" ; $count++ ; } $currPage = (($s/$limit) + 1); //break before paging echo "<br />"; // next we need to do the links to other results if ($s>=1) { // bypass PREV link if s is 0 $prevs=($s-$limit); print " <a href=\"$PHP_SELF?s=$prevs&q=$var\"><< Prev 10</a>  "; } // calculate number of pages needing links $pages=intval($numrows/$limit); // $pages now contains int of pages needed unless there is a remainder from division if ($numrows%$limit) { // has remainder so add one page $pages++; } // check to see if last page if (!((($s+$limit)/$limit)==$pages) && $pages!=1) { // not last page so give NEXT link $news=$s+$limit; echo " <a href=\"$PHP_SELF?s=$news&q=$var\">Next 10 >></a>"; } $a = $s + ($limit) ; if ($a > $numrows) { $a = $numrows ; } $b = $s + 1 ; echo "<p>Showing results $b to $a of $numrows</p>"; ?> Ok so a few days ago I was alerted that my site was vulnerable to XSS injections in my search form. I modified the php script to prevent any malicious activity by adding this to it: Code: [Select] "/\<(script).*\>.*\<\/(script)\>/isU", " ", But now anytime I put anything into the search form nothing is returned. Please advice. Here is the script in it's entirety. Code: [Select] <?php mysql_connect ("localhost", "","") or die (mysql_error()); mysql_select_db (""); $search = mysql_real_escape_string(preg_replace('/[^\w\'\"\@\-\.\,\(\) ]/i', '', "/\<(script).*\>.*\<\/(script)\>/isU", " ", $_POST['search'])); $sql = mysql_query("SELECT * FROM sales WHERE contact LIKE '%$search%' OR phone LIKE '%$search%' OR office LIKE '%$search%' OR town LIKE '%$search%' OR cross_streets LIKE '%$search%' OR description LIKE '%$search%' OR email LIKE '%$search%' OR price LIKE '%$search%' order by `date_created`"); echo "<strong>Click Headers to Sort</strong>"; echo "<br/><strong>Your Results for: </strong>"; echo $_POST['search']; echo "<table border='0' align='center' bgcolor='#999969' cellpadding='3' bordercolor='#000000' table class='sortable' table id='results'> <tr> <th> Title </th> <th> Price </th> <th> Bed </th> <th> Bath </th> <th> Contact </th> <th> Office </th> <th> Phone </th> </tr>"; while ($row = mysql_fetch_array($sql)){ echo "<tr> <td bgcolor='#FFFFFF' style='color: #000' align='center'> <a href='classified/sales/index.php?id=".$row['id']."'>" . $row['title'] . "</a></td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>$" . $row['price'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['rooms'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['bath'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['contact'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['office'] . "</td> <td bgcolor='#FFFFFF' style='color: #000' align='center'>" . $row['phone'] . "</td> </tr>"; } echo "</table>"; print_r($apts) ?> Thanks i have enters some data using form which submit data in sql table1 like this, Fields name in table -->> id First name Lastname Date data saved -->> 1 user 1 2011-05-10 2 user 2 2011-05-11 3 user 3 2011-05-12 now i dont want to duplicate date in database let say while inserting data using form, Firstname : ____________ Lasename : ____________ Date : ____________ (i dont want this date to b save if the date alredy exist in database, it should prompt user "Date already exist and to edit click here (this will be the link to that date which is already exist so that we can edit) " ) SAVE i user files , form.php , insert.php(so insert values in database) , so tell me what function should i use to solve my problem.... I found this amazing tutorial and i try to change it for a different database, but when i do a search it never finds anything. <?php $dbHost = 'localhost'; // localhost will be used in most cases // set these to your mysql database username and password. $dbUser = 'root'; $dbPass = '123'; $dbDatabase = 'ergasia2'; // the database you put the table into. $con = mysql_connect($dbHost, $dbUser, $dbPass) or trigger_error("Failed to connect to MySQL Server. Error: " . mysql_error()); mysql_select_db($dbDatabase) or trigger_error("Failed to connect to database {$dbDatabase}. Error: " . mysql_error()); // Set up our error check and result check array $error = array(); $results = array(); // First check if a form was submitted. // Since this is a search we will use $_GET if (isset($_GET['search'])) { $searchTerms = trim($_GET['search']); $searchTerms = strip_tags($searchTerms); // remove any html/javascript. if (strlen($searchTerms) < 3) { $error[] = "Ο όρος αναζήτησις πρέπει να είναι έχει περισσότερους από 3 χαρακτήρες."; }else { $searchTermDB = mysql_real_escape_string($searchTerms); // prevent sql injection. } // If there are no errors, lets get the search going. if (count($error) < 1) { $searchSQL = "SELECT Fname, Surname, StreetName, status FROM EMPLOYEES WHERE "; // grab the search types. $types = array(); $types[] = isset($_GET['Fname'])?"`Fname` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['Surname'])?"`Surname` LIKE '%{$searchTermDB}%'":''; $types[] = isset($_GET['StreetName'])?"`StreetName` LIKE '%{$searchTermDB}%'":''; $types = array_filter($types, "removeEmpty"); // removes any item that was empty (not checked) if (count($types) < 1) $types[] = "`sbody` LIKE '%{$searchTermDB}%'"; // use the body as a default search if none are checked $andOr = isset($_GET['matchall'])?'AND':'OR'; $searchSQL .= implode(" {$andOr} ", $types) . " ORDER BY `stitle`"; // order by title. $searchResult = mysql_query($searchSQL) or trigger_error("There was an error.<br/>" . mysql_error() . "<br />SQL Was: {$searchSQL}"); if (mysql_num_rows($searchResult) < 1) { $error[] = "The search term provided {$searchTerms} yielded no results."; }else { $results = array(); // the result array $i = 1; while ($row = mysql_fetch_assoc($searchResult)) { $results[] = "{$i}: {$row['stitle']}<br />{$row['sdescription']}<br />{$row['sbody']}<br /><br />"; $i++; } } } } function removeEmpty($var) { return (!empty($var)); } ?> <html> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>My Simple Search Form</title> <style type="text/css"> #error { color: red; } </style> <body> <?php echo (count($error) > 0)?"The following had errors:<br /><span id=\"error\">" . implode("<br />", $error) . "</span><br /><br />":""; ?> <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm"> Search For: <input type="text" name="search" value="<?php echo isset($searchTerms)?htmlspecialchars($searchTerms):''; ?>" /><br /> Search In:<br /> Body: <input type="checkbox" name="body" value="on" <?php echo isset($_GET['body'])?"checked":''; ?> /> | Title: <input type="checkbox" name="title" value="on" <?php echo isset($_GET['title'])?"checked":''; ?> /> | Description: <input type="checkbox" name="desc" value="on" <?php echo isset($_GET['desc'])?"checked":''; ?> /><br /> Match All Selected Fields? <input type="checkbox" name="matchall" value="on" <?php echo isset($_GET['matchall'])?"checked":''; ?><br /><br /> <input type="submit" name="submit" value="Search!" /> </form> <?php echo (count($results) > 0)?"Your search term: {$searchTerms} returned:<br /><br />" . implode("", $results):""; ?> </body> </html> The table which i use is the following ---------------- |EMPLOYEES| ---------------- |ssn | ---------------- |Fname ---------------- |postal code | ---------------- |salary | ---------------- |street name| ---------------- |street number | ------------------- |surname | ----------------- |UnionMembershipNumber| --------------------------------- |password | ----------------- |status | ---------------- hi iam trying to make a simple search form to search the members tables based on there input. iam new php so most of my code is guess work Code: [Select] <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm"> <label for="country">Country:</label> <input type="text" name="country" /> <label for="state">State:</label> <input type="text" name="state" /> <label for="city">City:</label> <input type="text" name="city" /> <input type="submit" value="submit" /> </form> <? if ($_GET == array ()) { //Define a variable that will be used to query the members; in this case, it would select all members $query = "SELECT * FROM users"; } else { //If the user typed at least one thing (in the form OR the url) if (count ($_GET) == 1) { //If what they typed is only for one criteria, define a variable that creates a query for only ONE criteria to search for $query = "SELECT * FROM users WHERE 1"; foreach ($_GET as $field => $value) { $query .= " AND $field = '$value'"; } //If the user has typed in more than one field and hits search } else { //Define a variable for a query that selects members based off each criteria $query = "SELECT * FROM users WHERE 1"; foreach ($_GET as $field => $value) { $query .= " AND $field LIKE '%$value%'"; } } while($info = mysql_fetch_array( $data )) { Echo "<img src='http://datenight.netne.net/images/".$info['img'] ."' width='150' height='250''> <br>"; Echo "<b>Name:</b> ".$info['username'] . "<br> <hr>"; Echo "<b>Sex:</b> ".$info['sex'] . " <br><hr>"; Echo "<b>Intrested in</b>" . "<br><hr>"; Echo "".$info['rel'] . " "; Echo "".$info['frwb'] . " "; Echo "".$info['ons'] . " "; Echo "".$info['fr'] . "<br><hr>"; Echo "<b>About me:</b> ".$info['aboutme'] . "<br><hr> "; Echo "<b>Looking for:</b> ".$info['looking'] . " <br><hr>"; Echo "<a href='login_success.php'>'Back'</a>"; } ?> </body> </html> while($info = mysql_fetch_array( $data )) { is not vaild error Thank you for writing this script. It has been most helpful in doing a search for a website I manage. Everything is working fine but I would like some help in modifying the "$results[] = " line. For instance, I would like to show or hide the address of a business if a data value is set to 1 if set to 0 then hide. Same for the business web address. if ( $row_memberrs['WebAddress'] != NULL ) { echo <a href=\"{$row['WebAddress']}\" target=_blank>Visit our website</a>; } I am a newbie to php and would appreciate any help you can give me. Here is a link to the search page http://www.wildwoodba.org/searchsite.php If it is not too much trouble I would like to hide the check boxes and make it search the body, title or disc for the words entered. Thank you for your help. Hi Guys, I am trying to get the below code to work - search form with textbox, dropdown and submit button. I found scripts on the web but the addition of the pagination just causes an error. I spent hours tweaking it but alas I cant see the solution. Perhaps someone could help please. I would love to see an example with 1 textbox, 2 dropdowns and a submit button or a link to such a tutorial. My googling has hit a dead end. In the below code I can run a search and the reults are listed on results.php. Results get screwed up when I go to pagination page 2,3,4 etc...I think i need to integrate $max somewhere in the Code: [Select] $data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'"); Thanks Code: [Select] <h2>Search</h2> <form name="search" method="post" action="results.php"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="fname">First Name</option> <Option VALUE="lname">Last Name</option> <Option VALUE="result">Profile</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form> //results.php <? // Grab POST data sent from form $field = @$_POST['field'] ; $find = @$_POST['find'] ; $searching = @$_POST['searching'] ; //This is only displayed if they have submitted the form if ($searching =="yes") { echo "<h2>Results</h2><p>"; //If they did not enter a search term we give them an error if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } // Otherwise we connect to our Database mysql_connect("mysql.yourhost.com", "user_name", "password") or die(mysql_error()); mysql_select_db("database_name") or die(mysql_error()); // We preform a bit of filtering $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); //Now we search for our search term, in the field the user specified $data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'"); //This counts the number or results - and if there wasn't any it gives them a little message explaining that $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, but we can not find an entry to match your query<br><br>"; } //And we remind them what they searched for echo "<b>Searched For:</b> " .$find; } ?> <?php if(!isset($_REQUEST['pagenum'])) { $pagenum=1; } else { $pagenum=$_REQUEST['pagenum']; } //Here we count the number of results //Edit $data to be your query $rows = mysql_num_rows($data); //This is the number of results displayed per page $page_rows = 4; //This tells us the page number of our last page $last = ceil($rows/$page_rows); //this makes sure the page number isn't below one, or more than our maximum pages if ($pagenum < 1) { $pagenum = 1; } elseif ($pagenum > $last) { $pagenum = $last; } //This sets the range to display in our query $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; //This is your query again, the same one... the only difference is we add $max into it //$data = mysql_query("SELECT * FROM topsites $max") or die(mysql_error()); this works with pagination hmmm //This is where you display your query results //And we display the results while($result = mysql_fetch_array( $data )) { echo $result['fname']; echo " "; echo $result['lname']; echo "<br>"; echo $result['info']; echo "<br>"; echo "<br>"; } echo "<p>"; // This shows the user what page they are on, and the total number of pages echo " --Page $pagenum of $last-- <p>"; // First we check if we are on page one. If we are then we don't need a link to the previous page or the first page so we do nothing. If we aren't then we generate links to the first page, and to the previous page. if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } //just a spacer echo " ---- "; //This does the same as above, only checking if we are on the last page, and then generating the Next and Last links if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } ?> I am currently looking to have two pages, one with a search form (textbox and button) and output the results (from database table) based on the strings input to another page. how do i achieve this? i just want something very simple nothing too complex and advanced please im a complete novice. im using one of the tutorials on here to make a simple search form. the bit of script that i think outputs the results is $results = array(); // the result array $i = 1; while ($row = mysql_fetch_assoc($searchResult)) { $results[] = "{$i}: {$row['placing']},   {$row['racedate']},   {$row['horseid']}<br /><br />"; $i++; how do i make these results appear in a table, and how would i make it so there was a link on the date that clicked would show all the races on that day? sorry i advance as this is probably the most dumb of questions! ugh... I'm a total PHP nub and I'm having trouble with: Code: [Select] $search_by = $_POST['search_by']; $search = $_post['search']; $dbc = mysqli_connect('xx', 'artofwarsomerset', 'xx', 'artofwarsomerset') or die ('Error connecting to MySQL server'); $query = "SELECT * FROM players WHERE '$search_by' = '$search' "; $result = mysqli_query($dbc,$query) or die("Error: ".mysqli_error($dbc)); echo "<table><tr><td>Player</td><td>city</td><td>alliance</td><td>x</td><td>y</td><td>other</td><td>porters</td><td>conscripts</td><td>Spies</td><td>HBD</td><td>Minos</td><td>LBM</td><td>SSD</td><td>BD</td><td>AT</td><td>Giants</td><td>Mirrors</td><td>Fangs</td><td>ogres</td><td>banshee</td></tr>" ; while ($row = mysqli_fetch_array ($result)) { echo '<tr><td> $row['player'] </td>'; echo '<td> . $row['city']</td>'; echo '<td> . $row['alliance']</td>'; echo '<td> . $row['x']</td>'; echo '<td> . $row['y']</td>'; echo '<td> . $row['other']</td>'; echo '<td> . $row['porter']</td>'; echo '<td> . $row['cons']</td>'; echo '<td> . $row['spy']</td>'; echo '<td> . $row['hbd']</td>'; echo '<td> . $row['mino']</td>'; echo '<td> . $row['lbm']</td>'; echo '<td> . $row['ssd']</td>'; echo '<td> . $row['bd']</td>'; echo '<td> . $row['at']</td>'; echo '<td> . $row['giant']</td>'; echo '<td> . $row['fm']</td>'; echo '<td> . $row['ft']</td>'; echo '<td> . $row['ogre']</td>'; echo '<td> . $row['banshee']</td></tr></table>'; } ?> Error shows up on line 35 but I'm not sure what I've done... Also, the xx's on my dbc statement were on purpose. Current error is: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/content/64/4940664/html/artofwar/browse.php on line 35, I can't figure out where the hell it wants a ;... I am wanting to write a script that will allow a user to search youtube videos! What I have so far is not working yet, but I know it can be done! I found this code and it works and its not a million api files to get one thing working! Code: [Select] <?php # YouTube Video Collector - YouTube.class.php ##################################################### # # # YouTube Video Collector 2010 # # # # Author: CMBSystems (Chris Bearcroft) # # Copyright: CMBSystems 2010, All Rights Reserved # # Last Modded: 29-09-2010, 1:26 AM (GMT) # # # ##################################################### class YouTube { public function getURL($Search){ if(!empty($Search)){ $Search=split("\n",$Search); for($i=0;$i<count($Search);$i++){ $SearchURL=urlencode($Search[$i]); $SearchURL="http://www.youtube.com/results?search_category=10&search_type=videos&search_query={$SearchURL}"; preg_match('/\/watch\?v=(.*?)\"/',file_get_contents($SearchURL),$URL); if(strpos($URL[1],'&')){$URL=split('&',$URL[1]);$URL=$URL[0];}else{$URL=$URL[1];} $array[]="http://www.youtube.com/watch?v={$URL}"; } return $array; } } public function printForm($Search){ $Search=htmlspecialchars(stripslashes($Search)); return "<form method=\"get\" action=\"\">\n <table>\n <tr>\n". " <td><textarea cols=\"60\" rows=\"15\" name=\"search_query\">{$Search}</textarea></td>\n". " </tr>\n <tr>\n <td align=\"right\"><input type=\"submit\" value=\"Search YouTube\" /></td>\n". " </tr>\n </table>\n</form>\n"; } } ?> Code: [Select] <?php # YouTube Video Collector - YouTube.php ##################################################### # # # YouTube Video Collector 2010 # # # # Author: CMBSystems (Chris Bearcroft) # # Copyright: CMBSystems 2010, All Rights Reserved # # Last Modded: 29-09-2010, 1:26 AM (GMT) # # # ##################################################### # Require the YouTube class require 'YouTube.class.php'; # Set the PHP vars $Form = YouTube::printForm($_GET['search_query']); $Result = YouTube::getURL($_GET['search_query']); print <<<YTVSC <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>YouTube Collector</title> </head> <body> {$Form} YTVSC; print_r($Result); print <<<YTVSC </body> </html> YTVSC; ?> It allows me to have a feed link on my site to get the data http://claritydreams.com/youtube/YouTube.php?YT_Search=Staind I can push that ?YT_Search as a search from with in my client but I want to convert the file in to xml to read the data back into the client. hey...im trying to display messages stored in a database on a page using ajax. a user should choose from a drop down list the title of the message and then on selection that message should appear just below. but i cant seem to do it and i dont know why there is no errors in what ive got so far. here is the code for the drop down box where the user would select the title. Code: [Select] <form> <select name="users" onchange="showMessage(this.value)"> <option value="">Select a message:</option> <?php while($rows = mysql_fetch_array($results)) {?> <option value="1"><?php echo $rows['heading']; ?></option> <?php } ?> </select> </form> <br /> <div id="txtHint"><b>Message info will be listed here.</b></div> the drop down is successfully populated with the correct titles. here is the javascript in the HEAD of the same page: Code: [Select] <script type="text/javascript"> function showMessage(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","showmessage.php?id="+str,true); xmlhttp.send(); } </script> and here is the php file which is used to display the message upon selection. <?php $id=$_GET["id"]; $cust = new customer; $sql="SELECT * FROM messages WHERE m_id = '".$id."'"; $result = mysql_query($sql); ?> <table border='1' cellspacing="4"> <?php while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<th>Heading</th>"; echo "<th>Message</th>"; echo "</tr>"; echo "<tr>"; echo "<td>" . $row['heading'] . "</td>"; echo "<td>" . $row['message'] . "</td>"; echo "</tr>"; } ?> </table> could someone please take a look at this and see whats wrong? ive spent so long on it. if you could tell me how to correct it it would be great Guys i wrote one pinging script but i don't know it works or not... Someone help me about it works or not? <?php site1("http://site.com/sitemap.xml"); site2("http://site2.com/sitemap.xml"); function site1($url){ @file_get_contents("http://www.google.com/webmasters/tools/ping?sitemap=" . $url); @file_get_contents("http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=YahooDemo&url=" . $url); @file_get_contents("http://www.bing.com/webmaster/ping.aspx?siteMap=" . $url); @file_get_contents("http://submissions.ask.com/ping?sitemap=" . $url); } Print "Pinging1 success"; function site2($url){ @file_get_contents("http://www.google.com/webmasters/tools/ping?sitemap=" . $url); @file_get_contents("http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=YahooDemo&url=" . $url); @file_get_contents("http://www.bing.com/webmaster/ping.aspx?siteMap=" . $url); @file_get_contents("http://submissions.ask.com/ping?sitemap=" . $url); } Print "<br>Pinging2 success"; ?> Hello; I'm new to php and to programming in general, but i want to do a little app to help a process on my work, you know, just being pro-active (hoping it doesnt come and byte me in the a** in the future, you know.. "you did it now our life depend on it and you fix it right now!!). So.. I have this really simple piece of code, but its not working and i cant figure out why. I'm trying to use echo to print a couple of link but when i put in the second line everything messes up. the code is: (note the "test lines" i just added them to try to understand what is doing) <?php $client = $_GET['client']; echo "Client " . $client . "<br />"; echo "test line 1"; echo "<a href=\"link1.php?client=".$client.">Link 1</a><br>"; echo "test line 2"; echo "test line 3"; echo "<a href=\"link2.php?client=".$client.">Link 2</a><br>"; ?> When i open the page on firefox i get: === Client myclient test line 1Link 2 === Where the link (underlined) text is "Link 2" but the it points to something totally different (a mix of the rest of the code). If I remove the second link, like he <?php $client = $_GET['client']; echo "Client " . $client . "<br />"; echo "test line 1"; echo "<a href=\"link1.php?client=".$client.">Link 1</a><br>"; echo "test line 2"; echo "test line 3"; ?> I get what i'd expect: === Client myclient test line 1Link 1 test line 2test line 3 === Im totally lost, im not sure if its a browser issue, a server issue or just the code My setup: WAMP 2.1 (Apache) I'm opening the "site" with Firefox 3.6.15 and IE6, both show the same result Windows XP (dont know if it matters) The file is saved as php tried changing "echo" with "print", same result Umm.. thats it... Please let me know if you need any more info Thanks everyone edit: typo on subject edit: yet another typo hi guys, i'm learning some php, and trying some things. but i can't seem to get this to work. Code: [Select] <html> <title>simple thing</title> <body> <form action= 'blog.php' method = 'GET'> author: <input type='text' name="writer" /> <br/> article: <textarea rows="25" cols='60' name="article"></textarea> <input type="submit" value="send" /> </form> </body> <hr /> </html> <?php $writer = $_GET ['writer']; print "writer is " . $writer; ?> i want to get rid of the error. it works, but it show this error. have I used the $_GET correctly? I tried using isset() and empty(), but I think I didn't used those correctly. could you guys tell me how to fix this small thing. the error: http://i.imgur.com/DC8by.png it runs perfect, when I run it in phpED, but when running the file directly "like: http://localhost/blog.php" it gives the error. I also read somewhere this has to do with the version of php. php4 would ignore the error, and php5 shows the error. would you explain that a bit more, please? thank you |