Jump to content

ayok

Members
  • Posts

    340
  • Joined

  • Last visited

    Never

Posts posted by ayok

  1. Hi Barand,

     

    No.. with $_GET, the table is updated (except the image -> becomes blank), with $_POST nothing's happened.

    What doesn't work is the image isnot uploaded. And I have "enctype='multipart/form-data'" in the form tag. perhaps I need to change $_file?

     

    Thanks,

    ayok

  2. Hi,

    I have scripts that are used to update datas from database. So it shows the datas on the browser, change, and update it. But I have problem with updating the image.

     

    Here is my update.php:

    <?php
    $fupload = $_FILES['fupload']['tmp_name'];
    $fupload_name = $_FILES['fupload']['name'];
    $category = $_GET['category'];
    $title = $_GET['title'];
    $descript = $_GET['descript'];
    $price = $_GET['price'];
    $id = $_GET['id'];
    include "../../connection/db.php";
    
    $input=mysql_query("UPDATE products SET title='$title', category='$category', descript='$descript', price='$price', image='$fupload_name' WHERE prod_id='$id'") or die(mysql_error());
    
    $direktori_file = "../../images/products/original/$fupload_name";
    
    if (!move_uploaded_file($fupload, "$direktori_file"))
    {
        echo "Upload failed!<br>";
        echo "<a href=add_pic.php>Upload again!</a><br>";
    }
    
    elseif ($input)
    {
        echo "input data success!<BR>";
        echo "<a href=add_pic.php>Add again</a><br>";
        echo "<a href=../logout.php>Logout</a><BR>";
        echo "<a href=index.php>Cek Products</a><BR>";
    }
    else
    {
        echo "Input process failed!";
    }
    .........
    ?>

     

    With this script, I can update the data's, except the image. Is there anyway i can update the image?

     

    Thank you.

    ayok

  3. i tried the hello world and it displays blank!! it is seriously driving me nuts, no sorts of white text, just plain blank!

     

    First, take something that makes you relax. A cup of tea or a joint. I had a same experince. ;)

     

    Then, you need to know what is required to see your test.php on your browser. You can download WAMP to set up your computer ready for php. I use Apache2Triad. If you work on webserver, see if it's support php. If you really have started 3 days ago, then you need to prepare some basic stuff.

     

    Good luck

     

    ayok

  4. Hi,

     

    I have a problem working with register global = Off. I used to set it "on" when I worked on my scripts in my local server. However, i heard that it's not recommended. So now I add some $_GET, $_POST, etc. Mostly I can do, but now I have a problem with uploading script. Especially, on admin pages.

     

    I upload the image with a simple script:

    <?php
    include "../../connection/db.php";
    echo "<FORM enctype=MULTIPART/FORM-DATA METHOD=POST ACTION=input_pic.php>";
    echo "Upload picture:<input type=file name=[u]fupload[/u]> ";
    echo "<INPUT TYPE=SUBMIT VALUE=add>";
    }?>

    With register global = On, I can just write the input_pic.php like this:

    <?php
    include "../../connection/db.php";
    $input=mysql_query("INSERT INTO gallery(image) VALUES('$fupload_name')") or die(mysql_error());
    $direktori_file = "../../gallery/images/original/$fupload_name";
    if ($fupload_type != "image/pjpeg" AND 
    $fupload_type != "image/jpeg")
    {
        echo "Type file <b>$fupload_name</b> is $fupload_type<br>";
        echo "Insert image is failed<br>";
    }
    elseif (!move_uploaded_file($fupload, "$direktori_file"))
    {
        echo "Upload process failed!<br>";
        echo "<a href=add_pic.php>Upload again</a><br>";
    }

    The name fupload can be $fupload, $fupload_name, or $fupload_type.

     

    However, with register global = off, the script doesn't work. I've tried to insert

    $fupload=$_GET[fupload]

    , but it doesn't work either.

     

    Could anybody help me out here?

     

    Thank you,

    ayok

  5. Thanks for the reply, guys.

    The script is ok. It works properly. The picture shows up everytime I clicked on one of the thumbnail.

     

    My problem is, everytime I open the gallery, there is no displayed picture (because I haven't click on a thumbnail). The default image is blank. What I want to do is to display the last picture for the default (when I haven't clicked on any thumbnail). I hope it's clear.

     

    Thank you,

    ayok

  6. Hi, I need help for my simple photo gallery.

     

    I have 3 php file for my photo gallery. In index.php I use 2 iframes, one for thumbs.php (thumbnails) and one is for displaying the bigger picture (image.php). The picture is displayed when we clicked on one of the thumbnail.

     

    The problem is when I open my photo gallery, the default picture on iframe image (image.php) is blank. This is my image.php:

    <?php
    include "../connection/db.php";
    
    $result = mysql_query("SELECT * FROM gallery WHERE pic_id='$id'") or DIE(mysql_error());
    echo "<TABLE bgcolor=#EBC0A0 border=0 cellpadding=5 cellspacing=5 align=center>";
    while ($data=mysql_fetch_array($result))
    {
    echo "<TR>";
    echo "<td align='right'>$data[descript]</td></tr>";
    echo "<tr><TD><img src='images/$data[image]'></a></TD></tr>";
    }
    echo "</table>";
    ?>

    I know that I need to make an if statement, but after several tries, I gave up. Could someone help me out here? Any help will be appriciated. ;)

     

    Thank you,

    ayok

  7. Thank you for the reply, guys.

    I've tried to put those POST codes, but I got the same result which go back to the login page.

     

    I've tried to add this:

    <?php
    session_start();
    $namauser = $_GET['nameuser'];<--
    $passuser = $_GET['passuser'];<--
    if(!empty($nameuser) AND !empty ($passuser))
    { do things }else{
    echo "You have to login before adding new items<BR>";
    echo "<a href=form_login.php>Login</a>";
    }

    on index.php.

    But still.. doesn't work.

  8. Hi, got another problem  ;D

     

    I've created simple login scripts for my webpage, but I cannot use it on my webserver.

    Here is the codes for check_login.php:

    <?php
    include "connect_db.php";
    $login=mysql_query("SELECT * FROM users WHERE username= '$username' AND password='$password'") or die (mysql_error());
    $data=mysql_fetch_array($login);
    
    if($data[username]==$username AND $data[password]==$password)
    {
    session_start();
    session_register("nameuser");
    session_register("passuser");
    $nameuser=$data[username];
    $passuser=$data[password];
    header("location:index.php");
    }
    else
    {
    echo "Failed! you give wrong username and password<BR>";
    echo "<a href=form_login.php>try again</a>";
    }
    
    ?>

     

    And ini every page, there are codes:

    <?php
    session_start();
    if(!empty($nameuser) AND !empty ($passuser))
    { do things }else{
    echo "You have to login before adding new items<BR>";
    echo "<a href=form_login.php>Login</a>";
    }

    The scripts worked on my local server but not on web server. From the information I've got, it doesn't work because use the register_globals.

     

    Would anybody help me how I solve this?

     

    Thank you,

    ayok

  9. Hi,

    I've got a different result on my local server and web server.???

     

    I created this page. On this page, you can find some company projects which are taken from mysql database. But I cannot get the data when I clicked on one of the project. No data is selected in the next page. However, the script is working properly if I tested it on my localhost.

     

    Here is the php script on index.php

    <?php
    include "../../dbconnect/koneksi_db.php";
    $result=mysql_query("SELECT * FROM project");
    while ($data=mysql_fetch_array($result))
    {
    echo "<a href=detail.php?id=$data[proj_no]>$data[title] - $data[company]</A><BR>";
    }

     

    From this index page, we can click on one of the links to the project detail which goes to detail.php.

     

    <?php
    
    include "../../dbconnect/koneksi_db.php";
    $result = mysql_query("SELECT * FROM project WHERE proj_no='$id'") or DIE(mysql_error());
    $data = mysql_fetch_array($result);
    $body_project = nl2br($data[body]);
    
    echo "<h1 align='center'>$data[title]</h1>";
    echo "Begin: $data[year]<br>Status: $data[status]<br>Bedrijf: $data[company]<br>";
    echo "<p>$body_project</p>";
    echo "<a href='file/$data[file]'>dossier downloaden<br>";
    echo "<a href='index.php'>terug naar projecten</a>";
    ?>

    In this page, the information cannot be shown in the browser.

     

    Could anybody help me to find out what's wrong?

     

    Thanks,

    ayok

  10. Hi, I have a question with php script for "if" statement.

     

    I have this php code for a news with image in it:

    <?php
    echo "$data[day_news], $data[date_news], $data[time_news]<br><b>$data[by]</font></b><br><br>";
    echo "<h1>$data[title]</h1>";
    echo "<a href=detail_news.php?id=$data[news_id]><img align='left' src='images/$data[image]'></a>";
    echo "$data[body]";	

     

    But if there is no image uploaded, it has a cross box where the image should be there.

    What should I write if I don't want any image if I didn't upload the image?

     

    Thank you,

     

    ayok

  11. But it's kind of weird, because i made an upload script where I can put an original image, then create two smaller images in different folders, and then in the same script, I am able to unlink the original image from the folder. So how come I couldn't unlink those two smaller images?

     

    thanks,

    ayok

  12. All right,

    I can now unlink the image files from the image folder in localhost. But when I test it on web server, i keep getting this error:

    Warning: unlink() [function.unlink]: http does not allow unlinking in /home/mywebcom/HTML/products/admin/delete.php on line 8

    I even set the permission to 777, but i still get this error. How can I solve this?

     

    Thank you,

    ayok

  13. Hi,

    I have difficulty to set up the code.

    What I try to do is to unlink 2 images (same name) in different folder.

    This is my delete.php

    <?php
    
    include "../dbconnect.php";
    $delete="DELETE from product WHERE id='$id'";
    $result=mysql_query($delete);
    
    if($result)
    {
    header("location:index.php");
    }
    else
    {
    echo "Delete process failed";
        echo "<a href=index.php>Try again</a><br>";
        echo "<a href=logout.php>Logout</a><BR>";
    }
    
    ?>

     

    I've tried to add this code:

    $image = "SELECT image FROM products WHERE id = '$id'";
    unlink('images/$image);
    unlink('images/thumbnail/$image);

     

    But it doesn't work.

     

    Could anybody help me?

     

    Thanks,

    ayok

    But

  14. Hi,

    I have a question. I have some php scripts to upload images and delete it. But if I delete the image I only delete the image's data in the database, and the image still remains in the folder.

     

    My question is, how can I remove the image from the image folder?

     

    Thank you,

    ayok

  15. In the interest of getting this solved:

     

    <?php
    $show = mysql_query("SELECT service.*,category.name FROM service LEFT JOIN category on service.category=category.id_cat WHERE category='$id'") or die(mysql_error());
    echo "<table border=0><tr bgcolor='#D0DCE0'><th>Service</th><th>Description</th><th>Duration (minutes)</th><th>Prices</th></tr>";
    
    
        while (($data = mysql_fetch_array($tampil)) && (mysql_num_rows($tampil) > 0))
        {
            echo "<tr>";
            echo "<td bgcolor='#D47FFF'>$data[name_serv]</td>";
            echo "<td bgcolor='#FF55FF'>$data[desc_serv]</td>";
            echo "<td bgcolor='#D47FFF'>$data[minutes]</td>";
            echo "<td bgcolor='#FF55FF'>$data[price]</td>";
            echo "<td><a href='' onclick='return disp_confirm()'>delete</a><br><a href=edit_service.php?id=$data[id_serv]>edit</a></td></tr>";
        }
        echo "</table>";
    }?>
    
    <script type="text/javascript">
    function disp_confirm(){
        var msg = "Do you really want to delete this?";
        if (confirm(msg)){
            window.location.href = "delete.php?id=<?php echo $datakategori['id_cat']; ?>";
        }
        return false;
    }
    </script>

     

    Hi roopurt,

     

    Thank you for being so patient to help me to solve my problem ;). This is what I found.

    the links should be "delete.php?id=<?php echo $data['id_serv']; ?>"; I want to delete the service item, not the category. I don't know why I used that $datakategori variable. Anyway, I've changed the links to "$data['id_serve]".

     

    However, it keeps getting the links of $datakategori variable. Its probably getting confused because the link is outside the php code. So, nogray is right. Thanks for your code. It's working now.

     

    Thank you,

    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.