-
Posts
2,527 -
Joined
-
Last visited
Posts posted by DeanWhitehouse
-
-
No it shouldn't, you can't run a loop through a variable, each loop is run separately.
-
Have you heard of Google?
Do you even know mysql?
-
That will only loop through the rows in $query1, have you check how many row are in their ?
-
Search engines have no clue whether the directory exists or not. They don't see the server, they only see the data that the server feeds to them. Mod rewrite is set up on the server, and any rewriting is done internally before being sent to the search engines (or user). So whether a directory exists, or whether mod rewrite just makes it look like a directory exists, it doesn't really matter.
No, that is not what i meant when you use it in links and/or submit them as pages in your site map it can make the search engine believe it is a directory and in effect come up with a 404
-
Also are you sure that your mod_rewrite works properly?
-
Huh?
Did you read what i wrote, the latest reply will be on the last page but i need to get to a specific reply which might be on the third.
Normally (without pagination)
I would do
site.com/file.php#reply_5
or something but with pagination that wouldn't work, i would need the page number.
-
Just a little warning, first off not all hosts will allow mod rewrite, second off i believe it can cause problems with some search engines as it looks for a directory then and not a file, and third if the user or you try and use
site.com/productname/
it won't work it has to be
site.com/productname
-
Use echo or print, not die
-
Just wondering, i have seen on sites that they take the user to the latest post or whatever even when using pageination but how does it work does it have to calculate what page it would be on based on the amount of replies in the database.
-
as i said arguments and if statments
-
That can all be achieved with functions stored in one page, but if you want to get more advanced then use OOP
-
Have the function allow arguments and then have if statements in the functions
-
I think it would be better to just make a file containing all your functions and include it on all pages.
-
You are missing an } just before you close the php tags
-
Hmm, have you tried contacting your host about this or is it localhost?
-
This might help, it is not using dom
http://djw-webdesign.awardspace.com/code.php?snippet=13
or
http://djw-webdesign.awardspace.com/code.php?snippet=1
or this might work
$code = "<a href=\"test\">test</a>"; $code = preg_replace("/\<a href=([^\[]+)\>(.*?)\<\/a\>/","//1",$code); echo $code;//should print test
-
Your missing a mime type, try looking at the manual on how to use the mail feature to send html emails
-
Lol, ok, if you want more help feel free to add me on msn and i can give you more assistance
(my email is in my profile)
-
O ok, well i modified this one so it similar (a bit) to mine.
<form action="search1.php" method="get" name="search"> <div align="center"> <input name="q" type="text" value="<?php echo $q; ?>" size="15"> <input name="search" type="submit" value="Search"> </div> </form> <p> <?php //connect to database $hostname="host"; $username="user"; $password="********"; $dbname="users"; //open database connection mysql_connect($hostname,$username,$password); mysql_select_db($dbname); //specify how many results to display per page $limit = 10; // Get the search variable from URL if(isset($_GET['q'])) $var = $_GET['q'] ;//Removed the @ as this suppresses errors, better to use an if statment else echo "You must enter a search parameter";//message to print if there is no get var passed //only allow alphanumeric ***--> I probably screwed this up but it seems to work except it displays "no record of found" when submitted with nothing in the search bar if (!ereg("^[A-z0-9]*[']?[A-z0-9]*$",$var)) { //trim whitespace from the stored variable $trimmed = trim($var); //separate key-phrases into keywords $trimmed_array = explode(" ",$trimmed); // check for an empty string and display a message. if (strlen($trimmed) == 0) $resultmsg = "<p><b>SEARCH ERROR</b></p><p>Only enter letters or numbers: no spaces, dashes or special characters</p>" ; $row_count = 0; // Build SQL Query for each keyword entered foreach ($trimmed_array as $trimm) { // EDIT HERE and specify your table and field names for the SQL query $query = "SELECT * FROM table_1 WHERE field_1 LIKE '\"$trimm\"' ORDER BY field_1 DESC" ; // Execute the query to get number of rows that contain search kewords $numresults = mysql_query ($query) or die ("Couldn't execute query: Reason; ".mysql_error()); $row_num_links_main =mysql_num_rows ($numresults); $row_count += $row_num_links; // next determine if 's' has been passed to script, if not use 0. // 's' is a variable that gets set as we navigate the search result pages. if(!isset($s)) $s=0; // now let's get results. $query .= " LIMIT $s,$limit" ; $numresults = mysql_query ($query) or die ("Couldn't execute query: Reason; ".mysql_error()); while($row = mysql_fetch_array($numresults)) { echo "<b>Serial: </b>" . $row['id'];//enter the proper row names echo "<b>Make: </b>" . $row['fname']; echo "<b>Model: </b>" . $row['model']; echo "<b>Caliber: </b>" . $row['city']; echo "<b>Caliber: </b>" . $row['state']; } } //end foreach ?> </p>
It might need some work, here is my search feature used on my site
<div class="post"> <h1 class="title">Search</h1> <div class="entry"> <p> <form id="searchform" method="get" action=""> <input type="text" maxlength="20" name="query" id="s" size="15" value="<?php if(isset($_GET['query'])){echo $_GET['query'];}?>" > <br> <input type="submit" value="Search" id="x" > </form> </div> </div> <?php if(isset($_GET['query'])) { $search = stripslashes($_GET['query']); $search = mysql_real_escape_string($search); $search = trim($search); if(strlen($search) < 2) echo "<div class=\"entry\">Please enter two or more values to perform a search</div>"; else { $sql = "SELECT COUNT(*) FROM djw_snippet WHERE `title` LIKE '%".$search."%' OR `poster` LIKE '%".$search."%' OR `desc` LIKE '%".$search."%'"; $result = mysql_query($sql); $r = mysql_fetch_row($result); $numrows = $r[0]; // number of rows to show per page $rowsperpage = 10; // find out total pages $totalpages = ceil($numrows / $rowsperpage); // get the current page or set a default if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) { // cast var as int $currentpage = (int) $_GET['currentpage']; } else { // default page num $currentpage = 1; } // end if // if current page is greater than total pages... if ($currentpage > $totalpages) { // set current page to last page $currentpage = $totalpages; } // end if // if current page is less than first page... if ($currentpage < 1) { // set current page to first page $currentpage = 1; } // end if if($totalpages > 1) echo "<div class=\"post\"><h2 class=\"title\">Page $currentpage out of $totalpages</h2></div>"; // the offset of the list, based on current page $offset = ($currentpage - 1) * $rowsperpage; // get the info from the db $sql = "SELECT * FROM `djw_snippet` WHERE `title` LIKE '".$search."' OR `poster` LIKE '%".$search."%' OR `tags` LIKE '%".$search."%' ORDER BY time DESC LIMIT $offset, $rowsperpage";//removed OR `example` LIKE '%".$search."%' and OR `code` LIKE '%".$search."%' $result = mysql_query($sql); // while there are rows to be fetched... $snip_count = mysql_num_rows($result); if(strlen($search) > 30) $r = substr($search,0,30)."..."; else $r = $search; if($snip_count == 1) $c = $snip_count." result found - "; else $c = $snip_count." results found - "; echo "<p class=\"byline\">".$c.$r."</p><div class=\"entry\">"; if($snip_count == 0) { echo "<br>Sorry there are no results that match your criterea"; } else { while($rows = mysql_fetch_assoc($result)) { $tags = $rows['tags']; if(substr_count(strtolower($tags),strtolower($search)) > 1) { $pos = stripos($tags,$search); $len = strlen($search); $tags = substr_replace($tags,"",$pos,$len); } $tags = str_replace(","," - ",$tags); $tags = str_ireplace($search,"<b style=\"color:#FFFFFF;\">".$search."</b>",$tags); $title = ucfirst($rows['title']); echo "<br><a href=\"http://djw-webdesign.awardspace.com/code.php?snippet=".$rows['id']."\">".$title."</a> - Posted by ".ucfirst($rows['poster'])."<br> Tags: ".$tags; } } echo "</div></div>"; /****** build the pagination links ******/ // range of num links to show $range = 3; // if not on page 1, don't show back links if ($currentpage > 1) { if($totalpages > 2) echo " <a href='{$_SERVER['PHP_SELF']}?query=$search¤tpage=1'><<</a> "; // get previous page num $prevpage = $currentpage - 1; // show < link to go back to 1 page echo " <a href='{$_SERVER['PHP_SELF']}?query=$search¤tpage=$prevpage'><</a> "; } // end if // loop to show links to range of pages around current page for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) { // if it's a valid page number... if (($x > 0) && ($x <= $totalpages)) { // if we're on current page... if ($x == $currentpage) { if($totalpages > 1) echo " [<b>$x</b>] "; // if not current page... } else { // make it a link echo " <a href='{$_SERVER['PHP_SELF']}?query=$search¤tpage=$x'>$x</a> "; } // end else } // end if } // end for // if not on last page, show forward and last page links if ($currentpage != $totalpages) { // get next page $nextpage = $currentpage + 1; // echo forward link for next page if($totalpages > 1) echo " <a href='{$_SERVER['PHP_SELF']}?query=$search¤tpage=$nextpage'>></a> "; if($totalpages > 2) echo " <a href='{$_SERVER['PHP_SELF']}?query=$search¤tpage=$totalpages'>>></a> "; } // end if /****** end build pagination links ******/ } } ?>
-
If you give me about 5-10 mins i will post up what should be a working version
-
Works for me
$str = 'tes"t'; echo addslashes($str);//prints tes\"t
-
It might be something wrong with your headers on the code, or could be because of the email address you are sending to (or if you are sending multiple emails)
-
do you want to remove it?
If so use str_replace, or use htmlentities on it to turn the quote into a html special char
-
For the second question you can use an if statement, quite simple.
For the first question maybe use a multi-dimensional array, although this will require changing some of your pages which are using this array.
Sticky forms: There has got to be a more efficient way
in PHP Coding Help
Posted
Please use php tags.
Code doesn't need to look pretty and escaping characters is fine.
But if you don't want to then you can do
$var = <<something
stuff
something>>
that would allow you to insert html without the need of escaping.
Or similar, one of the other members may know