473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

update image and text at a time in database what is the query for that.

1
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php 
  3. include('auth.php');
  4. ob_start();
  5. include('config.php');
  6.  
  7.  
  8.  
  9.  
  10.  
  11. $title=$_POST['title'];
  12. $content=$_POST['text1'];
  13. $titles=$_POST['title1'];
  14. $contents=$_POST['text2'];
  15.  
  16. $file = basename($_FILES['img']['name']);
  17. if($file)
  18. {
  19. //exit(var_dump($_FILES));
  20. $file=time().$file;
  21. $target_path = dirname(_FILE_). '/img/';
  22. $hh=move_uploaded_file($_FILES['img']['tmp_name'],$target_path.$file);
  23. //echo  $hh."lipu";
  24. }
  25.  
  26. $name="img/".$_FILES['img']['name'];
  27.  
  28.  
  29.  
  30. //we verify if the image has been uploaded, and print error instead
  31.  if(isset($_POST['Submit']) && !$errors) 
  32.  {
  33.      header("location:aboutus.php?msg=success");
  34.  
  35.  }
  36. $sql="INSERT INTO  aboutus(title,des,subtitle,descr,img)VALUES('$title','$content','$titles','$contents','$file')";
  37.  
  38. $result=mysql_query($sql);
  39. if(!$sql)
  40. die(mysql_error());
  41.  
  42. // close connection
  43. mysql_close();
  44.  
  45. ?>
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
Jan 3 '15 #1
2 1467
omerbutt
638 512MB
you tell me ?
regards,
omer aslam
Jan 5 '15 #2
omerbutt
638 512MB
  • FIRST of all what are you really trying to do :D
what is this thing doing in the whole code
Expand|Select|Wrap|Line Numbers
  1.  
  2. if( isset($_POST['Submit']) 
  3.     && !$errors) {
  4.      header("location:aboutus.php?msg=success"); 
  5.  }
  6.  
and your sql insert query is written after this if condition so when ever you submit any thing via post on this page and the file is uploaded the page will redirect to aboutus.php and your query will never run
  • Secondly
please kindly tell what error are you currently receiving, and look at the following line.
Expand|Select|Wrap|Line Numbers
  1. VALUES('$title','$content','$titles',
  2. '$contents','$file')";
  3.  
you should not use single quotes around php variables as they need to be parsed for the value they are holding remove them and run the code hope it helps.
you should really donate blood :D
regards,
Omer Aslam
Jan 5 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mike Leahy | last post by:
Hello all, This question is related to updating tables - is there any way to calculate or update the values in a column in a table to the values in a field produced by a query result? An...
7
by: Eric Slan | last post by:
Hello All: I'm having a problem that's been baffling me for a few days and I seek counsel here. I have an Access 2000 DB from which I want to run several reports. These reports are...
1
by: Thubaiti | last post by:
Hi, I have an image web control with other web controls.. <asp:Image id="itemImage" runat="server"></asp:Image> <asp:Label id="itemNameLabel" runat="server"></asp:Label> <asp:Label...
6
by: Dixie | last post by:
I have asked this question before, but I could not get the suggested solution work. So I will give more details this time. I have an append query that adds several hundred records to a table...
1
by: udivyaprakash | last post by:
Hi guys, I have doing my php project using mysql. My problem is how to upload a image in database.but i got a coding in internet and implemented.But dont know how to update that image. That...
2
by: avvarumurali | last post by:
Hi, iam doing c# windows application. i save a image into the database,but iam unable to retrive image from database it is giving error "parameter is not valid "; mycode is : string query =...
2
by: John Kotuby | last post by:
Hi all, Maybe this belongs in the Full Text group but I am writing an ASP.NET application with a SQL Server 2005 backend, so I am posing the question here. I have been using fulltext search...
1
by: simon2x1 | last post by:
how can i arrange image that i echo from the database to be in 5column and 2 row that is if i have 5 image that is echo on a page the next image that will be added should be in the second row and...
0
by: dipalipatel | last post by:
Hi, I have a very hard time to insert Image into Sqlce Database. Table : Test Column : mypic Datatype : image below the code while i am inserting
8
by: AnagJohari | last post by:
I would like to of display an the image at a proper position on a browser. I access the image from the database before doing this I stored the image in a database in a byte form. I also make a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.