logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Other Software View previous topic :: View next topic
Reply to topic   Topic: Need Help About How to save pics in mysql database
Author
peacemaker



Joined: 23 May 2008
Posts: 80

PostPosted: Thu 27 Nov '08 4:21    Post subject: Need Help About How to save pics in mysql database Reply with quote

Hi all,
I have a little bit of problem about how to save the pic images into mysql database using php. I need help, if any body can give me suggestion about how to use BLOB datatype. i have no idea. I saw few blogs they create table with fields like, imagename,imagetype,imagesize , does it is necessary to do this or i can straight away add pic as one of the filed in the record. Or i wil have to create seperate table to store all the details.I am going to create a gallery and going to display it. I am creating web site for wild life organisation,they need to show their pics of birds and wild animals so for that i need to save the pics. I will be thankful if i get suggestions as soon as possible.
Please suggest i am confused.
Thanks in advance.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 27 Nov '08 15:08    Post subject: Reply with quote

I never used blobs so far. If realy needed it stored binary data encoded with bas64 in the DB and give it out with decodebase64.

But I recommend NOT to store files in a DB, but the paths to the binaries on the file system.
Back to top
peacemaker



Joined: 23 May 2008
Posts: 80

PostPosted: Fri 28 Nov '08 1:34    Post subject: Reply with quote

Thanks for the reply james,
i didnt get wat you mean by storing path. Can u explain me plz or is there any thread then can u tell me plz. I will be thankful for that.
Else is there any other way other than BLOB to store pic in db. Or shall i just upload pic in 1 folder and store the file name with full path as text in DB. This is wat you mean to say. I wil have to use the Upload File script like uploading files to server. and store the name and address of the file(pic file) in the DB.Hope is the thing that u want to suggest me.
Again thanks for reply in advance.
Bye
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Sat 29 Nov '08 21:30    Post subject: Reply with quote

Yepp that was what I tried to tell. Upload a file to harddisk and store in the DB the path e.g. images/your.jpg

For using BLOB I found a tutorial.

http://www.php-mysql-tutorial.com/php-mysql-upload.php
Back to top
peacemaker



Joined: 23 May 2008
Posts: 80

PostPosted: Sun 30 Nov '08 2:03    Post subject: Login Problem Reply with quote

Hi James thanks for the reply, rt now i m not working on the gallery stuff, rt now i want to start doing the doing the login for users. i am giving html php code i request you to check the code and tell me where is the problem as the varibles are not passing values to the next page so its nt checking the password and username. I m confused , i have taken the code form 1 web site. so plz check for me the code. The data is going properly in the database just wanna check the login. Thanks for help again

The codes are as follows
HTML code
Code:

<form action="login.php" method="post">
         
      
         <label style="padding-bottom:14px;">login </label><br />
         <input type="text" name="MyLogin"  /><br /><br />
         
         <label>Password </label><br />
         <input type="password" name="MyPass" />
         
         <input type="submit" value="Login" name="ok" />
         
         <?php
         
         ?>
         
      </form>   



Login.php

Code:


$mysqli=mysqli_connect("localhost","ABC","PQR","wecs");
      $sql="select * from login where loginname='$Mylogin' AND password='$MyPass'";
      echo $MyLogin;
      echo $MyPass;
      echo $sql;
      
      if($rec=mysql_fetch_array(mysql_query("SELECT * FROM  login WHERE loginname='MyLogin' AND password = '$MyPass')))
         
      echo $rec;
      echo $MyLogin;
      echo $MyPass;
      
      
      {
      
      
      if(($rec['loginname']=='$MyLogin')&&($rec['password']=='$MyPass'))
      {
   
         echo $MyLogin;
         echo $MyPass;
         
         
         echo "User Name Password Correct";
      }   
   
      else
      {
         echo "User Name or password not correct";
      }
      
   }
   ?>



I have give both the files, i request you to please check the code and please tell me where is my mistake.
Or i need to use the session variables for ssending the values of the MyLogin and MyPass to the next page
I checked the values of Mypass and MyLogin but nothing is there with echo statement. I m confused wat to do.
Thanks in advance
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Sun 30 Nov '08 19:45    Post subject: Reply with quote

I'm not a debugger Wink But I noticed that you mixed up mysql and mysqli. For beginner I recommend you to use only mysql.
Back to top
peacemaker



Joined: 23 May 2008
Posts: 80

PostPosted: Sun 30 Nov '08 23:08    Post subject: Reply with quote

Hi james thanks for nice reply. Sorry for bugging u.
I got my mistake. i will try again and hope it wil work and thanks for pointing out my mistake
Back to top


Reply to topic   Topic: Need Help About How to save pics in mysql database View previous topic :: View next topic
Post new topic   Forum Index -> Other Software