The following is a php script which runs perfectly fine. But I have one problem.
=> When I assign a variable the value from the form eg.
$acc = $_POST["accno"] it doesn't work. But if I give
$acc = $_POST[accno] it works (accno without quotes).
Also i the query
$result = mysql_db_query("book_info","insert into info values('$acc','$title','$auth','$edition','$pub')"); should I give single quotes to the variable names i.e $acc, $title ...?
Please help me out , when I should give single quotes or double quotes or no quotes at all ....?
=> When I assign a variable the value from the form eg.
$acc = $_POST["accno"] it doesn't work. But if I give
$acc = $_POST[accno] it works (accno without quotes).
Also i the query
$result = mysql_db_query("book_info","insert into info values('$acc','$title','$auth','$edition','$pub')"); should I give single quotes to the variable names i.e $acc, $title ...?
Please help me out , when I should give single quotes or double quotes or no quotes at all ....?
| Quote: |
| <HTML>
<HEAD> <TITLE> Program 8.php </TITLE> </HEAD> <BODY> <form action = "" method = "post"> Accession number <input type ="text" name = "accno"><p> Title <input type = "text" name = "title"><p> Authors <input type = "text" name = "authors"><p> Edition <input type = "text" name = "edition"><p> Publication <input type = "text" name = "pub"><p> <input type = "submit" value = "send"> <input type = "reset"><p><hr> </form> <? $mysql = mysql_connect("localhost","root","msrit"); $acc = $_POST[accno]; $title = $_POST[title]; $auth = $_POST[authors]; $edition = $_POST[edition]; $pub = $_POST[pub]; $result = mysql_db_query("book_info","insert into info values('$acc','$title','$auth','$edition','$pub')"); $r1 = mysql_db_query("book_info","select *from info"); while ( $array = mysql_fetch_row($r1) ) { foreach($array as $f) { print "$f ::"; } print "<hr>"; } ?> </BODY> </HTML> |
