Jump to content

Whats wrong with my code???


amitojduggal

Recommended Posts

Hello everybody,

The code is driving me nuts from couple of days
i just can't spot whats wrong in that.
i am inserting data in the database, but its not working , please someone verify the code
[code] $linkid=mysql_connect("localhost","root","")or die ('Couldnt Connect To database');
  mysql_select_db("details");
  $query ="INSERT INTO all(name,company_name,designation,response,ph_number,email,review) VALUES('$_POST[textfield3]','$_POST[textfield]','$_POST[textarea]','$_POST[textfield4]','$_POST[textfield5]', '$_POST[q]')";
  $result=mysql_query($query);[/code]
someone please tell me whats wrong in that.
I will be highly thankful

Amitoj
Link to comment
Share on other sites

Can you please try the query like this:

$query ="INSERT INTO all(name,company_name,designation,response,ph_number,email,review) VALUES('".$_POST[textfield3]."','".$_POST[textfield]."','".$_POST[textarea]."','".$_POST[textfield4]."','".$_POST[textfield5]."', '".$_POST[q]."');";

Please post the error you get
Link to comment
Share on other sites

Well firstly if you are going to define link resource objects you should use them by supplying them as parameters to your subsewuent mySQL functions. Secondly, the 'all' in your query is both incorrect and unnecessary, SQL assumes all unless you qualify your statement somehow with a WHERE.
Link to comment
Share on other sites

i don't get any error but the code simply doesn't make data inserted in sql database, i still see 0 records there,
please someone check my code, i really need help.
and please tell me whats the difference between
[code]$query ="INSERT INTO all(name,company_name,designation,response,ph_number,email,review) VALUES('".$_POST[textfield3]."','".$_POST[textfield]."','".$_POST[textarea]."','".$_POST[textfield4]."','".$_POST[textfield5]."', '".$_POST[q]."');";[/code]

and this way

[code]$query ="INSERT INTO all(name,company_name,designation,response,ph_number,email,review) VALUES('$_POST[textfield3]','$_POST[textfield]','$_POST[textarea]','$_POST[textfield4]','$_POST[textfield5]', '$_POST[q]');";[/code]

isn't both same
Link to comment
Share on other sites

Need space between all and (
[code]

$query ="INSERT INTO all (name,company_name,designation,response,ph_number,email,review) VALUES('".$_POST[textfield3]."','".$_POST[textfield]."','".$_POST[textarea]."','".$_POST[textfield4]."','".$_POST[textfield5]."', '".$_POST[q]."');";

[/code]
Link to comment
Share on other sites

some field names are reserved in MySQL
try to add ` before and after the field name.
like :
[code]
$query ="INSERT INTO all(`name`,company_name,designation,response,ph_number,email,`review`) VALUES('$_POST[textfield3]','$_POST[textfield]','$_POST[textarea]','$_POST[textfield4]','$_POST[textfield5]', '$_POST[q]')";
[/code]
you may have trouble with the filed names (name,review) I said maybe.
Also you should use mysql_real_escape_string to make your script safe.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.