Pleas help me on this

i am a new one for php and i want to upload a picture to database
can u plz help me to do this ................

thanx.............

You can't really upload a picture to a database...save it to your server, save the title to your database, then call it using the title from your database.

You can run a quick Google search to figure out how to do each of those.

actually you can upload files to the database, but its better to save them on the server.

actually you can upload files to the database, but its better to save them on the server.

Hi this is the code for uploading files or images....if u want specific formates plz go to other codes...

here first u create folder for uploading images.....in this example code i created news folder..u can change it...
plz change this code based on ur requirement..

<?php
include_once("dbconnect.php");
$uploaddir="news/";
if(isset($_POST['save']))
	{
	$headline=$_POST['headline'];
	$content=mysql_real_escape_string($_POST['content']);
	$upload_Name1=$_FILES['file']['name'];
	
	 if(file_exists($uploaddir.$upload_Name1)) {  ?>
     
	 <div align="center"><font color="#000000" size="+1">
	 
	 <?php echo "EXISTED FILE NAME, Please rename your files and try again."; ?></font></div> 
	 
	 <?php
			
		}
		else
         {
		 if ($_FILES['file']['name'] != "")
        	{
            $uploadfile = $uploaddir.$_FILES['file']['name'];
			if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile))

                {
				$query="insert into news values('','$headline','$content','$upload_Name1',NOW())";
				mysql_query($query) or die(mysql_error());
?>
     <div align="center"><font color="#000000" size="+1"><?php echo "Successfully Saved in our Database"; ?></font></div>           
<?php
				}
			
			}
			
		 }
	
	}
	
	
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>News-JaiPolitics</title>
</head>

<body>
<fieldset>
	
<div  ><font color="#000066" style="font-weight:bold"><a href="news.php">
    News
    </a>| <a href="Logout.php">Logout   </a></font></div>
<table border="0" cellpadding="0" cellspacing="0" width="1024" align="center">




	<tr>
	
            <td width="210" valign="top"></td>
			<td width="10">&nbsp;</td>
			<td class="lakstoppad1" valign="top">

            		<form name="news" action="" method="post"  enctype="multipart/form-data">

                    	

                    	<table border="0" cellpadding="0" cellspacing="1" width="100%" bgcolor="#EEEEEE">

                    		<tr>
                            	<td class="tblhdr" colspan="7" height="24">
                                	News	Post							</td>
                            </tr>
							
							<tr>

                            	<td width="16%" class="tbldt">

                                	Headline<span class="manda">*</span>                                     </td>

                          <td width="84%" class="tbldt">

                   	   <input name="headline" type="text" id="headline" tabindex="1" size="70"/>

								 </td>
                          </tr>

                             <tr>

                            	<td height="197" class="tbldt">

                                	News                                </td>

                            <td class="tbldt">

                                	<textarea id="content" name="content" tabindex="2" style="width:90%" rows="25"></textarea>                                </td>
                            </tr>
<tr>

                            	<td width="16%" class="tbldt">

                                	Photo <span class="manda">*</span>                                     </td>

<td width="84%" class="tbldt">

<input type="file" name="file"/>

									                   </td>
                          </tr>

                             <tr>

                             	
                                <td height="120" colspan="2" align="center" valign="baseline"><input type="submit" value="Save" name="save" id="save" tabindex="4" style="background-image:url('../Images/btnsmall2.gif');width:100;height:26;border:0" class="btnbg"/>
                               <input name="Reset" type="reset" class="btnbg" style="background-image:url('../Images/btnsmall2.gif');width:100;height:26;border:0" tabindex="15" value="Clear"/></td>
                          </tr>       
                    	</table>
                
		      </form>

            </td>

        </tr>

    </table>
</fieldset>
</body>
</html>

this is working but whr is the DB codes i cant solve without the DB codings

plzzz help me

this is working but whr is the DB codes i cant solve without the DB codings

plzzz help me

DB codes means?


u want configaration code ? at the top of ur page having database code....

DB codes means?


u want configaration code ? at the top of ur page having database code....

create the table

wht are the rows?

this is working but whr is the DB codes i cant solve without the DB codings

plzzz help me

<?php
 	$conn=mysql_connect("localhost","root","");
 	mysql_select_db('dbname',$conn);
	if(!$conn)
{
die("Unable to connect to database!");
}
?>

create the table

wht are the rows?

CREATE TABLE `table` (
  `id` int(50) NOT NULL auto_increment,
  `topic` text NOT NULL,
  `content` longtext NOT NULL,
  `photo` text NOT NULL,
  `date` datetime NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
CREATE TABLE `table` (
  `id` int(50) NOT NULL auto_increment,
  `topic` text NOT NULL,
  `content` longtext NOT NULL,
  `photo` text NOT NULL,
  `date` datetime NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;

is this working with ur php cades u gave me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.