Jump to content

sprinkles

Members
  • Posts

    17
  • Joined

  • Last visited

    Never

Posts posted by sprinkles

  1. Hi,

    I'm developing a mobile site that needs to be able to use either XHTML or WML, depending on the device capabilities.

    I'd like to keep the same controllers and models, but am unsure of the best way to achieve switching the output format.

    The way that seems logical would be to switch views. I can't see how to do this, though, and I'm not certain it's the best practice.

    The other option I can think of would be to have logic in the view to decide which to output, but that seems very messy.

    Any advice is appreciated, thanks!

  2. I don't have time to look through your code at the moment, but %22 is the url entity for a double quote (").

    See if a double quote is sneaking into your url somewhere. you can also use url_decode to change it back to a quote.

  3. I'm building a script with the last.fm datafeeds.

     

    When a incorrect username is given to the script, the last fm site throws a 404, and results in this PHP error:

     

    Warning: simplexml_load_file(http://ws.audioscrobbler.com/1.0/user/RichardJohn/tasteometer.xml?with=) [function.simplexml-load-file]: failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found in /home/richardm/public_html/lastfmcompatibility.php on line 12
    
    Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "http://ws.audioscrobbler.com/1.0/user/RichardJohn/tasteometer.xml?with=" in /home/richardm/public_html/lastfmcompatibility.php on line 12
    There was a problem loading the data feed.

     

    Is there a way to catch this error and just present a friendly error?

  4. I'm creating a site for someone else that needs to use Paypal.
    Basically, the script submits the entry to the database with a paid value of 0 (This I can do myself), then the person pays with paypal, and Paypal IPN should ping a script which changes the paid value to 1.

    Does anyone know any tutorial/script that can do this, as it's really frustrating, there seems to be no decent documentation anywhere! It also complicates things that it's not my Paypal account.

    Best Wishes,
    Richard John
  5. I have a form that's submitting all of the variables by post.
    I'm using this code to remove htmk/javascript and tocheck that they're not empty:

    $poster = $_POST['poster'];
    $cityid = $_POST['cityid'];
    $catid = $_POST['catid'];
    $subcatid = $_POST['subcatid'];
    $showphone = $_POST['showphone'];

    if($showphone=="on") {
    $showphone = 1;
    } else {
    $showphone = 0;
    }

    $title = $_POST['catid'];
    $title = strip_tags($title);
    $title = RemoveXSS($title);

    $body = $_POST['body'];
    $body = strip_tags($body);
    $body = RemoveXSS($body);

    $location = $_POST['location'];
    $location = strip_tags($location);
    $location = RemoveXSS($location);

    $price = $_POST['price'];
    $price = strip_tags($price);
    $price = RemoveXSS($price);

    $phone = $_POST['phone'];
    $phone = strip_tags($phone);
    $phone = RemoveXSS($phone);

    $email = $_POST['email'];
    $email = strip_tags($email);
    $email = RemoveXSS($email);

    if($cityid=="") {
    header("location: post.php?err=cityid");
    }
    if($catid=="") {
    header("location: post.php?err=catid");
    }
    if($title=="") {
    header("location: post.php?err=title");
    }
    if($body=="") {
    header("location: post.php?err=body");
    }
    if($location=="") {
    header("location: post.php?err=location");
    }
    if($phone=="") {
    header("location: post.php?err=phone");
    }
    if($email=="") {
    header("location: post.php?err=email");
    }

    Every time the script is run, it returns to the form with the blank email error. I've triple-checked the form field's name. EVen if I leave all of the other fields blank, it still goes back on the email. Anyone got any ideas?
  6. I've been using a script that wasn't writtenn by me for a while to create thumbnails of logos on the fly.
    This is now taking too long with 30+ logos on a page, so i've decided to implement a cache.
    When I execute this script, it creates a thumbnail of the image, displays it in the browser, but does not save it. This means the cache does not work at all. I've also tried using fopen and fwrite, but I can't get the image to save.
    The images folder is CHMOD 777.

    [code=php:0]
    <?php

    header("Content-Type: image/jpeg");

    $num = $_GET['num'];

    $image_path = "http://www.radioo.net/images/$num.jpg";

    if (file_exists($image_path)) {

    readfile($image_path);
    }else{

      if (isset($_GET['img'])) {

            // Generate a thumbnail of the image
            if (!isset($_GET['iw'])) { $iw = 50; } else { $iw = $_GET['iw']; }
            $iname = $_GET['img'];
            if (ereg('png$',$_GET['img'])) {    $i = imagecreatefrompng($iname); }
            if (ereg('jpg$',$_GET['img'])) {    $i =
    imagecreatefromjpeg($iname); }
            if (ereg('gif$',$_GET['img'])) {    $i = imagecreatefromgif($iname); }
            if (imageSX($i) <= $iw) {
                imagejpeg($i);
            } else {
                $i2 =
    imagecreatetruecolor($iw,($iw*(imagesy($i)/imagesx($i)))+1);

    imagecopyresampled($i2,$i,0,0,0,0,$iw,$iw*(imagesy($i)/imagesx($i))+1,imagesx($i),imagesy($i));


              imagejpeg($i2);
              imagejpeg($i2,$image_path);
           

    ImageDestroy($i2);

            }
            exit;
        }


    }

    ?>
    [/code]

    Any help appreciated, thanks.
  7. I have a problem with sessions.
    All the links on my site are prefixed with www.
    I've just implemented a registration system, but I'm having a problem with sessions.
    If the user visits the site with the www. prefix, the sessions work fine and the user stays logged in, however if the user omits the www. from the address, the user gets logged out when clicking a link.

    How can I either solve this, or forward all users to www.?
  8. Using this code (so I can see the array) gives me the error:
    Parse error: parse error, unexpected T_ARRAY, expecting T_STRING or T_VARIABLE or '$' in /home/radioone/public_html/tagsave.php on line 7

    [code]

    $tags_arr = explode(",",$tags);


    $tags_count = new array();

    foreach ($tags_arr as $tag){
         if (array_key_exists($tag, $tags_count)){
              $tags_count[$tag]++;
         }
         else {
              $tags_count[$tag] = 1;
         }
    }

    print_r(array_keys($tags_count));[/code]

    The variable "tags" contains all of the tags seperated by commas.
  9. If what you're looking to do is re-direct based on parameters (such as index.php?location=forums redirects to forums.php) then this should do it:

    <?

    $location = $_GET['location'];

    if($location=="PAGENAME") {
    header("location: pagename.php");
    }
    else if($location=="OTHERPAGENAME") {
    header("location: otherpagename.php");
    }

    etc.
  10. Hello,
    I need to tag clouds for a site I am working on, but I can't quite get my head around it!

    I've found a code snippet that distribues the font sizes, but that does not include how to count the tags in the first place to get it to work! (the snippet is this one [a href=\"http://www.hawkee.com/snippet.php?snippet_id=1485)\" target=\"_blank\"]http://www.hawkee.com/snippet.php?snippet_id=1485)[/a]

    In my database I have the tags in a field seperated by spaces for each record (I know this was a bad way of doing it, but it can't be changed now). I have no problem taking all the tags from the database, and putting them into an array, but after this, I can't work out how to count the tags and turn it into a tag cloud!

    So I have an array full of tags, but I can't work out how to do anythign with it!

    Any help/ideas appreicated!

    Richard John
×
×
  • 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.