i tried atli's manual and the picture is not appearing?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #16
    well, it does not explain where the string comes from, but it explains the strange submit.

    obviously image.php is designed to be an image (representation ), thus if you put it in your form's action it will be executed onsubmit (say, if you submit the form, you'll be returned an image (which is possible, but doesn't make sense)). solution: put the form handling script in the action attribute.

    Comment

    • Paul NIcolai Sunga
      New Member
      • Mar 2008
      • 43

      #17
      solution: put the form handling script in the action attribute.

      what exactly i will put in the action attribute?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #18
        Originally posted by Paul NIcolai Sunga
        what exactly i will put in the action attribute?
        ............... ......


        the script (resp. its file name) that processes the form data (may be the same as the current page)

        Comment

        • Paul NIcolai Sunga
          New Member
          • Mar 2008
          • 43

          #19
          what shall i do? it is still not working..

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #20
            what is not working, the form or the image?

            Comment

            • Paul NIcolai Sunga
              New Member
              • Mar 2008
              • 43

              #21
              the image is not showing.. i tried to show it through the src itself and its okei but when the image that came from the database it is not showing,.. maybe the problem is in the database or in the code, but there is no sign error in the codes.

              Comment

              • Dormilich
                Recognized Expert Expert
                • Aug 2008
                • 8694

                #22
                ok, then you have to make sure that the picture is saved correctly in the DB . there are some MySQL GUIs out, but unless you have a Mac I can’t recommend anything.

                (If that’s possible I could try connecting to your DB and look myself)

                Comment

                • Canabeez
                  New Member
                  • Jul 2009
                  • 126

                  #23
                  Here's one I use... SQLYog

                  Comment

                  • Dormilich
                    Recognized Expert Expert
                    • Aug 2008
                    • 8694

                    #24
                    Originally posted by Canabeez
                    Here's one I use... SQLYog
                    does it show you any pictures?

                    Comment

                    • Paul NIcolai Sunga
                      New Member
                      • Mar 2008
                      • 43

                      #25
                      i tried another code:
                      here's the code. it only displays a blank photo. i mean an x that is usually seen in a blank photo..
                      Code:
                      <?php
                      
                      $Link = mysqli_connect("localhost","root","tupi", "amyak_maleh");
                      			if (!$Link)
                        			{
                        			trigger_error("Could not connect", E_USER_ERROR );
                        			}
                      
                      $result=mysqli_query($Link, "SELECT * FROM pix");
                      while($row=mysqli_fetch_assoc($result))
                      {
                       header("Content-type: image/jpeg");
                        echo "<img src=\"".$row['imgdata']."\" alt=\"".$row['title']."\" width=\"100\" length=\"100\"/>";
                      }
                      ?>
                      Last edited by Dormilich; Aug 12 '09, 04:09 AM. Reason: fixed [code] tags

                      Comment

                      • Dormilich
                        Recognized Expert Expert
                        • Aug 2008
                        • 8694

                        #26
                        Originally posted by Paul NIcolai Sunga
                        Code:
                        header("Content-type: image/jpeg");
                          echo "<img [U]src=\"".$row['imgdata']."\"[/U] alt=\"".$row['title']."\" width=\"100\" length=\"100\"/>";
                        this is completely wrong, the src attribute has to be an url!

                        Comment

                        • Dormilich
                          Recognized Expert Expert
                          • Aug 2008
                          • 8694

                          #27
                          I’ll give you a working example

                          HTML
                          Code:
                              <h4>
                                  <a class="hook" id="mord">Mord an Bord</a>
                              </h4>
                          
                          	<p>11. Januar 2009, SachsenSonntag</p>
                          	<div class="mitte">
                          		[U]<img src="img.php?iid=sas091"[/U] width="150" height="99" alt="Bild des Zeitungsartikels" title="Wohl bekomm’s! Ein Schlückchen zur Begrüßung der Passagiere" id="img_sas091"/>
                          	</div>
                          img.php
                          Code:
                          <?php
                          	require 'load.img.php';
                          	$img = new ArticleIMG;
                          	$img->display();
                          ?>
                          methods
                          Code:
                          	public function display()
                          	{
                          		if (!$this->requestImage())
                          		{
                          			exit;
                          		}
                          		
                          		if (!empty($this->DBimg['img_mime']) and !empty($this->DBimg['img_size']) and !empty($this->DBimg['img_data']))
                          		{
                          			[B]header('Content-Type: ' . $this->DBimg['img_mime']);
                          			header('Content-Length: ' . $this->DBimg['img_size']);
                          			echo $this->DBimg['img_data'];[/B]
                          		}
                          	}
                          
                          	protected function requestImage()
                          	{
                          		$this->load();
                          		
                          		if ($this->checkID($this->IID))
                          		{
                          			return $this->getImageData();
                          		}
                          		return false;
                          	}
                          
                          	private function getImageData()
                          	{
                          		try 
                          		{			 
                          			$PS = aDB::execute('img', array(':id' => $this->IID));
                          			$this->DBimg = $PS->fetch(PDO::FETCH_ASSOC);
                          		}
                          		catch (PDOException $pdo)
                          		{
                          			ErrorLog::logException($pdo, __CLASS__, __METHOD__);
                          			return false;
                          		}
                          		return true;
                          	}

                          Comment

                          • Paul NIcolai Sunga
                            New Member
                            • Mar 2008
                            • 43

                            #28
                            yes

                            is this correct?
                            Code:
                             
                            $pic = $_FILES['Browse'];
                            
                            $formid = mysqli_query($Link, "Select form_no from registration_form where last_insert_id() = form_no");
                            
                            $formnum = mysqli_fetch_row($formid);
                            
                            	
                            $querypic = mysqli_query($Link, "INSERT INTO pix(pid, imgdata) values('$formnum', '$pic')");
                            i am not certain with this code..

                            Comment

                            • Dormilich
                              Recognized Expert Expert
                              • Aug 2008
                              • 8694

                              #29
                              Originally posted by Paul NIcolai Sunga
                              is this correct?
                              Code:
                              $formid = mysqli_query($Link, "Select form_no from registration_form where last_insert_id() = form_no");
                              completely unnecessary (have a close look at what you want to do here… ;))

                              otherwise I can’t tell (too less info)

                              Comment

                              • Paul NIcolai Sunga
                                New Member
                                • Mar 2008
                                • 43

                                #30
                                okei.. im trying a lot of codes that is why i am so confused.. the issue about the displaying picture from mysql is still unsolved..

                                Comment

                                Working...