@WyPe

Перестал работать код?

Всё работало, поменял пару ссылок, ничего фундаментально в коде не менял, начал выдавать :
Warning: extract() expects parameter 1 to be array, boolean given on line 13

<?php

	error_reporting( ~E_NOTICE );
	
	require_once 'dbconfig.php';
	
	if(isset($_GET['edit_id']) && !empty($_GET['edit_id']))
	{
		$id = $_GET['edit_id'];
		$stmt_edit = $DB_con->prepare('SELECT name, name_ru, description, description_ru, price, image FROM colianuri WHERE id =:uid');
		$stmt_edit->execute(array(':uid'=>$id));
		$edit_row = $stmt_edit->fetch(PDO::FETCH_ASSOC);
		extract($edit_row);
	}
	else
	{
		header("Location: admin.php");
	}
	
	
	
	if(isset($_POST['btn_save_updates']))
	{
		$name = $_POST['name'];// name
		$name_ru = $_POST['name_ru'];// name
		$description = $_POST['description'];// description
		$description_ru = $_POST['description_ru'];// description
        $price = $_POST['price'];// price		
		
		$imgFile = $_FILES['image']['name'];
		$tmp_dir = $_FILES['image']['tmp_name'];
		$imgSize = $_FILES['image']['size'];
					
		if($imgFile)
		{
			$upload_dir = '../Flip_turn/image/'; // upload directory	
			$imgExt = strtolower(pathinfo($imgFile,PATHINFO_EXTENSION)); // get image extension
			$valid_extensions = array('jpeg', 'jpg', 'png', 'gif'); // valid extensions
			$image = rand(1000,1000000).".".$imgExt;
			if(in_array($imgExt, $valid_extensions))
			{			
				if($imgSize < 5000000)
				{
					unlink($upload_dir.$edit_row['image']);
					move_uploaded_file($tmp_dir,$upload_dir.$image);
				}
				else
				{
					$errMSG = "Sorry, your file is too large it should be less then 5MB";
				}
			}
			else
			{
				$errMSG = "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";		
			}	
		}
		else
		{
			// if no image selected the old image remain as it is.
			$userpic = $edit_row['image']; // old image from database
		}	
						
		
		// if no error occured, continue ....
		if(!isset($errMSG))
		{
			$stmt = $DB_con->prepare('UPDATE colianuri 
									     SET name=:uname, 
										     name_ru=:uname_ru,
										     description=:ujob,
                                             description_ru=:ujob_ru,
                                             price=:uprice,											 
										     image=:upic 
								       WHERE ID=:uid');
			$stmt->bindParam(':uname',$name);
			$stmt->bindParam(':uname_ru',$name_ru);
			$stmt->bindParam(':ujob',$description);
			$stmt->bindParam(':ujob_ru',$description_ru);
			$stmt->bindParam(':uprice',$price);
			$stmt->bindParam(':upic',$image);
			$stmt->bindParam(':uid',$id);
				
			if($stmt->execute()){
				?>
                <script>
				alert('Successfully Updated ...');
				window.location.href='admin.php';
				</script>
                <?php
			}
			else{
				$errMSG = "Sorry Data Could Not Updated !";
			}
		
		}
		
						
	}
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Adminca</title>

<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css">

<!-- custom stylesheet -->
<link rel="stylesheet" href="style.css">

<!-- Latest compiled and minified JavaScript -->
<script src="bootstrap/js/bootstrap.min.js"></script>

<script src="jquery-1.11.3-jquery.min.js"></script>
</head>
<body>

<div class="navbar navbar-default navbar-static-top" role="navigation">
    <div class="container">
 
        <div class="navbar-header">
            <a class="navbar-brand" href="http://www.codingcage.com" title='Programming Blog'>Coding Cage</a>
            <a class="navbar-brand" href="http://www.codingcage.com/search/label/CRUD">CRUD</a>
            <a class="navbar-brand" href="http://www.codingcage.com/search/label/PDO">PDO</a>
            <a class="navbar-brand" href="http://www.codingcage.com/search/label/jQuery">jQuery</a>
        </div>
 
    </div>
</div>


<div class="container">


	<div class="page-header">
    	<h1 class="h2">update product. <a class="btn btn-default" href="admin.php"> see all </a></h1>
    </div>

<div class="clearfix"></div>

<form method="post" enctype="multipart/form-data" class="form-horizontal">
	
    
    <?php
	if(isset($errMSG)){
		?>
        <div class="alert alert-danger">
          <span class="glyphicon glyphicon-info-sign"></span> &nbsp; <?php echo $errMSG; ?>
        </div>
        <?php
	}
	?>
   
    
	<table class="table table-bordered table-responsive">
	
    <tr>
    	<td><label class="control-label">Name RO.</label></td>
        <td><input class="form-control" type="text" name="name" value="<?php echo $name; ?>" required /></td>
    </tr>
    
	    <tr>
    	<td><label class="control-label">Name RU.</label></td>
        <td><input class="form-control" type="text" name="name_ru" value="<?php echo $name_ru; ?>" required /></td>
    </tr>
	
    <tr>
    	<td><label class="control-label">Descriptie RO.</label></td>
        <td><input class="form-control" type="text" name="description" value="<?php echo $description; ?>" required /></td>
    </tr>
    
	 <tr>
    	<td><label class="control-label">Descriptie RU.</label></td>
        <td><input class="form-control" type="text" name="description_ru" value="<?php echo $description_ru; ?>" required /></td>
    </tr>
	
	<tr>
    	<td><label class="control-label">Price.</label></td>
        <td><input class="form-control" type="text" name="price" value="<?php echo $price; ?>" required /></td>
    </tr>
	
    <tr>
    	<td><label class="control-label">Photo.</label></td>
        <td>
        	<p><img src="../Flip_turn/image/<?php echo $image; ?>" height="150" width="150" /></p>
        	<input class="input-group" type="file" name="image" accept="../Flip_turn/image/*" />
        </td>
    </tr>
    
    <tr>
        <td colspan="2"><button type="submit" name="btn_save_updates" class="btn btn-default">
        <span class="glyphicon glyphicon-save"></span> Update
        </button>
        
        <a class="btn btn-default" href="admin.php"> <span class="glyphicon glyphicon-backward"></span> cancel </a>
        
        </td>
    </tr>
    
    </table>
    
</form>


<div class="alert alert-info">
    <strong>404</strong> <a href="404.html">Error Page</a>!
</div>

</div>
</body>
</html>


Не вижу где бяда. Помогите пжлста.
  • Вопрос задан
  • 283 просмотра
Пригласить эксперта
Ответы на вопрос 2
@entermix
Не вижу где бяда. Помогите пжлста.

Вот здесь:
Warning: extract() expects parameter 1 to be array, boolean given on line 13


https://translate.google.com/#en/ru/Warning%3A%20e...

Проверьте $edit_row
Ответ написан
kimono
@kimono
Web developer
$edit_row видимо не массив. Точнее ваш SQL-запрос не выдает данных.
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы