0
<?php 
require_once('upper.php');
if(isset($_POST['submit']))
{
//This is code in which we can choose the type and size file uploaded or upload anything. We can declare the path of folder or can do without it.
if($_FILES['uploaded_file']['size']< 200000)
{
/*if($_FILES['uploaded_file']['error']>0)
{
echo "Error occurs".$_FILES['up_test']['error']."<br/>";
}
else{*/
$Title=$_POST['Title'];
$City=$_POST['City'];
$Content=$_POST['Content'];
$Date=$_POST['Date'];
echo "Uploaded Title--$Title<br/>";
echo "Uploaded City--$City<br/>";
echo "Uploaded Content--$Content<br/>";
echo "Uploaded Date of Event--$Date<br/>";

/*if(file_exists("upload/". $_FILES['uploaded_file']['name']))
{
echo "File".$_FILES['uploaded_file']['name']." already exists";
}
else
{*/
move_uploaded_file($_FILES['uploaded_file']['tmp_name'],"upload/".$_FILES['uploaded_file']['name']);
echo "File uploaded-- ".$_FILES['uploaded_file']['name']."<br><br><br>";
}
else{
echo "File size is too large or Not Uploaded ";
}
$path="upload/".$_FILES['uploaded_file']['name'];
require_once('database.php');
$result=mysqli_query($dbc,"insert into events (Title,City,Content,Photo,Date) values ('$Title','$City','$Content','$path','$Date')") or die ('Not Connected Events');
//echo "PAth";
}
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"
enctype="multipart/form-data">
<h4>Enter Events</h4><br>
Enter Title <br><textarea rows="10" cols="10" name="Title"></textarea><br>
Enter City <br><input type="text" name="City"><br>
Enter Content <br><textarea rows="10" cols="10" name="Content"></textarea><br>
<label for="file">Upload Photo<br></label>
<input type="file" name="uploaded_file"  /> 
<br />
Enter Date of Event<br> <input type="text" name="Date" value="yyyy-mm-dd"><br>
<input type="submit" name="submit" value="Upload" />
</form>
<?php require_once('lower.php');?>

</body>
</html>

Hi friends...............
In above code when i upload title or content within range of 20 words it works properly but when I increase numbers of words till approx. 100 words. It gives an error "Not Connected Events". Not any file is uploaded in database.
I set the length of title and content in phpmyadmin is 500 and 1000 and type is varchar respectively.
I can't understand where is problem????????
I think it's about something size???????
Help me Anyone???????????????

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by madCoder
0

You can identify exact mysql error by using below code.

$result=mysqli_query($dbc,"insert into events (Title,City,Content,Photo,Date) values ('$Title','$City','$Content','$path','$Date')") or die(mysql_error());

Exact error will guide you.

0

You can identify exact mysql error by using below code.

$result=mysqli_query($dbc,"insert into events (Title,City,Content,Photo,Date) values ('$Title','$City','$Content','$path','$Date')") or die(mysql_error());

Exact error will guide you.

On calling die(mysli_error()) in place of "Not Connected". I got this error "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near _______"
Now I don't know what I should do??????
Help plz...............

0

You are getting a syntax error in the query. Echo the query out so you can see what it contains.

Also, you must scrub information being put into the database. Some characters need 'escaping' or you will either get a syntax error or you risk exposing your database to a SQL Injection.

<?php
// ...
$query = sprintf("insert into events (Title,City,Content,Photo,Date) 
  values (\n'%1s',\n'%2s',\n'%3s',\n'%4s',\n'%5s')",
  mysql_real_escape_string ($Title),
  mysql_real_escape_string ($City),
  mysql_real_escape_string ($Content),
  mysql_real_escape_string ($path),
  mysql_real_escape_string ($Date)
  );
 
 echo "<pre>$query</pre>";  // For debugging only.  @todo remove this when working...
  
$result=mysqli_query($dbc,$query) or die(mysql_error());
//...
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.