PHP & MYSQL HELP
Posted by: aks_anilsharda (202.81.207.---)
Date: June 22, 2007 10:06AM

I have created a database "name" and i m trying to insert values in database by php coding...
but the value is not inserting the output comes that "-1 data insert";
i m very confused that y -1 is coming n y not values is inserted...
i m using WAMP5 for testing the code.
Please help me on this issue...


database name "name"
table name is "name";
and the structure of table is as follow:

Field Type Collation Attributes Null Default Extra Action
name varchar(30) latin1_swedish_ci No anonymous

CODING IS AS FOLLOW:

<?php

/**
* @author anilsharda
* @copyright 2007
*/
?>
<html>
<body>
<form action="add.php" method="PODT">
<table width=40% bgcolor="red">
<tr>
<td width=40% bgcolor="white"><b>Name :</b></td>
<td bgcolor="white"><input type="text" name="name" size="30"></td>
<tr><td colspan=2 align="center"><input type="submit" value="SUBMIT" name="s1"></td></tr>
</tr>
</table>

<?php
$name=$_POST['name'];
$db=mysql_pconnect('localhost','root','anilsharda') or die("unable to connect"winking smiley;
mysql_select_db('name',$db);
$result=mysql_query("insert into name value('.$name.'),$db"winking smiley;
if (!$result) {echo mysql_affected_rows($db)."data insert";}

?>



Anil sharda

Options: ReplyQuote
Re: PHP & MYSQL HELP
Posted by: Hekko (---.net.upc.cz)
Date: June 22, 2007 06:39PM

There's a typo in the form (method="PODT"winking smiley.

I believe the correct INSERT syntax is INSERT INTO table VALUES(value1[, value2]).

Also, close the <form> tag (if it's not closed and just missing in the piece of code you pasted).



Post Edited (06-22-07 18:47)

Options: ReplyQuote
Re: PHP & MYSQL HELP
Posted by: aks_anilsharda (202.81.207.---)
Date: June 25, 2007 06:27AM

thanks dear ...
its work....



Anil sharda

Options: ReplyQuote


Sorry, only registered users may post in this forum.