0

Hello guys ,
i am new around here.Need help with one script its for movie's web site, i need to add more than one picture in database.
The code is:

<?php 
@mysql_connect($host,$user,$password); 
@mysql_select_db($db); 
@mysql_query("SET CHARACTER SET cp1251") or die( "Не мога да избера БД"); 
if(isset($_POST['submit'])){ 
$kategoriq = htmlspecialchars($_POST['kategoriq']); 
$seriq = htmlspecialchars($_POST['seriq']); 
$nomer = htmlspecialchars($_POST['nomer']); 
$zaglaviebg = htmlspecialchars($_POST['zaglaviebg']); 
$zaglavieus = htmlspecialchars($_POST['zaglavieus']); 
$wreme = htmlspecialchars($_POST['wreme']); 
$godina = htmlspecialchars($_POST['godina']); 
$dyrjawa = htmlspecialchars($_POST['dyrjawa']); 
$rejis = htmlspecialchars($_POST['rejis']); 
$roli = htmlspecialchars($_POST['roli']); 
$link = htmlspecialchars($_POST['link']); 
$reiting = htmlspecialchars($_POST['reiting']); 
$nositel = htmlspecialchars($_POST['nositel']); 
$broinositeli = htmlspecialchars($_POST['broinositeli']); 
$rezume = htmlspecialchars($_POST['rezume']); 
$dopylnitelno = htmlspecialchars($_POST['dopylnitelno']); 
$kat1 = $_POST['1']; 
$kat2 = $_POST['2']; 
$kat3 = $_POST['3']; 
$kat4 = $_POST['4']; 
$kat5 = $_POST['5']; 
$kat6 = $_POST['6']; 
$kat7 = $_POST['7']; 
$kat8 = $_POST['8']; 
$kat9 = $_POST['9']; 
$kat10 = $_POST['10']; 
$kat11 = $_POST['11']; 
$kat12 = $_POST['12']; 
$kat13 = $_POST['13']; 
$kat14 = $_POST['14']; 
$kat15 = $_POST['15']; 
$kat16 = $_POST['16']; 
$kat17 = $_POST['17']; 
$kat18 = $_POST['18']; 
$kat19 = $_POST['19']; 
$kat20 = $_POST['20']; 
$kat21 = $_POST['21']; 
$kat22 = $_POST['22']; 
$kat23 = $_POST['23']; 
$kat24 = $_POST['24']; 
$file = $_FILES['file']['name']; 
$tmp_file = $_FILES['file']['tmp_name']; 
$size = $_FILES['file']['size']; 
$dopylnitelno1 = htmlspecialchars($dopylnitelno); 
$post_no_html = $dopylnitelno; 
$bbcode_regex = array( 
0 => '/\[b\](.+?)\[\/b\]/s', 
1 => '/\[i\](.+?)\[\/i\]/s', 
2 => '/\[u\](.+?)\[\/u\]/s', 
3 => '/\[code\](.+?)\[\/code\]/s', 
4 => '/\[url\=(.+?)\](.+?)\[\/url\]/s', 
5 => '/\[img\](.+?)\[\/img\]/s', 
6 => '/\[center\](.+?)\[\/center\]/s');
$bbcode_replace = array( 
0 => '<b>$1</b>', 
1 => '<i>$1</i>', 
2 => '<u>$1</u>', 
3 => '<table><tr><td class="dve">$1</td></tr></table>', 
4 => '<a href="$1">$2</a>', 
5 => '<img src="$1" alt="" />', 
6 => '<center>$1</center>'); 
ksort($bbcode_regex); 
ksort($bbcode_replace); 
$post_bbcode_treated = preg_replace($bbcode_regex, $bbcode_replace, $dopylnitelno1); 
$dopylnitelno = nl2br($post_bbcode_treated); 
$poster="../images/property/".basename($file);    
if(file_exists($poster)) {echo "<center>Файла съществува !<br /><br /><a href=\"../index.php\" class=\"a\">Начална страница</a></center></body></html>";exit;} 
if(empty($kategoriq) or empty($seriq) ) {echo "<center>Имате празни полета !<br /><br /><a href=\"../index.php\" class=\"a\">Начална страница</a></center></body></html>";exit;} 
if($size==0) {echo "<center>Файла е повреден !<br /><br /><a href=\"../index.php\" class=\"a\">Начална страница</a></center></body></html>";exit;} 
if($size>999999) {echo "<center>Файла е много голям !<br /><br /><a href=\"../index.php\" class=\"a\">Начална страница</a></center></body></html>";exit;} 
$extensions = array("gif","jpg","jpeg","png"); 
$extension_file = end(explode(".",$file)); 
$extension_file = strtolower($extension_file); 
if(!in_array($extension_file,$extensions)) {echo "<center>Този файл е не позволен ! Може да качвате само gif, jpg, jpeg, png !<br /><br /><a href=\"../index.php\" class=\"a\">Начална страница</a></center></body></html>";exit;} 
$upload = move_uploaded_file ($tmp_file,$poster); 
if($upload){$q = mysql_query("INSERT INTO `filmi` (`kategoriq`, `seriq`,`nomer`, `zaglaviebg`, `zaglavieus`, `poster`, `wreme`, `godina`, `dyrjawa`, `rejis`, `roli`, `link`, `reiting`, `nositel`, `broinositeli`, `rezume`, `dopylnitelno`, `c1`,`c2`, `c3`, `c4`, `c5`, `c6`,`c7`, `c8`, `c9`, `c10`, `c11`,`c12`, `c13`, `c14`, `c15`, `c16`,`c17`, `c18`, `c19`, `c20`, `c21`, `c22`, `c23`, `c24`) VALUES ('$kategoriq', '$seriq', '$nomer', '$zaglaviebg', '$zaglavieus', '$file', '$wreme', '$godina', '$dyrjawa', '$rejis', '$roli', '$link', '$reiting', '$nositel', '$broinositeli', '$rezume', '$dopylnitelno', '$kat1', '$kat2', '$kat3', '$kat4', '$kat5', '$kat6', '$kat7', '$kat8', '$kat9', '$kat10', '$kat11', '$kat12', '$kat13', '$kat14', '$kat15', '$kat16', '$kat17', '$kat18', '$kat19', '$kat20', '$kat21', '$kat22', '$kat23', '$kat24')"); 
if($q) {echo "<center>Заявката е добавена !<br /><br /><a href=\"../index.php\" class=\"a\">Начална страница</a></center></body></html>";} else{echo "<center>Имате грешка <br /><br /><a href=\"../index.php\" class=\"a\">Начална страница</a>!</center></body></html>";exit;}}}else{ 
?> 



<td>Poster</td> 
<td> 
<input name="file" type="file" size="36" /></td> 
</tr> 

the SQL is:

CREATE TABLE IF NOT EXISTS `filmi` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `kategoriq` varchar(255) COLLATE cp1251_bulgarian_ci NOT NULL DEFAULT '',
  `seriq` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `nomer` varchar(10) COLLATE cp1251_bulgarian_ci NOT NULL DEFAULT '',
  `zaglaviebg` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `zaglavieus` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `poster` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `poster2` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `poster3` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `poster4` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `wreme` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `godina` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `dyrjawa` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `rejis` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `roli` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `link` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `reiting` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `nositel` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `broinositeli` text COLLATE cp1251_bulgarian_ci NOT NULL,
  `rezume` mediumtext COLLATE cp1251_bulgarian_ci NOT NULL,
  `dopylnitelno` mediumtext COLLATE cp1251_bulgarian_ci NOT NULL,
  `c1` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c2` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c3` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c4` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c5` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c6` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c7` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c8` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c9` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c10` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c11` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c12` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c13` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c14` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c15` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c16` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c17` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c18` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c19` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c20` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c21` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c22` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c23` smallint(1) unsigned NOT NULL DEFAULT '0',
  `c24` smallint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=cp1251 COLLATE=cp1251_bulgarian_ci AUTO_INCREMENT=26 ;

Need to upload more pictures into poster2 , poster3...

I'm very grateful for the help,
Thanks

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

@appointmen

i am new around here.Need help with one script its for movie's web site, i need to add more than one picture in database.

You have to explain more clearly what you want to do. I got no idea what you are asking.

All you did is post the code without pinpointing the issue?

I mean is there an error when you modify the code or you didn't test the code at all?

0

no there is no issue with this code works fine.
i just wana know is it possible to add more than one picture ( poster ).
If i get it correctly for poster code is:

$file = $_FILES['file']['name']; 
$tmp_file = $_FILES['file']['tmp_name']; 
$size = $_FILES['file']['size']; 
$dopylnitelno1 = htmlspecialchars($dopylnitelno); 
$post_no_html = $dopylnitelno; 
$bbcode_regex = array( 
0 => '/\[b\](.+?)\[\/b\]/s', 
1 => '/\[i\](.+?)\[\/i\]/s', 
2 => '/\[u\](.+?)\[\/u\]/s', 
3 => '/\[code\](.+?)\[\/code\]/s', 
4 => '/\[url\=(.+?)\](.+?)\[\/url\]/s', 
5 => '/\[img\](.+?)\[\/img\]/s', 
6 => '/\[center\](.+?)\[\/center\]/s');
$bbcode_replace = array( 
0 => '<b>$1</b>', 
1 => '<i>$1</i>', 
2 => '<u>$1</u>', 
3 => '<table><tr><td class="dve">$1</td></tr></table>', 
4 => '<a href="$1">$2</a>', 
5 => '<img src="$1" alt="" />', 
6 => '<center>$1</center>'); 
ksort($bbcode_regex); 
ksort($bbcode_replace); 
$post_bbcode_treated = preg_replace($bbcode_regex, $bbcode_replace, $dopylnitelno1); 
$dopylnitelno = nl2br($post_bbcode_treated); 
$poster="../images/property/".basename($file);    
if(file_exists($poster)) {echo "<center>Файла съществува !<br /><br /><a href=\"../index.php\" class=\"a\">Начална страница</a></center></body></html>";exit;} 
if(empty($kategoriq) or empty($seriq) ) {echo "<center>Имате празни полета !<br /><br /><a href=\"../index.php\" class=\"a\">Начална страница</a></center></body></html>";exit;} 
if($size==0) {echo "<center>Файла е повреден !<br /><br /><a href=\"../index.php\" class=\"a\">Начална страница</a></center></body></html>";exit;} 
if($size>999999) {echo "<center>Файла е много голям !<br /><br /><a href=\"../index.php\" class=\"a\">Начална страница</a></center></body></html>";exit;} 
$extensions = array("gif","jpg","jpeg","png"); 
$extension_file = end(explode(".",$file)); 
$extension_file = strtolower($extension_file); 
if(!in_array($extension_file,$extensions)) {echo "<center>Този файл е не позволен ! Може да качвате само gif, jpg, jpeg, png !<br /><br /><a href=\"../index.php\" class=\"a\">Начална страница</a></center></body></html>";exit;} 
$upload = move_uploaded_file ($tmp_file,$poster); 
if($upload){$q = mysql_query("INSERT INTO `filmi` (`kategoriq`, `seriq`,`nomer`, `zaglaviebg`, `zaglavieus`, `poster`, `wreme`, `godina`, `dyrjawa`, `rejis`, `roli`, `link`, `reiting`, `nositel`, `broinositeli`, `rezume`, `dopylnitelno`, `c1`,`c2`, `c3`, `c4`, `c5`, `c6`,`c7`, `c8`, `c9`, `c10`, `c11`,`c12`, `c13`, `c14`, `c15`, `c16`,`c17`, `c18`, `c19`, `c20`, `c21`, `c22`, `c23`, `c24`) VALUES ('$kategoriq', '$seriq', '$nomer', '$zaglaviebg', '$zaglavieus', '$file', '$wreme', '$godina', '$dyrjawa', '$rejis', '$roli', '$link', '$reiting', '$nositel', '$broinositeli', '$rezume', '$dopylnitelno', '$kat1', '$kat2', '$kat3', '$kat4', '$kat5', '$kat6', '$kat7', '$kat8', '$kat9', '$kat10', '$kat11', '$kat12', '$kat13', '$kat14', '$kat15', '$kat16', '$kat17', '$kat18', '$kat19', '$kat20', '$kat21', '$kat22', '$kat23', '$kat24')"); 

How can i make a additional script for second poster or third ?

0

Are you sure all those fields are necessary? Could this table be split / optimized? If the numbered fields are categories, why not just have a categories atable and a movie_cat link table?

Categories

cat_id (PK)
cat_label

Movie_Cat

movie_cat_id (PK - optional)
movie_id (FK)
cat_id (FK)

Your movie table then has no categories at all to worry about. Also there is no duplication.

Edited by diafol

0

i figured out but i need picture solution :( need to add few more pictures for galery

0

@appointmen

I figured out but i need picture solution :( need to add few more pictures for galery

If you want a movie video match up with an image then you have to fetch the movie id and match it with an image.

I think what diafol mention is the best solution for you.

Edited by LastMitch: grammer

This question has already been answered. 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.