Alfraganus Posted December 21, 2015 Share Posted December 21, 2015 (edited) I am trying to upload my data in object orinted approach, but larger text are not being uplaoded while only smallers ones are being succesfully uploaded, why larger articles cant bu uplaoded, what is wrong with it? here is my sourse codes upload.php-------------- <!DOCTYPE html> <html> <head> <title>uploading a file</title> </head> <body bgcolor="blue"> <form accept="upload.php" method="post" enctype="multipart/form-data"> <table align="center" width="700" border="2" bgcolor="green"> <tr align="center"> <td align="center"> <td colspan="8"><h2>upload whatever you want mr Alfraganus</h2></td> </td> <tr> <td colspan="8" align="center"><input type="text" name="title" size="60"><b>Title</b></td> </tr> <tr> <td colspan="8"><textarea name="body" cols="80" rows="20"></textarea></td> </tr> <tr> <td colspan="8"><center><input type="submit" name="upload" value="upload the text"> </center></td> </tr> </table> </body> </html> <?php include_once 'functions.php'; $con=new cms(); if(isset($_POST['upload'])) { $title=$_POST['title']; $body=$_POST['body']; $con->insert($title,$body); } if($con) { echo "<script>alert('success')</script>"; } ?> functions.php------ <?php define('DB_SERVER','localhost'); define('DB_USER','root'); define('DB_PASS',''); define('DB_NAME','testdb'); class cms { function __construct() { $con=mysql_connect(DB_SERVER, DB_USER,DB_PASS) or die('localhost problemm'.mysql_error()); mysql_select_db(DB_NAME,$con); } public function insert($title,$body) { $res=mysql_connect("INSERT INTO CMS (title, body) values ('$title','$body')"); return $res; } } Edited December 21, 2015 by Alfraganus Link to comment Share on other sites More sharing options...
davej Posted December 21, 2015 Share Posted December 21, 2015 When you created the CMS table what were the title and body columns declared as? Link to comment Share on other sites More sharing options...
Alfraganus Posted December 22, 2015 Author Share Posted December 22, 2015 both of them declared as "text", but later I changed them to "longtext", but it is not working Link to comment Share on other sites More sharing options...
john_jack Posted December 23, 2015 Share Posted December 23, 2015 i suppose you are typing html in the the text fileds : $title=$_POST['title']; $body=$_POST['body']; use this instead to avoid errors even thoe you didnt mention an error ! $title=addslashes($_POST['title']); $body=addslashes($_POST['body']); as for the large size post problem try one of these 2 solutions 1) go to php.ini post_max_size=20Mupload_max_filesize=20M 2) use an .htaccess / httpd.conf / virtualhost include php_value post_max_size 20Mphp_value upload_max_filesize 20M 1 Link to comment Share on other sites More sharing options...
dsonesuk Posted December 23, 2015 Share Posted December 23, 2015 You do realise you are using accept attribute which apparently is not supported in html5 http://www.w3schools.com/tags/tag_form.asp anyway, instead of action attribute. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now