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?
×
×
  • 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.