Jump to content

Jessica

Staff Alumni
  • Posts

    8,968
  • Joined

  • Last visited

  • Days Won

    41

Posts posted by Jessica

  1. Right now you are checking if the entire string $contents is equal to the string $Mrx. You want to find if $Mrx is IN the string $contents and how many times, right?

    [code]$counter = substr_count($contents, $Mrx);[/code]
    That gives you a place to start. Go from there ;)
  2. It tells you the problem
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
    What does this mean? Well, your $result variable is not a valid resource.
    I think your connection: $db = database_connect(); is failing.

    Also, there's a forum for third party stuff :http://www.phpfreaks.com/forums/index.php/board,34.0.html

    :)
  3. Why do you want to put echo in a variable? I think you mean you want to echo the variable.
    [code]
    $var = "<strong>".($row1["sellrenttext"]).", ".($row2["typeofobjecttext"]).", ".($row3["city"]).", ".($row4["countrytext"]).", ".($row5["price"], 0, ',', ' ')." ".($row6["currencycode"])."</strong><BR><BR>".($row7["objectdes"]);

    echo $var;
    [/code]
  4. Have you tried adding parenthesis so it looks like this

    [code]$counting = "SELECT COUNT(*) FROM listings WHERE (title LIKE '%$search%' OR  description LIKE '%$search%') AND cat='$ncat' ORDER BY id ASC";
    $showing = "SELECT * FROM listings WHERE (title LIKE '%$search%' OR  description LIKE '%$search%') AND cat='$ncat'  LIMIT $start, $display";[/code]

    It should be prioritized that way automatically, but just in case, try this.
  5. I want to allow only letters, numbers, and the . and _ character - nothing else, no spaces, no $!, etc. This is what I have.

    [code]if(preg_match("/[^A-Za-z0-9_\.]+$/", $this->username)){
        $msg = "Please use only letters, numbers, and the following characters: _ and .";
    }else{
        $msg = "Username OK!";
    }[/code]

    It works great when a user enters !@#$% etc, but when a user enters spaces in between two words, IE: john doe, it says Username OK. If they enter a space and another unallowed character it gives the error, but not if it's just two words with space. What is wrong with my regexp?
  6. If the user enters the string of where the file is on their computer:
    C:\Documents and Settings\user\My Documents\image.jpg

    How can I upload it to the server without using a form like I would normally?

    What I am trying to achieve is an ajax image upload form, like the one on TheDailyPlate.com
    (see: http://www.thedailyplate.com/food-nutrition/food/generic/mashed-potatoes
    click on Contribute a photo of this item! - Don't actually do it, but that is what I mean. It uploads the image without refreshing the page.)

    Thanks!
  7. [quote author=fenway link=topic=103135.msg410746#msg410746 date=1154881440]
    Why does the actual data have escape characters in it?
    [/quote]

    And, I have no idea why it's overescaped, when I put it in the database I used "mysql_real_escape_string(strip_tags($_POST['item']));" to get the string and put it in.

    In that case, 'item' was The Pirate's Code.

    Now I've gone into the database and changed the entry to "The Pirate's Code" unescaped, and the query
    SELECT name, id FROM all_items WHERE name LIKE '%Pirate\\\'s%'

    Finds it.

    WTF is going on here? Something is wrong with my database settings.
  8. The actual record in the database is The Pirate\'s Code, and that's what I need to find. :(

    Here's what happens. The user enters pirate's in a search form.

    Then:

    $item = mysql_real_escape_string(strip_tags($_POST['search']));
    $shop_info = "SELECT name, id FROM all_items WHERE name LIKE '%$item%'";

    At that point $shop_info = "SELECT name, id FROM all_items WHERE name LIKE '%Pirate\\\'s%'"
    Which if I understand the escaping, it should find pirate\'s.

    And, I have no idea why it's overescaped, when I put it in the database I used "mysql_real_escape_string(strip_tags($_POST['search']));" to get the string and put it in.

    ARGH
  9. SELECT name, id FROM all_items WHERE name LIKE '%pirate\\\'s%'
    MySQL returned an empty result set (i.e. zero rows). (Query took 0.0030 sec)

    SELECT name, id FROM all_items WHERE name LIKE '%pirate\'s%'
    MySQL returned an empty result set (i.e. zero rows). (Query took 0.0030 sec)

    SELECT name, id FROM all_items WHERE name LIKE '%pirate%'
    The Pirate\'s Code  30
    Famous Pirates 32

    I need to be able to search for the entry "The Pirate\'s Code" using "pirate\'s" or "pirate\\\'s". Why do the first two not work?
  10. I am performing this query:
    $update_item = "UPDATE stall_transactions SET cleared = 1 WHERE stall_id = $stall_id LIMIT 50";

    I want it to update the 50 most recent by either sold (datetime) or transaction_id (primary key).

    How can I ensure it does the 50 most recent?

    Thanks!
    ps: the new forum design is awesome!
  11. Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 4252 bytes) in /home/www/sites/lifefiles.com/admin/uploadphotos.php on line 41

    [code]function resize_image($type, $file, $max_width, $max_height){
        $full_url = $file;
        
        $imageinfo = getimagesize($file);
        $src_width = $imageinfo[0];
        $src_height = $imageinfo[1];
        
        if($src_width > $max_width){
            $divide = $imageinfo[0] / $max_width;
        }
        if($src_height > $max_height){
            $divide = $imageinfo[1] / $max_height;
        }
        
        $dest_width = $src_width / $divide;
        $dest_height = $src_height / $divide;
        
        if($type == 2){
            $src_img = imagecreatefromjpeg($file); (<-- Line 41)
        }else{
            $src_img = imagecreatefromgif($file);
        }
        $dst_img = imagecreatetruecolor($dest_width,$dest_height);
        imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width, $dest_height, $src_width, $src_height);
        if($type == 2){
            imagejpeg($dst_img,$full_url);
        }else{
            imagegif($dst_img,$full_url);
        }
        imagedestroy($src_img);
    }
    [/code]

    The file is a very large one, and I need to be able to do the resize. How do I make it use more memory?
  12. [!--quoteo(post=380786:date=Jun 6 2006, 04:26 PM:name=nogray)--][div class=\'quotetop\']QUOTE(nogray @ Jun 6 2006, 04:26 PM) [snapback]380786[/snapback][/div][div class=\'quotemain\'][!--quotec--]
    make sure the $cards is declared as an array somewhere in your script. I am not sure if you have it in the 'cards.php' file or not. But if you don't have it there, and it's not a global variable that is set as an array, you'll need to add

    $cards = array();

    before you use it in the array_search() function
    [/quote]

    Yeah it is

    [code]$cards         = array();
    $cards[1]     = '2H';
    $cards[2]     = '3H';
    $cards[3]     = '4H';
    (snip)[/code]

    is cards.php. I had to put it in the file outside of the function and do global $cards;

    Thanks!
×
×
  • 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.