Jump to content

EchoFool

Members
  • Posts

    1,074
  • Joined

  • Last visited

Posts posted by EchoFool

  1. Hey i have a function which grabs info and sends it back in an array with return().

     

    But for some reason the script that recieves the data receives partial information here is an example:

     

     

     

     

     

     

     

    <?php
    function arrayget($pid,$aid){
    $s = $db->getRow("SELECT field1,field2,field3,field4 FROM table1 t1
    
                   INNER JOIN table2 t2 ON
                   t1.id=t2.pid
                   WHERE t2.pid='$pid' AND t2.aid='$aid'");   
    print_r($s); //array displays correctly at this point
       foreach($s as $key=>$ss){  
       $var = 1;
        return array($ss['field1'],$ss['field2'],$ss['field3'],$ss['field4']);    
       }
    }
    $pid = 28;
    $aid = 1;
    print_r(arrayget($pid,$aid)); //displays incorrect values see below print out examples in bold
    ?>
    

     

    The first print array shows:

    Array ( [field1] => 5 [field2] => 2 [field3] => 5000 [field4] => 5000)

     

    Second print shows:

    Array ( [field1] => 0 [field2] => 0 [field3] => 0 [field4] => 0)

     

    When i physically put $ss['field3'] = 5000; in the for loop the result became:

    Array ( [field1] => 5 [field2] => 5 [field3] => 5 [field4] => 5)

     

    I don't understand what i did wrong =/

  2. okay well i store numbers in database like 1,2,3,4,5 in a single field.

     

    then i explode the string $var =  explode(',',$string);

     

    so now i got the array as $var then i need to find all rows with field "test" containing a number that is found in array $var.

     

    in_array cannot be done in a query from what im aware of?

  3. Hey,

     

    I'm trying to create a search system where by fields have a number in them but my php carries an array of numbers.

     

    So lets say a field holds the value 3.

     

    And my php array is  1,3,5,8,9

     

    How can i simply query to check if the number in the field is found in the php array ?

     

  4. It is normalized but its weather i should split some of my tables up to smaller tables.

     

    if, as you said... it's normalized... then are you trying to split tables due to the number of records? or you really are not sure if you data structure is correct (and normalized)?... please clarify

    I think the question is about whether to split a (normalized) table with a couple dozen columns into a couple smaller (slightly less normalized) tables. Like if you had a table with columns A-Z, is there any worth to splitting it into a table1 with A-M and a table2 with N-Z (with a 1-to-1 relationship between them).

     

    exactly. So to sum up again is a table with large number of fields (forget number of rows) better over multiple tables with less fields... which im not sure why everyone is complicating this with normalization when it has no relationship what ever to it.

  5. Which is better in terms of efficientcy for the server load etc

     

    More tables with less fields and then using inner joins to connect them up in scripts.

    Or less tables with more fields of the data only needing a SELECT query to get info?

     

  6. Full code is :

     

     

                    
    $Get = mysql_query("SELECT Image FROM userimages WHERE UserID='$UserID'")
                        Or die(mysql_error());
                    If(mysql_num_rows($Get)>0){
                    $row = mysql_fetch_assoc($Get);
                    $Image = $row['Image'];
                    $picturearray = getimagesize($Image); 
    }
    

     

    In the database it says:

     

    It doesn't happen all the time - just some times it does which is odd.

  7. Hey

     

    My php function keeps returning an error on a valid image! I get this error:

     

    could not make seekable

    I use this line to get the image size but i get the above error for it:

    $picturearray = getimagesize($Image); 

     

    Url being tested :

    http://www.fileden.com/files/2010/12/22/3043070/Sidroc.jpg

     

    The url is correct and the image does exist - does any one know what can cause this issue ?

  8. also, you can't just echo $image.  It's an image source object.  If you want to output it to browser, you have to do it like this:

     

    header('Content-type: ' .image_type_to_mime_type($type));
    imagejpeg($tn); // for jpg files, there's other image type equivalents to this
    

     

     

    would image.$type($tn); work or is the functions not named equal to the file type? With the header line its always going to error if its the middle of script and i can't put the header else where it won't know the $type without the variable which is half way through the script so theres no logic to it.

  9. I tried both methods - but get this in both circumstances :

     

    Before the first part i get:

     

     

    Warning:  Cannot modify header information - headers already sent by (output started at main.php:85) in functions.php on line 548

     

     

    Obviously its unreadable :P

     

    http://www.paste.to/ODA4Mw==  im assuming this is raw image data?

     

    <?php
    function makethumb($fn,$shrink,$rt=false)
       {
          list($ow, $oh, $type, $attr) = getimagesize($fn);
          if ($oh > $ow) {
             $th = $shrink;
             $tw = ($th / $oh) * $ow;
          }
          if ($ow >= $oh) {
             $tw = $shrink;
             $th = ($tw / $ow) * $oh;
          }
          $w = round($tw);
          $h = round($th);
          $tn = imagecreatetruecolor($w, $h);
          $img = imagecreatefromjpeg($fn);
          imagecopyresampled($tn, $img, 0, 0, 0, 0, $w, $h, $ow, $oh);
          if ($rt) {
             return (array($tn, $type, $w, $h));
          } else {
                     header('Content-type: ' .image_type_to_mime_type($type));
             imagejpeg($tn);
          }
       }
    
    $Url = 'http://www.google.co.uk/images/logos/ps_logo2.png';  //test image off the net
    $image = makethumb($Url,260,false);
    echo $image;
    ?>
    

  10. Function is stored some where then i have:

    <?php 
    $Url = '[url=http://www.test.com/image.jpg%27;]www.test.com/image.jpg';[/url]
    echo makethumb($Url,260); 
    ?>

     

    I set the value to FALSE also in the function. Is that where im going wrong?

  11. Is there such a function which allows you pass the image url into a function, it then resizes the image keeping its aspect ratio so that people don't look fat or thin when the picture is in thumbnail form ?

     

    Can't see to do it in standard CSS so im wondering if php can some how do it =/ ?

  12. How do you place isometric shaped images together on html - i've seen it done but because images are sqaure /rectangular in shape it always leaves gaps which is driving me insane as i can't work out how to solve it.

     

    Any one ever managed to work out how they do it ?

  13. Hey i have an onclick call in a href to call an ajax function but it doesn't work for some reason.

     

     

    I use jquery library to use my ajax.

     

    The function:

    function dmg()
    {
         $.ajax({
              type: "POST",
              url: "cm.php",
              async: false,
              data: "id="+$("#del"),
    	  
          });
    	$("#del").val("");
       return false;
    }

    The link:

    <a href="?del=<?=$row['id']?>" onclick="dmg();">[x]</a>

    Have i got this incorrect with the use of GETs?

  14. Hey,

     

    I need help with my BBCode function... im trying to allow it to embed you tube videos but im kinda confused as to how i can do it when i need the link to be in the bbcode html ouput twice with my current method.

     

    Here is my function:

    http://www.paste.to/MzE3Mg==

     

    I could not post the script as it was messing up with this site's BBcode.

     

    Any one can help me please ?

    Thankss

  15. Thanks for the suggestion MadTechie, sadly it still hangs. And my entire session is for ever hanging on my domain so i have clear cookies to get it back to normal (which makes me wonder if its session related?)

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