Jump to content

HuggieBear

Members
  • Posts

    1,899
  • Joined

  • Last visited

Posts posted by HuggieBear

  1. My bad... I put the wrong values in the php if condition

    [code]
    <?php
      $engine = urlencode($_GET['engine']);
      $string = urlencode($_GET['string']);

      if ($engine == "Google.com"){
          $url = "http://www.google.com/search?q=$string";
      }
      elseif ($engine == "Yahoo.com"){
          $url = "http://search.yahoo.com/search?p=$string";
      }

      header("Location: $url");
    ?>
    [/code]

    Regards
    Rich
  2. I'm determined to get this sorted for you...

    Forget all the previous stuff, lets go from scratch as it's all very confusing.

    [code]
    <?php
      // Get the parameters from the URL
      $id = $_GET['id']
      $page = isset($_GET['page']) ? $_GET['page'] : '1'; // if '&page=n' (n is a number) is in the url use it, if not, default to page=1

      // The following assumes that you have a user_id column in your pages table, and the columns are called 'content', 'page_id' and 'user_id'
      $sql = "SELECT content FROM pages WHERE page_id = '$page' AND user_id = '$id'";
      $result = mysql_query($sql);

      // We should only have one row returned, so mysql_fetch_row should be fine here
      $content = mysql_fetch_row($result);

      // Check we found a page with the page_id that was given to us and output accordingly
      if ($content){
          echo $content[0];
      else {
          echo "No record was found for Page ID $page";
      }
    ?>
    [/code]

    Now this is assuming quite a lot, but this simple bit of code should work fine and you should be able to build whatever you need around it.

    Regards
    Rich
  3. Why not have something like this...

    HTML Page (Not sure the syntax is exact):
    [code]
    <form name="search" method="GET" action="search.php">
    <select name="engine">
      <option name="google">Google.com</option>
      <option name="yahoo">Yahoo.com</option>
    </select>
    <input type="text" name="string">
    </form>
    [/code]

    This calls search.php which looks like this
    [code]
    <?php
      $engine = urlencode($_GET['engine']);
      $string = urlencode($_GET['string']);

      if ($engine == "google"){
          $url = "http://www.google.com/search?q=$string";
      }
      elseif ($engine == "yahoo"){
          $url = "http://search.yahoo.com/search?p=$string";
      }

      header("Location: $url");
    ?>[/code]

    Should work a treat.

    Regards
    Rich
  4. You could pass it in the url...

    So have the code from the db generate links like this...

    [code]
    <a href="reviews.php?id=1">Product 1</a>
    <a href="reviews.php?id=2">Product 2</a>
    [/code]

    Then have you next page (reviews.php) do another select from the database based on the $_GET['id']and propogate the forms accordingly.

    Regards
    Rich
  5. I've just noticed something...

    If the code that you've included is all you have you're missing something massive...

    [code=php:0]
    <?php
      session_start(); // this must be specified at the top if you're referring to a $_SESSION variable.
    ?>
    [/code]

    Regards
    Rich
  6. Have you tried running this in something like phpMyAdmin?  If so, the sql statement returned results you're looking for?

    Just trying to work out if it's SQL or PHP.

    Rich

    [color=red]Edit: Also, if you echo things out as you go, it's a good way to diagnose.[/color]
  7. Try this...

    [code]
    $query = "select * from call_reminder WHERE date(date) >= '$todays_date' AND date(date) <= '$max_date' AND level <= '$show->level') OR (member_group = '$show->mastermind' AND call = 'mastermind') ORDER by date, time";
    [/code]

    If that doesn't work, then post your code as previously suggested.

    Rich
  8. Try setting the session variable of 'userlevel' once a user's logged in and then use this...

    [code]
    <?php
    if ((!isset($_SESSION['userlevel'])) || ($_SESSION['userlevel'] <= 5)){ // if the session's not set, or if it's less than or equal to 5
      header("Location: index.php"); // forward them to our homepage
    }
    ?>
    [/code]

    Regards
    Rich
  9. That code's not quite right...

    [code]
    if(!isset($session['userlevel'])=>5){
    echo "<center><font face='Verdana' size='2' color=red>Sorry, you don't have sufficent access rights to use this page </font></center>";
    exit;
    [/code]

    Notice the [b][color=red]![/color][/b] before the isset()... That means negative, so in essence you're saying "if the session isn't set, and is greater than 5"... That will always evaluate to false, as something that has no value can never be greater than 5.

    Regards
    Rich
  10. Nicklas... why the parenthesis arount the first 's'?

    You don't want to match it, and it's not being user for alternation.

    Surely [color=green][tt]https?[/tt][/color] says match [color=red][tt]http[/tt][/color] and an optional [color=red][tt]s[/tt][/color]

    Regards
    Rich

  11. ok, here's a shorter version... might achieve what you're after.

    [code=php:0]
    <?php
    $string = "HereĀ“s a string  https://mysite.com with a link to www.somesite.com bla bla";
    echo preg_replace('/(https?:\/\/)?(www\.)?([^\s]+)/', '\\3', $string);
    ?>
    [/code]

    Also, there's another problem with your code wildteen88.. what about if my domain's http://www.ilovethewww.com ?

    What's going to happen then  ;)

    Regards
    Rich
×
×
  • 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.