Jump to content

strago

Members
  • Posts

    93
  • Joined

  • Last visited

Everything posted by strago

  1. <?php mysql_connect("localhost", "root", "PASSWORD") or die(mysql_error()); mysql_select_db("DATABASENAME") or die(mysql_error()); $pageresults = $_GET['pageresults']; $query = $_GET['q']; if(!empty($_GET['q'])){ $query=mysql_real_escape_string(trim($_GET['q'])); $searchSQL="SELECT * FROM memes WHERE `title` LIKE '%{$query}%' OR `source` LIKE '%{$query}%' OR `category` LIKE '%{$query}%' OR `body` LIKE '%{$query}%' OR `facebook` LIKE '%{$query}%' ORDER by `title` LIMIT $pageresults,10"; $back=($pageresults-10); $next=$pageresults+10; $searchResult=mysql_query($searchSQL); if(mysql_num_rows($searchResult) <= 0) { echo "No results"; } else { while ($row=mysql_fetch_assoc($searchResult)){ $results[]="<BR><a href='file.php?id={$row['id']}'>{$row['title']}</a> - {$row['source']}"; } echo implode($results); echo "<P>"; if ($pageresults > 1) echo "<P><a href='file.php?q=$query&pageresults=$back'>Back</a> - "; if(mysql_num_rows($searchResult) < $next+1) echo " <a href='file.php?q=$query&pageresults=$next'>Next</a>"; } } ?> if(mysql_num_rows($searchResult) < $next+1) is giving me trouble. How do you get rid of the 'Next' link on the last page of the results? And how do you remove the requirement of having in the URL &pageresults=0 I would like Page one to be like file.php?q=keyword then Page two and so on, as it should be... file.php?q=keyword&pageresults=0 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/site1/public_html/file.php on line 15 get's generated with the pageresults gone, which is if(mysql_num_rows($searchResult) <= 0) At $searchSQL="SELECT * FROM memes WHERE `title` LIKE '%{$query}%' OR `source` LIKE '%{$query}%' OR `category` LIKE '%{$query}%' OR `body` LIKE '%{$query}%' OR `link` LIKE '%{$query}%' ORDER by `title` LIMIT $pageresults,10"; how do you get it to just search everything with out having to include everything in it like that?
  2. Thanks! Yes, I'm a php n00bie!!
  3. <?php session_start(); ob_start(); mysql_connect("localhost", "root", "XXXXX") or die(mysql_error()); mysql_select_db("XXXXX") or die(mysql_error()); $page_name = $_GET["id"]; $q = mysql_query("SELECT * FROM `memes` WHERE `id` LIKE '$page_name'"); while($result = mysql_fetch_assoc($q){ $db_title = $result["title"]; $db_image = $result["image"]; $db_body = $result["body"]; } echo " <h1>$db_title</h1> <p>$db_image</p> Text: $db_body "; ?> generates Parse error: syntax error, unexpected '{' in /home/site1/public_html/Memes.php on line 10 Line 10 being while($result = mysql_fetch_assoc($q){ I'm trying to use the URL to get the content from the database. filename.php?id=1
  4. $titleurl = preg_replace('/[^a-zA-Z0-9_ -%]/', '-', $d); $titleurl = preg_replace('/[ ]/', '-', $titleurl); How do you add to this to replace ---- with - --- with - -- with - and remove quotes? How do you remove a - if it's at the very end of $titleurl. For example, replace My-iPhone- with My-iPhone
  5. I'm going to manually be converting a lot of static text into being in a database and am just wondering what characters I need to add a \ to before the character. Any others along with " and '
  6. preg_match_all('/(www.domain.com\/[a-z0-9-_\.&=:/])\"/i', $html, $matches); and preg_match_all('/(www.domain.com\/((.*))\"/i', $html, $matches); totally kill it. Only with preg_match_all('/(www.domain.com\/([^"]+))\"/i', $html, $matches); or preg_match_all('@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)@',$html,$matches); can I get it to partly work. Works with static normal URLs, but not something like domain.com/cgi-bin/file.cgi?whatever=whatever&whatever=whatever%2B-more%2B-stuff%2B-is%2B-here%2B-ok
  7. preg_match_all('/(www.DOMAIN.com\/([^"]+))\"/i', $html, $matches); How do you make this match any URL on the domain including URLs with ? = & type of characters.
  8. $getURL = mysql_fetch_assoc(mysql_query("SELECT `urlname` FROM `workingurls` ORDER BY RAND() LIMIT 1")); spits out Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /public_html/script.php on line 130 How do you make mysql_fetch_assoc a valid MySQL result resource?
  9. Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^([^.]+)/([^.]+)$ index.php?p=$1/$2 [L] or RewriteRule ^([^.]+)$ index.php?p=$1 [L] if you're going from com/index.php?p=Free-Quote to com/Free-Quote
  10. Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^about/([^.]+)/$ about.php?x=$1 [L]
  11. <?php $user = $_GET['user']; $request_url ="http://www.domain.com/logs.shtml"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $request_url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); //THIS NEEDS CHANGED!!!!! $regex='|$user - (.*?) - $user|'; preg_match_all($regex,$result,$parts); $logs=$parts[1]; foreach($logs as $log){ echo "<B>".$log."</B><br>"; } curl_close($ch); ?> The logs file looks like username - log info - log info - log info - username For a URL like http-//www.domain.com/view-logs.php?user=strago I want it to spit out just the lines from the log file that got strago - log info - log info - log info - strago
  12. Wow!! Thanks!! That was *really* easy!!! $price = $rslt[0]['EARNINGS']; $price = str_replace("$",'',$price); $sum_total = $price * .40; print_r($price); echo "$"; print_r($sum_total);
  13. I can' t even get the simple str_replace to work. I got.... $rslt = $client->getTodaySubIDStats($key, $sub_id); $rslt = str_replace("EARNINGS",'',$rslt); $rslt = str_replace("Array","",$rslt); $rslt = str_replace("\r","",$rslt); $rslt = str_replace("\n","",$rslt); $rslt = str_replace("\t","",$rslt); print_r($rslt); which spits out.... Array ( [0] => Array ( [EARNINGS] => $100.40 [CLICKS] => 1301 [LEADS] => 100 [sUB_ID] => yacker [EPC] => $0.11 ) ) I would like to have every thing removed except the '$100.40' (The number is always changing). Then remove the $ and do math 100.40*.40, so in the end, all it spits out is 40.16 and always only have two digits after the period.
  14. Any time a URL conflicts with the other URLS, you have to add something unique to the URL, like an extra fake direcory, like RewriteRule ^shop/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ index.php?page=$1&c=$2 index.php?page=2&c=1 being domaIn.com/shop/2/1 or adding a fake extension. RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)\.html$ index.php?page=$1&c=$2 being domaIn.com/2/1.html or RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)\.html$ index.php?page=$2&c=$3 and you edit the script to make the first directory in the URL be a variable like boyswallart. And the extention wt the end of the URL will keep them from having conflicts, for nrmkidswallart.com/boyswallart/2/1.html
  15. Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^video/([^.]+)/([^.]+)/([^.]+)$ index.php?do=video&id=$1,$2,$3 [L]
  16. You need something unique in the URL, like domain.com/pages/ Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^pages/([^.]+)/([^.]+)$ pages.php?act=$1&page=$2
  17. It needs to know if you want the album or info page. They can't both have the same kind of URL. Adding a fake directory will fix it. Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^fx/([^.]+)/album/([^.]+)$ index.php?fx=$1&album=$2 [NC,L] RewriteRule ^fx/([^.]+)/info/([^.]+)$ index.php?fx=$1&info=$2 [NC,L] RewriteRule ^([^.]+)$ index.php?fx=$1 [L]
  18. RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?user=$1 is probably messing it up, making profile.php try to take all the URLs. Try changing the order of it... Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^([a-zA-Z0-9_-]+)/section$ section.php?user=$1 RewriteRule ^([a-zA-Z0-9_-]+)/section/$ section.php?user=$1 RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?user=$1 RewriteRule ^([a-zA-Z0-9_-]+)/$ profile.php?user=$1 and if that doesn't do it, making something unique in the URL should make it work. Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^([^.]+)/section/$ section.php?user=$1 [L] RewriteRule ^([^.]+)/section$ section.php?user=$1 [L] RewriteRule ^([^.]+)/profile/$ profile.php?user=$1 [L] RewriteRule ^([^.]+)/profile$ profile.php?user=$1 [L] Though most sites have it in the other order, like RewriteRule ^profile/([^.]+)/$ profile.php?user=$1 [L]
  19. Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^([^.]+)/([^.]+)/([^.]+)$ page.php?theurl=$1/$2/$3 [L] RewriteRule ^([^.]+)/([^.]+)$ page.php?theurl=$1/$2 [L] RewriteRule ^([^.]+)$ page.php?theurl=$1 [L] RewriteRule ^feed.xml feed.php [L]
  20. Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^([^.]+)/([^.]+)$ view_topics.php?fid=$1&tid=$2 [L] RewriteRule ^([^.]+)/$ view_topics.php?fid=$1 [L] If you have non-forum parts of the site, and .htaccess is in the main directory of the site, it can mess the site up if you don't have something unique in the URL, like RewriteRule ^forum/([^.]+)/topic/([^.]+)$ view_topics.php?fid=$1&tid=$2 [L] RewriteRule ^topic/([^.]+)/$ view_topics.php?fid=$1 [L]
  21. Options +Indexes Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteRule ^fr/forum/viewtopic.php?t=([^.]+)$ http://www.domain.com/forum/$1 [R=301,L]
  22. The CSS code needs to be changed to how it would be if the mod_rewrite URL was the real URL. Browsers and CSS don't know you're using mod_rewrite. They act like it's the mod_rewrite URL is the real URL.
  23. Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^profiles/([^.]+)$ profiles.php?username=$1 [L] with the links pointing to domain.com/profiles/username if you're only getting there by a link, it shouldn't cause any problems. Now forums, they are harder set-up so they go to a URL like that.
  24. Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^blog/article/id/([^.]+)/$ blog/article/index.php?id=$1 [L] For an even shorter URL... RewriteRule ^article/([^.]+)/$ blog/article/index.php?id=$1 [L] domain.com/article/#/
  25. Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^search/([^.]+)/page/([^.]+)/$ mysite/mypage.co.uk/Search/index.php?Search-Term=$1&page=$2 [L] for domain.com/search/ANYTHING/page/#/
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.