to save pictures to the database (PHP) error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • arkhe3
    New Member
    • Jan 2010
    • 5

    #1

    to save pictures to the database (PHP) error

    Code:
    <?php
    ob_start();
    include("top.php");
    include("tabletop.php");
    if ( empty($_SESSION['nick']) AND empty($_SESSION['sifre']) AND empty($_GET["ilan"]) ) {
    echo "giriþ yapmadýnýz!";}else{
    $ilan=$_GET["ilan"];
    $sql=mysql_query("select tur from ilanayrinti$ilan where tur='resim'");
    $sayisi=mysql_num_rows($sql);
    $sqla=mysql_query("update ilan set resim=$sayisi where id=$ilan");
    if($sayisi<=4){
    require('ekler/fonksiyonlarim.php');
    require('ekler/ayarlarim.php');
    $ilan=$_GET["ilan"];
    
    ?>
    <script type="text/javascript">
    function highlight(field) {
    field.focus();
    field.select();
    }
    var maxWidth=100;
    var maxHeight=100;
    var fileTypes=["jpg","jpeg","gif","png"];
    var outImage="previewField";
    var defaultPic="spacer.gif";
    /***** DO NOT EDIT BELOW *****/
    function preview(what){
      var source=what.value;
      var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
      for (var i=0; i<fileTypes.length; i++) if (fileTypes[i]==ext) break;
      globalPic=new Image();
      if (i<fileTypes.length) globalPic.src=source;
      else {
        globalPic.src=defaultPic;
        alert("BU TÜR DOSYALARI YÜKLEYEMEZSÝNÝZ!\n\nÝzin verilen dosya uzantýlarý:\n\n"+fileTypes.join(", "));
      }
      setTimeout("applyChanges()",200);
    }
    var globalPic;
    function applyChanges(){
      var field=document.getElementById(outImage);
      var x=parseInt(globalPic.width);
      var y=parseInt(globalPic.height);
      if (x>maxWidth) {
        y*=maxWidth/x;
        x=maxWidth;
      }
      if (y>maxHeight) {
        x*=maxHeight/y;
        y=maxHeight;
      }
      field.style.display=(x<1 || y<1)?"none":"";
      field.src=globalPic.src;
      field.width=x;
      field.height=y;
    }
    </script>
    <?php
    if($_POST){
    require_once ('ekler/posttan.php');
    }
    ?>
    <style type="text/css">
    <!--
    .style5 {color: #CCCCCC}
    body,td,th {
    	font-size: 10px;
    }
    -->
    </style>
    </head>
    <body>
    <center>
    <form enctype="multipart/form-data" method=post>
    <table width=400 border=0 align=center height="704">
    
    <tr>
    <td align=center height="1"><b><font size=1 color="#0099FF"><?=$baslik;?><font></b></td></tr>
    <tr>
      <td align=center height="8">Yükleyebileceðiniz dosya türleri: .jpg, jpeg, .gif</td>
    </tr>
    
    
    
    <tr>
      <td height="20" align=center>Yüklenebilir MAXÝMUM Dosya Boyutu :
        <?php $maximum_mb = $azami / 1024 / 1024;
            echo number_format($maximum_mb, 2, ",", ".");?>
        MB</td>
    </tr>
    
    <tr>
      <td align=center height="21"><input name=resim type=file class="file" onChange="preview(this)" size="50"></td>
    </tr>
    
    <tr>
    <select size="0" name="id" style="visibility:hidden;">
                            <?php
    
                                            echo "<option value='$ilan'></option>";
    
                            ?>
                            </select><br>
    <td align=center height="25"><input name=gonder type=submit class="file" value="Dosya Yolla"></td>
    </tr>
    <tr>
      <td height="197" align=center valign="bottom">
    <?php
            if($_POST){
    if ($boyut >= $azami){
    uyari('Dosyanýz çok büyük!');
    }
                            if ($resim != "" && $boyut <= $azami){
    $uzanti_izinlimi = ptIzinlimi($uzanti);
                                            if ($uzanti_izinlimi == 'evet'){
                                            move_uploaded_file ($_FILES['resim']['tmp_name'], $klasor.$yeniresim) or die ('Dosya kopyalanamýyor');
    ?><table width="370" border=0 align=center class="uyari2">
    
    <tr>
      <td align=center height="239"><b><a href="<?=$link?>" target="_blank"> <img src="<?=$link?>" alt="<?=$link?>" width="150" border=0></a><br>
        Resim Boyutu =
        <?=$boyutkb?>
        </b>
    <br>
    <strong class="footer"><b>Resmi gerçek boyutta görmek için üzerine týklayýn...<br><br></b> </strong>
          <?php
                                            }
                                            if ($resimismi == ""){
                                            uyari('Dosya Seçin Lütfen!');
                                            }
                                            if ((!$resimismi == "")&&($uzanti_izinlimi == 'hayir')){
                                            uyari('Bu tür dosyalarý yükleyemezsiniz!');
                                            }
                            }
                    }
    if(!$_POST){
    uyari('');
    }
    ?></td>
    </tr>
    </table></form>
    <?
    include("baglanti.php");
    $id=$_POST["id"];
    if ($resim != "" && $boyut <= $azami){
    $sql="insert into ilanayrinti$id(tur,url) values('resim','$link')";
    
                            $kontrol=mysql_query($sql);
                            if($kontrol)
                            {
                                    echo "Resim kayýt iþlemi baþarýlý þekilde yapýldý";
                                    $gidilecekYer = "thumb.php?resim=$link&id=$id";
                                    header ("Location: " . $gidilecekYer);
                                    echo "<br>";
                            }
                            else
                            {
                                    die(mysql_error());
                                    echo "Resim kayýt iþlemi yapýlýrken hata oluþtu. Lütfen tekrar deneyiniz.";
                                    echo "<br>";
                            }
    ?>
    </td>
    </tr>
                            <?php
                            {{
    
      [B][U]                              else                 {[/U][/B]
    
    
                            echo "Son Eklediðiniz Resimde Yüklenmiþtir. Baska Resim Yükleyemezsiniz. Bir Ýlana En Fazla 5 Adet Resim Yükleyebilirsiniz. Resim Yükleme Limitiniz Dolmuþtur!";
                            }
    
                            include("tabloalt.php");
                            include("alt.php");
                            }
                ?>
    this is "real estate site" and People must to add house's picture. But BOLD and UNDELİNE code is problem..

    what can I do ?
    thanks,
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    "else" is the problem?

    What's the error code?

    What is it doing now?

    What should it be doing?

    Do you understand the error and Have you tried anything?



    Dan

    Comment

    • arkhe3
      New Member
      • Jan 2010
      • 5

      #3
      Originally posted by arkhe3
      Code:
      <?php
      ob_start();
      include("top.php");
      include("tabletop.php");
      if ( empty($_SESSION['nick']) AND empty($_SESSION['sifre']) AND empty($_GET["ilan"]) ) {
      echo "giriþ yapmadýnýz!";}else{
      $ilan=$_GET["ilan"];
      $sql=mysql_query("select tur from ilanayrinti$ilan where tur='resim'");
      $sayisi=mysql_num_rows($sql);
      $sqla=mysql_query("update ilan set resim=$sayisi where id=$ilan");
      if($sayisi<=4){
      require('ekler/fonksiyonlarim.php');
      require('ekler/ayarlarim.php');
      $ilan=$_GET["ilan"];
      
      ?>
      <script type="text/javascript">
      function highlight(field) {
      field.focus();
      field.select();
      }
      var maxWidth=100;
      var maxHeight=100;
      var fileTypes=["jpg","jpeg","gif","png"];
      var outImage="previewField";
      var defaultPic="spacer.gif";
      /***** DO NOT EDIT BELOW *****/
      function preview(what){
        var source=what.value;
        var ext=source.substring(source.lastIndexOf(".")+1,source.length).toLowerCase();
        for (var i=0; i<fileTypes.length; i++) if (fileTypes[i]==ext) break;
        globalPic=new Image();
        if (i<fileTypes.length) globalPic.src=source;
        else {
          globalPic.src=defaultPic;
          alert("BU TÜR DOSYALARI YÜKLEYEMEZSÝNÝZ!\n\nÝzin verilen dosya uzantýlarý:\n\n"+fileTypes.join(", "));
        }
        setTimeout("applyChanges()",200);
      }
      var globalPic;
      function applyChanges(){
        var field=document.getElementById(outImage);
        var x=parseInt(globalPic.width);
        var y=parseInt(globalPic.height);
        if (x>maxWidth) {
          y*=maxWidth/x;
          x=maxWidth;
        }
        if (y>maxHeight) {
          x*=maxHeight/y;
          y=maxHeight;
        }
        field.style.display=(x<1 || y<1)?"none":"";
        field.src=globalPic.src;
        field.width=x;
        field.height=y;
      }
      </script>
      <?php
      if($_POST){
      require_once ('ekler/posttan.php');
      }
      ?>
      <style type="text/css">
      <!--
      .style5 {color: #CCCCCC}
      body,td,th {
      	font-size: 10px;
      }
      -->
      </style>
      </head>
      <body>
      <center>
      <form enctype="multipart/form-data" method=post>
      <table width=400 border=0 align=center height="704">
      
      <tr>
      <td align=center height="1"><b><font size=1 color="#0099FF"><?=$baslik;?><font></b></td></tr>
      <tr>
        <td align=center height="8">Yükleyebileceðiniz dosya türleri: .jpg, jpeg, .gif</td>
      </tr>
      
      
      
      <tr>
        <td height="20" align=center>Yüklenebilir MAXÝMUM Dosya Boyutu :
          <?php $maximum_mb = $azami / 1024 / 1024;
              echo number_format($maximum_mb, 2, ",", ".");?>
          MB</td>
      </tr>
      
      <tr>
        <td align=center height="21"><input name=resim type=file class="file" onChange="preview(this)" size="50"></td>
      </tr>
      
      <tr>
      <select size="0" name="id" style="visibility:hidden;">
                              <?php
      
                                              echo "<option value='$ilan'></option>";
      
                              ?>
                              </select><br>
      <td align=center height="25"><input name=gonder type=submit class="file" value="Dosya Yolla"></td>
      </tr>
      <tr>
        <td height="197" align=center valign="bottom">
      <?php
              if($_POST){
      if ($boyut >= $azami){
      uyari('Dosyanýz çok büyük!');
      }
                              if ($resim != "" && $boyut <= $azami){
      $uzanti_izinlimi = ptIzinlimi($uzanti);
                                              if ($uzanti_izinlimi == 'evet'){
                                              move_uploaded_file ($_FILES['resim']['tmp_name'], $klasor.$yeniresim) or die ('Dosya kopyalanamýyor');
      ?><table width="370" border=0 align=center class="uyari2">
      
      <tr>
        <td align=center height="239"><b><a href="<?=$link?>" target="_blank"> <img src="<?=$link?>" alt="<?=$link?>" width="150" border=0></a><br>
          Resim Boyutu =
          <?=$boyutkb?>
          </b>
      <br>
      <strong class="footer"><b>Resmi gerçek boyutta görmek için üzerine týklayýn...<br><br></b> </strong>
            <?php
                                              }
                                              if ($resimismi == ""){
                                              uyari('Dosya Seçin Lütfen!');
                                              }
                                              if ((!$resimismi == "")&&($uzanti_izinlimi == 'hayir')){
                                              uyari('Bu tür dosyalarý yükleyemezsiniz!');
                                              }
                              }
                      }
      if(!$_POST){
      uyari('');
      }
      ?></td>
      </tr>
      </table></form>
      <?
      include("baglanti.php");
      $id=$_POST["id"];
      if ($resim != "" && $boyut <= $azami){
      $sql="insert into ilanayrinti$id(tur,url) values('resim','$link')";
      
                              $kontrol=mysql_query($sql);
                              if($kontrol)
                              {
                                      echo "Resim kayýt iþlemi baþarýlý þekilde yapýldý";
                                      $gidilecekYer = "thumb.php?resim=$link&id=$id";
                                      header ("Location: " . $gidilecekYer);
                                      echo "<br>";
                              }
                              else
                              {
                                      die(mysql_error());
                                      echo "Resim kayýt iþlemi yapýlýrken hata oluþtu. Lütfen tekrar deneyiniz.";
                                      echo "<br>";
                              }
      ?>
      </td>
      </tr>
                              <?php
                              {{
      
        [B][U]                              else                 {[/U][/B]
      
      
                              echo "Son Eklediðiniz Resimde Yüklenmiþtir. Baska Resim Yükleyemezsiniz. Bir Ýlana En Fazla 5 Adet Resim Yükleyebilirsiniz. Resim Yükleme Limitiniz Dolmuþtur!";
                              }
      
                              include("tabloalt.php");
                              include("alt.php");
                              }
                  ?>
      this is "real estate site" and People must to add house's picture. But BOLD and UNDELİNE code is problem..

      what can I do ?
      thanks,
      yes "else", 169. line Error code.

      this is Real Estate site and I must to add picture to house's. But I can't.

      Comment

      • arkhe3
        New Member
        • Jan 2010
        • 5

        #4
        Originally posted by arkhe3
        yes "else", 169. line Error code.

        this is Real Estate site and I must to add picture to house's. But I can't.
        Code:
         }
              else                 
             {
        ---->> true version the 169. line

        okey i can true edit this problem.

        Comment

        • dlite922
          Recognized Expert Top Contributor
          • Dec 2007
          • 1586

          #5
          I was being sarcastic. "else" is a language construct, how can it be the problem, unless you misspell it.

          I know you want to add pictures, but we're not here to discuss high level functions of the site, we're programmers.

          So can you be a little more specific in answering my previous questions?

          Here's what I was looking for:

          "I get error Code ABC123 that says this, but I checked X, Y, and Z, and all seem to be as expected. What I expect is to have value FOO in variable $bar on line #, but I get value BAZ. I've put in echo and die statements in place E, F, G, but now I can't seem to understand why line # changes my variable $bar from A to B. "

          That's the kind of troubleshooting you need to do to become a good programmer.

          Cheers,


          Dan

          Comment

          Working...