943,771 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 393
  • PHP RSS
Jul 4th, 2009
0

Whats the error

Expand Post »
php Syntax (Toggle Plain Text)
  1. <?php
  2. $con=mysql_connect("localhost","root","");
  3. if(!$con)
  4. {
  5. die('Could not connect:'.mysql_error());
  6. }
  7. mysql_select_db(customer1,$con)
  8. $sql1="INSERT INTO details(companyname,companyadd,comstate,telephone,fax,email,fname,lname,nic,mobile,username,password);VALUES('$_POST[coname]','$_POST[coadd]','$_POST[cost]','$_POST[tel]','$_POST[fax]','$_POST[mail]','$_POST[fname]','$_POST[lname]','$_POST[nic]','$_POST[mob]','$_POST[user]','$_POST[password]')";
  9. if(!mysql_query($sql1,$con))
  10. {
  11. die('Error:'.mysql_error());
  12. }
  13. echo"1 record added";
  14. mysql_close($con)
  15. ?>
Last edited by peter_budo; Jul 6th, 2009 at 6:54 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dilan_n is offline Offline
1 posts
since Jul 2009
Jul 4th, 2009
0

Re: Whats the error

Hi..
check this two lines

mysql_select_db($customer1,$con)  

and

$sql1="INSERT INTO details(companyname,companyadd,comstate,telephone,fax,email,fname,lname,nic,mobile,username,password) VALUES('$_POST[coname]','$_POST[coadd]','$_POST[cost]','$_POST[tel]','$_POST[fax]','$_POST[mail]','$_POST[fname]','$_POST[lname]','$_POST[nic]','$_POST[mob]','$_POST[user]','$_POST[password]')";

Click to Expand / Collapse  Quote originally posted by dilan_n ...
<?php
$con=mysql_connect("localhost","root","");
if(!$con)
{
die('Could not connect:'.mysql_error());
}
mysql_select_db(customer1,$con)
$sql1="INSERT INTO details(companyname,companyadd,comstate,telephone,fax,email,fname,lname,nic,mobile,username,password);VALUES('$_POST[coname]','$_POST[coadd]','$_POST[cost]','$_POST[tel]','$_POST[fax]','$_POST[mail]','$_POST[fname]','$_POST[lname]','$_POST[nic]','$_POST[mob]','$_POST[user]','$_POST[password]')";
if(!mysql_query($sql1,$con))
{
die('Error:'.mysql_error());
}
echo"1 record added";
mysql_close($con)
?>
Reputation Points: 10
Solved Threads: 7
Junior Poster
sarithak is offline Offline
183 posts
since Aug 2008
Jul 4th, 2009
0

Re: Whats the error

check out this code
php Syntax (Toggle Plain Text)
  1. <?php
  2. $con=mysql_connect("localhost","root","");
  3. if(!$con)
  4. {
  5. die('Could not connect:'.mysql_error());
  6. }
  7. mysql_select_db(customer1,$con)
  8. $sql1="INSERT INTO details(companyname,companyadd,comstate,telephone,fax,email,fname,lname,nic,mobile,username,password)
  9. VALUES('".$_POST['conam'e]."','".$_POST['coadd']."','".$_POST['cost']"','".$_POST['tel']."','".$_POST['fax']."','".$_POST['mail']."','".$_POST['fname']."','."$_POST['lname']."','".$_POST['nic']."','".$_POST['mob']."','".$_POST['user']."','".$_POST['password']."')";
  10. if(!mysql_query($sql1,$con))
  11. {
  12. die('Error:'.mysql_error());
  13. }
  14. echo"1 record added";
  15. mysql_close($con)
  16. ?>
Reputation Points: 21
Solved Threads: 29
Posting Whiz in Training
praveen_dusari is offline Offline
202 posts
since Jun 2008
Jul 4th, 2009
0

Re: Whats the error

Hi..

As in C or Perl, PHP requires instructions to be terminated with a semicolon at the end of each statement.

http://sk.php.net/manual/en/language...separation.php

and check this two lines

mysql_select_db($customer1,$con) ;

and

mysql_close($con);

I hope it's gonna be OK.
Last edited by peter_budo; Jul 6th, 2009 at 6:54 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
Yayo_SK is offline Offline
11 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: cannot post an end date
Next Thread in PHP Forum Timeline: videos in PHP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC