User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 455,964 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,609 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 720 | Replies: 5 | Solved
Reply
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Help insert in mysql

  #1  
Nov 19th, 2007
hi
i want to know whether my coding is correct because data is not getting inserted in my sql table,but it is displaying the "data inserted" message<html>
<head></head>
<body>
<?php
$uname1= $_POST['uname1'];
$cname=$_POST['cname'];
$caddr=$_POST['caddr'];
$mid=$_POST['mid'];
$skills=$_POST['skills'];
$degree=$_POST['degree'];
$indtype=$_POST['indtype'];
$desc=$_POST['desc'];
$req=$_POST['req'];
$yoe=$_POST['yoe'];
$sal2=$_POST['sal2'];
$search=$_POST['search'];
$hostname = "localhost";
$username = "uname";
$password = "godcares";
$dbid = "splendor_samp";
$link=mysql_connect($hostname, $username, $password);
mysql_select_db($dbid) or die("unable to connect");

if (isset($_REQUEST["Submit"]))
{
mysql_query("INSERT INTO postreq(uname,cname,caddr,mailid,skills,degree,indtype,desc,req,yoe,sal,searchdate)VALUES('$uname1','$cname','$caddr','$mid','$skills','$degree','$indtype','$desc','$req','$yoe','$sal2','$search')");
echo "data inserted";
}
else
{
echo "ERROR: ".mysql_error();
}
mysql_close($link);
?>
</body>
</html>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation: ryan_vietnow is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 68
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: insert in mysql

  #2  
Nov 20th, 2007
try changing this one:
if (isset($_REQUEST["Submit"]))

with this one:
if ($_POST('Submit'))
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
Reply With Quote  
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Re: insert in mysql

  #3  
Nov 20th, 2007
hi
it is displaying error message like this
RROR:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc,req,yoe,sal,searchdate)VALUES('jhj','hjhg','hjhg','hjghj','hjhj','hjhj','hj' at line 1
Reply With Quote  
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation: ryan_vietnow is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 68
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: insert in mysql

  #4  
Nov 20th, 2007
Have you tried running your query in MySql?I think the problem there is the query itself,e.g. wrong fields,wrong field type,etc.for example your searchdate is supposed to be a date therefore you must enter a date.Try to check on this one.
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
Reply With Quote  
Join Date: Nov 2007
Posts: 183
Reputation: lydia21 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 5
lydia21 lydia21 is offline Offline
Junior Poster

Re: insert in mysql

  #5  
Nov 20th, 2007
thanks for your reply ...i found the error...desc is a key word in sql...i have given the name to my field in the table......
Reply With Quote  
Join Date: Aug 2007
Location: Cavite,Philippines
Posts: 508
Reputation: ryan_vietnow is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 68
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: insert in mysql

  #6  
Nov 20th, 2007
ok,please mark your thread as solved!
"death is the cure of all diseases..."
http://ryantetek.wordpress.com
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:01 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC