Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Posts posted by GingerRobot

  1. There was one mistake in there...the for loop should be initialized with x as 0, not 1. The following generates 4 google logos in one image, using the code i provided:

     

    <?php
    
    $im = imagecreatefromgif("http://www.google.co.uk/intl/en_uk/images/logo.gif");
    $barcodewidth = imagesx($im);
    $barcodeheight = imagesy($im);
    //after creating the barcode
    $barcodesRequired = 4;
    $im2 = imageCreate($barcodewidth,$barcodeheight*$barcodesRequired);
    for($x = 0; $x< $barcodesRequired; $x ++){
        imagecopy($im2,$im,0,$barcodeheight*$x,0,0,$barcodewidth,$barcodeheight);
    }
    
    Header( "Content-type:  image/gif");
    ImageGif($im2);
    ImageDestroy($im);
    ImageDestroy($im2);
    

     

    So it seems to be working for me. Perhaps you could post the actual code you're using now?

  2. Using the first option, the imagegif function takes an optional second parameter: a filename to save the image to. So, you could do this for example:

     

    ImageGif($im,"barcode.gif");
    $barcodesRequired = 3;
    $output = str_repeat("<img src='barcode.gif' /><br/>",$barcodesRequired);
    echo $output;
    

     

    If you take this approach, then you'll have to remove this line:

     

    Header( "Content-type:  image/gif");
    

     

    As the content you're serving is no longer a gif image, it's HTML.

     

    It might be that you specifically wanted to output a single image with the barcode appearing multiple times though. In which case, you'd want the second option:

     

    //after creating the barcode
    $barcodesRequired = 4;
    $im2 = imageCreate($barcodewidth,$barcodeheight*$barcodesRequired);
    for($x = 1; $x< $barcodesRequired; $x ++){
        imagecopy($im2,$im,0,$barcodeheight*$x,0,0,$barcodewidth,$barcodeheight);
    }
    
    Header( "Content-type:  image/gif");
    ImageGif($im2);
    ImageDestroy($im);
    ImageDestroy($im2);
    return;
    

     

    If you're easy either way, the first option is probably better...it'll use less resources.

  3. By "it wont echo anything" do you mean the page is entirely blank? If so, do you have error reporting and display errors turned on? Are you sure you're also not being redirected and it is in fact gang_listing.php that is blank?

  4. Hi mate. Yea I read that after I posted, moved it after connection string however still no luck

     

    Did you also do this?:

     

    Remove the . after '$g_name'.

     

    You should have:

     

    $sql1="INSERT INTO form_data (your_team, opp_team, date1, time1, g_name, result, writeup) VALUES
    ('$your_team','$opp_team','$date1','$time1', '$g_name', '$result', '$writeup')
    ";
    

  5. You do love regular expressions don't you CV? Though I thought they wanted to remove the heading tags.

     

    <?php
    $mytext = "<h1>Title One</h1><br>This is text one<br><br><h1>Title Two</h1><br>This is text two<br><br><h1>Title Three</h1><br>This is text three";
    $titles = explode("<br>",$mytext);
    
    for($x=0;$x<count($titles);$x+=3){
        echo "<a href=somepage.php?id=" . (($x/3)+1) . ">" . strip_tags($titles[$x]) . "</a><br>\n";
    }
    ?>
    

  6. Well that's roughly what i posted here:

     

    SELECT * FROM yourtable WHERE colour=(SELECT colour FROM `incoming` WHERE ...)
    

     

    Fitting it in with what you have:

     

    $id = (int) $_GET['id']; 
    $sql = "SELECT * FROM yourtable WHERE colors=(SELECT colors FROM `incoming` WHERE id=$id)";
    $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR);
    

  7. I'd start by adding some error checking:

     

    mysql_query($sql,$con) or trigger_error("Error in query: $sql <br>Error was:" . mysql_error(),E_USER_ERROR);
    mysql_query($sql1,$con) or trigger_error("Error in query: $sql1 <br>Error was:" . mysql_error(),E_USER_ERROR);
    

  8. A quick google search showed up that Joola uses something similar to prevent access to files which are included by others. So yes, if you are using this in the same way and defining that constant on the pages which include these files, then it will work.

     

    However, i'd prefer to place files which i don't want to grant access to outside of the web root.

  9. I don't think i understand. I assume you didn't mean something like the following:

     

    $color = 'green';
    $sql = "SELECT * FROM yourtable WHERE color='$color'";
    $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR);
    //display the results
    

     

    Or did you mean that the colour in question is selected from the colour of another row given by some criteria? Something like a "show similar articles (or colours)"?

     

    In which case, you can either perform one query to extract the colour or do it in one:

     

    SELECT * FROM yourtable WHERE colour=(SELECT colour FROM `incoming` WHERE ...)
    

  10. First time i've seen the output buffering used like this in a while...

     

    Anyway, the problem is a tiny one. You've a rogue quote mark on this line:

     

    <a href=<?php echo($baseuri."?tabindex=".$curindex);?>">
    

     

    If you'd echoed out $_GET['tabindex'] or taken a look at the page your browser was going to, you'd probably have spotted that '...?tabindex=1" ' isn't quite right. Try:

     

    <a href='<?php echo($baseuri."?tabindex=".$curindex);?>'>
    

     

     

  11. Not seen that one before, but according to the manual:

     

     

    Errors/Exceptions

     

    Every call to a date/time function will generate a E_NOTICE if the time zone is not valid, and/or a E_STRICT or E_WARNING message if using the system settings or the TZ environment variable. See also date_default_timezone_set()

     

    So i'm assuming there's no timezone set in your PHP setup.

     

    By the by, you don't need both of those functions to do what you want. You either want mk_time() with no parameters, date("U") or time().

  12. If i understand you correctly, an easy work-around would be to use the LIKE operator rather than the = operator in your query. For example:

     

    if(showingAllGenres){
         $genres = '%';
    }else{
         $genres = $_POST['genre'];
    }
    //Similarly for the group
    $sql .= "WHERE groep.id LIKE '$groups' AND genre.id = '$genres'";
    

     

    I hope you understand what I mean because my english isn't that great

     

    Unfortunately (or, perhaps from your perspective, fortunately) your English seems better than most. Also, it's nice to see a new member trying to help other members as well as asking their own question  :thumb-up:

     

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