Jump to content

ayok

Members
  • Posts

    340
  • Joined

  • Last visited

    Never

Posts posted by ayok

  1. Thank you phpknight,

     

    I've tried your advice to save the original folder first, and open it to resize it. But I don't know how to open and resize the saved files. Could you tell me how?

     

    Thanks,

    ayok

  2. Hi,

    I'm now trying to make an XML with PHP from mySQL database. I'd like to get an XML output like below:

    <?xml version="1.0" encoding="UTF-8"?>
    <menu>
                          <gallery name="Category1">
    	            <image source="pics/original/117.jpg" thumb="pics/117.jpg" title="first pic"/>
    	            <image source="pics/original/117.jpg" thumb="pics/117.jpg" title="second pic"/>
    
    	</gallery>
    	<gallery name="Category2">
    		<image source="pics/original/118.jpg" thumb="pics/118.jpg" title="third pic"/>
    		<image source="pics/original/121.jpg" thumb="pics/121.jpg" title="forth pic"/>
    		<image source="pics/original/122.jpg" thumb="pics/122.jpg" title="fifth pic"/>
    	</gallery>
    	<gallery name="Category3">
    		<image source="pics/original/187.jpg" thumb="pics/187.jpg" title="sixth pic"/>
    		<image source="pics/original/196.jpg" thumb="pics/196.jpg" title="seventh pic"/>
    		<image source="pics/original/197.jpg" thumb="pics/197.jpg" title="eight pic"/>
    		<image source="pics/original/203.jpg" thumb="pics/203.jpg" title="ninth pic"/>
    	</gallery>
    
    </menu>

     

    So far I've tried with the php code below:

    <?php
    
    header("Content-type: text/xml"); 
    
    $host = "localhost"; 
    $user = "root"; 
    $pass = ""; 
    $database = "gallery"; 
    
    $linkID = mysql_connect($host, $user, $pass) or die("Could not connect to host."); 
    mysql_select_db($database, $linkID) or die("Could not find database."); 
    
    $query = "SELECT * FROM pictures,category WHERE pictures.category=category.id";; 
    $resultID = mysql_query($query, $linkID) or die("Data not found."); 
    
    $xml_output .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; 
    $xml_output .= "<menu>\n"; 
    for($x = 0 ; $x < mysql_num_rows($resultID) ; $x++){ 
        $row = mysql_fetch_assoc($resultID);
        $xml_output .= "<gallery name=\"" .$row['name']."\">\n"; 
         
        $resultID2 = mysql_query($query, $linkID) or die("Data not found."); 
        for($x = 0 ; $x < mysql_num_rows($resultID2) ; $x++){
        	$row2 = mysql_fetch_assoc($resultID2); 
        	$xml_output .= "\t<image source=\"original/" .$row2['image']."\""; 
        	$xml_output .= "\tthumb=\"" .$row2['image']."\"";
        	$xml_output .= "\ttitle=\"" .$row2['title']."\"/>\n";
        }
        $xml_output .= "</gallery>\n"; 
    }
    
    $xml_output .= "</menu>\n"; 
    echo $xml_output;
    
    ?>

     

    But I only get this result:

     <?xml version="1.0" encoding="UTF-8" ?> 
    - <menu>
    - <gallery name="Category1">
      <image source="original/187.jpg" thumb="187.jpg" title="first pic" /> 
      <image source="original/121.jpg" thumb="121.jpg" title="second pic" /> 
      <image source="original/122.jpg" thumb="122.jpg" title="third pic" /> 
      <image source="original/150.jpg" thumb="150.jpg" title="forth pic" /> 
      <image source="original/203.jpg" thumb="203.jpg" title="fifth pic" /> 
      <image source="original/150.jpg" thumb="150.jpg" title="sixth pic" /> 
      <image source="original/118.jpg" thumb="118.jpg" title="seventh pic" /> 
      <image source="original/203.jpg" thumb="203.jpg" title="eight pic" /> 
      <image source="original/208.jpg" thumb="208.jpg" title="ninth pic" /> 
      </gallery>
      </menu>

     

    Could anybody help how can i get the result as I want?

     

    Thank you

    ayok

  3. Hi guys,

    I have this script to resize the image

    <?php
    function change_pic($pic_name)
    {
        header("Content-type:image/jpeg");
    
        $im_src = imagecreatefromjpeg($pic_name);
        $width_src = imagesx($im_src);
        $height_src = imagesy($im_src);
    
        $width_dst = 100;
        $height_dst = 100;
        $quality = 60;
    
        //resize process
        $im = imagecreatetruecolor($width_dst, $height_dst);
        imagecopyresampled($im, $im_src, 0, 0, 0, 0, $width_dst, $height_dst, $width_src,
            $height_src);
    
        imagejpeg($im, $pic_name, $quality);
        imagedestroy($im_src);
        imagedestroy($im);
    }
    
    if ($fupload_type = "image/pjpeg" || $fupload_type = "image/jpeg")
    {
        copy($fupload, "./$fupload_name");
        change_pic($fupload_name);
    }
    else
    {
        echo "File must be JPEG";
    }?>

     

    The codes resize the uploaded pic to 100X100 px from the original pic.

     

    However, I want to modify this script so I can resize into two size and put it in different folder. I can put the original pic with the original size in a folder, but how can I have two resized pic like, say, 100X100 and 300X300?

     

    Thank you,

     

    ayok

  4. Hi thanks guys,

     

    The problem is that I tried to combine two script to upload text data and image. The data should go to database, the image has to go to an image folder. Since I am a newbie, I don't know how to combine the outputs.

     

    I have this

    $input = mysql_query("INSERT INTO body(tooltip,woorden,words,image) 
    VALUES ('$tooltip','$woorden','$words','$fupload_name')");
    
    if ($input)
    {
        echo "Input Process Done!<BR>";
        echo "<a href=../add.php>Add again</a><br>";
        echo "<a href=../logout.php>Logout</a><BR>";
        echo "<a href=../admin.php>Check Products</a>";
    }

    for the text data.

     

    And the image handler

    if ($fupload_type = "image/pjpeg" || $fupload_type = "image/jpeg")
    {
        copy($fupload, "./$fupload_name");
        changeimage($fupload_name);
    }
    else
    {
        echo "File has to be JPEG";
    }

     

    Then when I'm messing around with the codes, I got header error or blank page, although the text and image are successfully uploaded. Does anybody have solution for this?

     

    Thanks,

    ayok

  5. Hi..

    I have this annoying error. It doesn't really impact the result, but this error annoys me.

    Cannot modify header information - headers already sent by (output started at /home/mywebcom/HTML/xmlgallery/images/input_product.php:34) in /home/mywebcom/HTML/xmlgallery/images/input_product.php on line 9

     

    This is my php in input_product.php

    <?php
    
    include "../dbconnect.php";
    $input = mysql_query("INSERT INTO body(tooltip,woorden,words,image) 
    VALUES ('$tooltip','$woorden','$words','$fupload_name')");
    
    function changeimage($nm_gambar)
    {
        header("Content-type:image/jpeg");
    
        ......
    
        imagejpeg($im, $nm_img, $quality);
        imagedestroy($im_src);
        imagedestroy($im);
    }
    
    if ($input)
    {
        echo "Input Process Done!<BR>";
        echo "<a href=../add.php>Add again</a><br>";
        echo "<a href=../logout.php>Logout</a><BR>";
        echo "<a href=../admin.php>Check Products</a>";
    }
    else
    {
        echo "Input process failed!";
    }
    ...........
    
    ?>

     

    The problem lays on line 9 "header("Content-type:image/jpeg");". But I don't know where to put that. Line 34 is "echo "Input Process Done!<BR>". Could anybody help me here?

     

    Thanks,

    ayok

  6. Hi,

    Another question.

    I want to have a page with categorized items, and also limit the divide the page into sub pages (with "previous 1 2 3 next" buttons), but I couldn't do it.

     

    I have this code:

    "SELECT products.*,category.name FROM products LEFT JOIN category on product.categorized=category.category_number LIMIT $offset,$limit WHERE category_number='$id'")

    LIMIT and WHERE doesn't work. But if I delete "LIMIT $offset,$limit", I have a long page.

     

    Anybody can help me to solve this?

     

    Thank you,

    ayok

  7. Hi,

    I have some pictures in database and I want to show it on my webpage. The problem is, I want to make those pictures are shown on a table with 3 or 5 columns before new rows.

     

    For example, I insert this code

    	
    <?php 
    while ($data = mysql_fetch_array($show){
    echo"<table>
    echo"<tr><td><img src='$url/thumbnails/$data[image]'></td></tr></table>";

    to show the pictures from database, the pictures will be shown vertically with only one columns. Could anybody tell me how to get some columns before new row? I hope you understand my question. I have no idea how to find the keywords for googling.

     

    thanks,

    ayok

  8. Hi,

    Now I'm trying to make a popup window with php. I've got this code:

    echo"<td><a href='$url/$data[image]' onclick=window.open('$url/$data[image]','popup','width=500,height=500,scrollbars=no,
    resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0') return false'>
    <img src='$url/thumbnails/$data[image]'></a></td>";

     

    The pop up window appears, but the image page is also opened on my browser. Could anybody tell me how to fix it?

     

    Thanks

    ayok

  9. Hi,

     

    I've installed apache2triad somedays ago. Now I want to learn about drawing with php which needs GD library support.

     

    Before that I test the server if there is GD library installed. So I use this code:

    if(!function_exists("gd_info"))

    But the result is no GD installed.

     

    I check the phpinfo, i think there is GD installed. I check php.ini, the phrase extension:php_gd.dll, it is already uncomment. So, I don't what else I should do.

     

    Could someone tell me how to solve this problem?

     

    Thank you,

    ayok

  10. Hey thanks,

    I put all in the same directory.

    My code: include "dbconnect.php"; and dbconnect.php is in the same folder. I have other pages which use include "dbconnect.php" and it works fine (like the codes from hostfreak above). I don't know why this time I've got no database is selected.

     

    I already tried include ("dbconnect.php"), but still doesn't work. How can I get the right path?

    I'm working in localhost. how can I define the path? .:C:\apache\htdocs... or http://localhost/directory/...?

     

    Thank you,

    ayok

  11. What's wrong with include "something.php"? sometimes it works, sometimes i got this error.

     

    I use it mostly to include the database connection. However, I often got this error: failed to open stream: No such file or directory . Do I need to use different code?

     

    Thanks,

    ayok

  12. Strange..

    I changed the AND's into OR's as you adviced, but it didn't affect, so I changed back to AND's. Now I've got different result.

     

    It's my form.php, btw:

    <FORM><tr><td>Content:</td> <td><INPUT NAME=Content type=text size=10 maxlength="2"></td></tr>
    <tr><td>Price:</td> <td>EUR <input NAME=Price type=text size=10 maxlength="10">
    (please use .00 as decimal)</td></tr>
    <tr><td>Upload Image:</td> <td>
    <input type=file name=fupload></td></tr></table>
    <INPUT TYPE=SUBMIT VALUE=Go>
    </FORM>

  13. Hi,

    Now I'm trying to create a form to a database which contain image. So besides submitting some data, it also upload an image to a folder. But everytime I upload the image, the script acknowledge it as a non image file. Here are part my codes:

     

    upload_form.php:

    <?php
    <tr><td>Upload Image:</td> <td>
    <input type=file name=fupload></td></tr></table>
    <INPUT TYPE=SUBMIT VALUE=Go>
    </FORM>

     

    input image.php

    <?php
    $direktori_file = "products/pics/$fupload_name";
    if($fupload_type != "image/gif" AND $fupload_type != "image/jpeg" AND$fupload_type != "image/pjpeg" AND $fupload_type != "image/png"){
    	echo "The type of file <b>$fupload_name</b> is $fupload_type<br>";
    	echo "The file must be image file<br>";
    	echo "<a href=add.php>Upload again!</a>";
    }
    elseif (!move_uploaded_file($fupload, "$direktori_file")){
    	echo "The upload is failed!";
    }

    everytime I submit the pic, i've got this kind of message:

    The type of file pic01.gif is image/gif

    The file must be image file

    Upload again!

     

    Why the script doesn't recognize my gif/jpeg files?

     

    FYI, I still test this on localhost.

     

    thanks,

    ayok

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