Following is my error free code, it has no syntactical error but when I run it it executes the else part, which means my databse has not been updated.What is the problem?
<html>
<body>
<?php
$connect=mysql_connect("localhost","root","ila");
$query="create database if it not exists demo";
$db=mysql_select_db("demo",$connect);
$query= "create table jlt(id int not null , name varchar(49))";
$result=mysql_query($query);
$query="insert into jlt values(1,'$_POST[inputfield]')";
if(mysql_query($query,$connect)){
echo "data successfully added";
}
else {
echo "not success";
}
?>
</body>
</html>
geekme
0
Junior Poster in Training
Recommended Answers
Jump to PostAs a general approach, if you are having a problem with a query, the fastest way to sort it out is to echo the query, paste it into PHPMyAdmin and work on it there until you have it figured out. Then you can change your code accordingly.
All 4 Replies
blocblue
238
Posting Pro in Training
Featured Poster
chrishea
182
Nearly a Posting Virtuoso
karthik_ppts
commented:
yes
+5
divyakrishnan
20
Junior Poster
geekme
0
Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.