iexona Posted May 21, 2007 Share Posted May 21, 2007 i need help i have a very basic script that i need help with it basically has a form that saves data to a mysql db and then displlays the data on another page. very simple but it wont submit all the data im asking it to.. the code is below dont laugh at me im a php n00b. MYSQL CODE: CREATE TABLE `clients` ( `id` int(4) NOT NULL auto_increment, `name` varchar(65) NOT NULL default '', `email` varchar(65) NOT NULL default '', `phone` varchar(65) NOT NULL default '', `website` varchar(65) NOT NULL default '', `comment` longtext NOT NULL, `datetime` varchar(65) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=4 ; PHP CODE: <?php $host=""; // Host name $username=""; // Mysql username $password=""; // Mysql password $db_name=""; // Database name $tbl_name=""; // Table name // Connect to server and select database. mysql_connect("$host", "$username", "$password")or die("cannot connect server "); mysql_select_db("$db_name")or die("cannot select DB"); $datetime=date("y-m-d h:i:s"); //date time $sql="INSERT INTO $tbl_name(name, email, comment, datetime)VALUES('$name', '$email', '$comment', '$datetime')"; $result=mysql_query($sql); //check if query successful if($result){ echo "Client Added Successfully!"; echo "<BR>"; echo "<a href='clients.php'>View Clients</a>"; // link to view guestbook page } else { echo "ERROR"; } mysql_close(); ?> above is the php that submits the data from a html form... but every time i submit data it doesnt have any errors it seems to work but the data doesnt get sent to the database. to see what im talking about look here >>> http://www.jswebmedia.com.au/admin/clients.php l ook at ID 2 the id works and date works but other data is blank. ID 1 i added manually through the database. please help!!! im sure its something small ... the whole script has 3 php pages reply if u need to know any of the other code. Quote Link to comment https://forums.phpfreaks.com/topic/52301-solved-n33d-help-im-stuck/ Share on other sites More sharing options...
jitesh Posted May 21, 2007 Share Posted May 21, 2007 Have you on register global ? Quote Link to comment https://forums.phpfreaks.com/topic/52301-solved-n33d-help-im-stuck/#findComment-258016 Share on other sites More sharing options...
iexona Posted May 21, 2007 Author Share Posted May 21, 2007 register globals is off Quote Link to comment https://forums.phpfreaks.com/topic/52301-solved-n33d-help-im-stuck/#findComment-258017 Share on other sites More sharing options...
jitesh Posted May 21, 2007 Share Posted May 21, 2007 If No then $sql="INSERT INTO $tbl_name(name, email, comment, datetime) VALUES ('{$_REQUEST['name']}', '{$_REQUEST['email']}', '{$_REQUEST ['$comment']}', '{$_REQUEST['$datetime']}')"; OR $sql="INSERT INTO $tbl_name(name, email, comment, datetime) VALUES ('".$_REQUEST['name']."', '".$_REQUEST['email']."', '".$_REQUEST['$comment']."', '".$_REQUEST['$datetime']."')"; Quote Link to comment https://forums.phpfreaks.com/topic/52301-solved-n33d-help-im-stuck/#findComment-258019 Share on other sites More sharing options...
drinksbreak Posted May 21, 2007 Share Posted May 21, 2007 Try this $sql="INSERT INTO $tbl_name( id , name, email, comment, datetime)VALUES(NULL , '$name', '$email', '$comment', '$datetime')"; I have issues sometimes when I dont put in the id in and it throws me a "Out of range error"... Sometimes Quote Link to comment https://forums.phpfreaks.com/topic/52301-solved-n33d-help-im-stuck/#findComment-258021 Share on other sites More sharing options...
iexona Posted May 21, 2007 Author Share Posted May 21, 2007 thanks it worked!!! thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/52301-solved-n33d-help-im-stuck/#findComment-258023 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.