Author |
|
peacemaker
Joined: 23 May 2008 Posts: 80
|
Posted: Thu 27 Nov '08 4:21 Post subject: Need Help About How to save pics in mysql database |
|
|
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
|
Posted: Thu 27 Nov '08 15:08 Post subject: |
|
|
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
|
Posted: Fri 28 Nov '08 1:34 Post subject: |
|
|
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
|
|
Back to top |
|
peacemaker
Joined: 23 May 2008 Posts: 80
|
Posted: Sun 30 Nov '08 2:03 Post subject: Login Problem |
|
|
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
|
Posted: Sun 30 Nov '08 19:45 Post subject: |
|
|
I'm not a debugger 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
|
Posted: Sun 30 Nov '08 23:08 Post subject: |
|
|
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 |
|