javascript - How to use sql tables on local machines when i have MAMP installed? -
javascript - How to use sql tables on local machines when i have MAMP installed? -
i installed mamp on mac run sql , apache server on local machine host website working on. using phpmyadmin command , create database tables. running couple of issues inserting values tables. have 2 pages namely, test.html , test.php. test.html has form username , password , calls javascript post values test.php.following code snippet of how posting value on test.html.
$.post("test1.php", { username: username, password: password }, function( datafromserver ){ alert(datafromserver); } );
i unable insert 2 values in table. when click submit, receive next error in firefox:
post http://localhost:8888//test1.php 500 internal server error
following code snippet of how insert values on test.php:
include('config.php'); $tbl_name="table1"; $username=$_post['username']; $password=$_post['password']; $sql="insert $tbl_name(col1,col2)values('$username','$password')"; $result=mysql_query($sql);
can point error here. new web coding might trivial.
thanks, -b
500 internal error means there wrong in php file. check next things
1.is there syntax error in php file.
2.
$sql="insert $tbl_name(col1,col2)values('$username','$password')";
should written as
$sql ="insert $tbl_name(col1,col2)values('".$username."','".$password."')";
also,always sanitize info before utilize it.
javascript mysql
Comments
Post a Comment