Jump to content
Fórum Script Brasil

Search the Community

Showing results for tags 'uncaught'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Programação & Desenvolvimento
    • ASP
    • PHP
    • .NET
    • Java
    • C, C++
    • Delphi, Kylix
    • Lógica de Programação
    • Mobile
    • Visual Basic
    • Outras Linguagens de Programação
  • WEB
    • HTML, XHTML, CSS
    • Ajax, JavaScript, XML, DOM
    • Editores
  • Arte & Design
    • Corel Draw
    • Fireworks
    • Flash & ActionScript
    • Photoshop
    • Outros Programas de Arte e Design
  • Sistemas Operacionais
    • Microsoft Windows
    • GNU/Linux
    • Outros Sistemas Operacionais
  • Softwares, Hardwares e Redes
    • Microsoft Office
    • Softwares Livres
    • Outros Softwares
    • Hardware
    • Redes
  • Banco de Dados
    • Access
    • MySQL
    • PostgreSQL
    • SQL Server
    • Demais Bancos
  • Segurança e Malwares
    • Segurança
    • Remoção De Malwares
  • Empregos
    • Vagas Efetivas
    • Vagas para Estágios
    • Oportunidades para Freelances
  • Negócios & Oportunidades
    • Classificados & Serviços
    • Eventos
  • Geral
    • Avaliações de Trabalhos
    • Links
    • Outros Assuntos
    • Entretenimento
  • Script Brasil
    • Novidades e Anúncios Script Brasil
    • Mercado Livre / Mercado Sócios
    • Sugestões e Críticas
    • Apresentações

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Found 2 results

  1. Boa noite. Estou desenvolvendo uma aplicação em php para estudos em MVC onde tenho as seguintes classes: Index.php <?php define('APP_ROOT', 'aula'); require_once 'helper/Bootstrap.php'; use lib\System; $System = new System; $System->Run(); Bootstrap.php <?php spl_autoload_register(function($class){ $file= str_replace('\\', '/', $class); if(file_exists($file)){ require_once $file; } }); System.php <?php namespace lib; class System extends Router{ private $url; private $exploder; private $area; private $controller; private $action; private $params; private $runController; public function __construct() { $this->setUrl(); $this->setExploder(); $this->setArea(); $this->setController(); $this->setAction(); $this->setParams(); } private function setUrl(){ $this->url = isset($_GET['url']) ? $_GET['url'] : 'home/index'; } private function setExploder(){ $this->exploder = explode('/', $this->url); } private function setArea(){ foreach($this->routers as $key => $value){ if($this->onRaiz && $this->exploder[0] == $key){ $this->area = $value; $this->onRaiz = false; } } $this->area = empty($this->area) ? $this->routerOnRaiz : $this->area; if (!defined('APP_AREA')) { defined('APP_AREA', $this->area); } } public function getArea(){ return $this->area; } private function setController(){ $this->controller = $this->onRaiz ? $this->exploder[0] : (empty($this->exploder[1]) || is_null($this->exploder[1]) || !isset($this->exploder[1]) ? 'home' : $this->exploder[1]); } public function getController(){ return $this->controller; } private function setAction(){ $this->action = $this->onRaiz ? (!isset($this->exploder[1]) || is_null($this->exploder[1]) || empty($this->exploder[1]) ? 'index' : $this->exploder[1]) : (!isset($this->exploder[2]) || is_null($this->exploder[2]) || empty($this->exploder[2]) ? 'index' : $this->exploder[2]); } public function getAction(){ return $this->action; } private function setParams(){ if($this->onRaiz){ unset($this->exploder[0], $this->exploder[1]); }else{ unset($this->exploder[0], $this->exploder[1], $this->exploder[2]); }; if(end($this->exploder) == null){ array_pop($this->exploder); }; if(empty($this->exploder)){ $this->params = array(); }else{ foreach ($this->exploder as $value) { $params[] = $value; } $this->params = $params; }; } public function getParams($indice){ return isset($this->params[$indice]) ? $this->params[$indice] : null; } private function validarController(){ if(!(class_exists($this->controller))){ header('HTTP/1.00 404 Not Found'); define('ERROR', 'não foi localizado o Controller' . $this->controller); include("content/[$this->area]/shared/404_error.phtml"); }; } private function validarAction(){ if(!(method_exists($this->runController, $this->action))){ header('HTTP/1.00 404 Not Found'); define('ERROR', 'não foi localizado o Controller' . $this->action); include("content/[$this->area]/shared/404_error.phtml"); } } public function Run(){ $this->runController = 'controller\\' . $this->area . '\\' . $this->controller . 'Controller'; $this->validarController(); $this->runController = new $this->runController(); $this->validarAction(); $act = $this->action; $this->runController->act(); } } A arvore das pastas estao da seguinte maneira: Ao executar a aplicação da a seguinte mensagem: Fatal error: Uncaught Error: Class 'lib\System' not found in C:\xampp\htdocs\aula\index.php:10 Stack trace: #0 {main} thrown in C:\xampp\htdocs\aula\index.php on line 10 Fiz algumas pesquisas e muitas delas falaram que era a forma que estava "instanciando" a classe System, já tentei "use", "require_once" e "require" e com isso apenas mudou mensagem de erro, saberiam o que mais posso fazer para tentar sanar esse erro? Obs.: Na index.php quando vou dar o "new" já tentei chamar a classe com e sem parentes (new System e new System() ). Muito Obrigado....
  2. Bom dia, estou criando um CRUD e no momento de criar meu update os seguintes erros aparece index.html:22 Uncaught ReferenceError: viewData is not definedonload @ index.html:22 index.html:120 Uncaught SyntaxError: Unexpected token function E minha tabela não aparece a não ser que eu comente o formulario no documento server.php entre a linha 47 e 81 segue o codigo do meu index.html e do meu server.php INDEX.HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> <title>CRUD AJAX</title> <!-- Bootstrap --> <link href="css/bootstrap.min.css" rel="stylesheet"> <!-- Latest compiled and minified CSS --> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body onload="viewData()"> <div class="container"> <p></p> <button class="btn btn-primary" data-toggle="modal" data-target="#addData">Insert DATA</button><!-- Botão para inserir os dados--> <!-- Modal --> <div class="modal fade" id="addData" tabindex="-1" role="dialog" aria-labelledby="addLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title" id="addLabel">Insert Data</h4> </div> <form method="POST"> <!-- Começo do Formulario --> <div class="modal-body"> <div class="form-group"> <label for="nm">Full Name</label> <input type="text" class="form-control" id="nm" placeholder="NAME"> </div> <div class="form-group"> <label for="em">EMail</label> <input type="email" class="form-control" id="em" placeholder="Email"> </div> <div class="form-group"> <label for="hp">Phone Number</label> <input type="number" class="form-control" id="hp" placeholder="Phone Number"> </div> <div class="form-group"> <label for="al">Address</label> <textarea class="form-control" id="al" placeholder="Address"></textarea> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="submit" onclick="saveData()" class="btn btn-primary">Save changes</button> </div> </form><!-- Termino do Formulario--> </div> </div> </div> <div id="result"></div> <p></p> <table class="table table-bordered table-striped"> <thead> <tr> <th width="40"></th> <th>Name</th> <th>Email</th> <th>Phone</th> <th>Address</th> <th width="180">Action</th> </tr> </thead> <tbody> </tbody> </table> </div> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="js/jquery-3.1.1.min.js"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="js/bootstrap.min.js"></script> <script> /* Começo AJAX */ function saveData(){ var name = $('#nm').val(); var email = $('#em').val(); var phone = $('#hp').val(); var address = $('#al').val(); $.ajax({ type: "POST", url:"server.php?p=add", data: "nm="+name+"&em="+email+"&hp="+phone+"&al="+address, success: function(data){ viewData(); } }); } function viewData(){ $.ajax({ type: "GET", url: "server.php", success: function(data){ $('tbody').html(data); } }); } function updateData(str){ var id = str; var name = $('#nm-'+str).val(); var email = $('#em-'+str).val(); var phone = $('#hp-'+str).val(); var address = $('#al-'+str).val(); $.ajax({ type: "POST", url: "server.php?p=edit", data: "nm="+name+"&em="+email+"&hp="+phone+"&al="+address+"&id="+id, success function(data){ viewData(); } }); } </script> </body> </html> SERVER.PHP <?php $db = new PDO('mysql:host=localhost;dbname=ajaxdata', 'root', ''); $page = isset($_GET['p']) ? $_GET['p'] : ''; if ($page === 'add'){ $name = $_POST['nm']; $email = $_POST['em']; $phone = $_POST['hp']; $address = $_POST['al']; $stmt = $db->prepare("INSERT INTO crud (name, email, phone, address) VALUES (?, ?, ?, ?);"); $stmt->bindParam(1, $name); $stmt->bindParam(2, $email); $stmt->bindParam(3, $phone); $stmt->bindParam(4, $address); $status = $stmt->execute(); }else if ($page === 'edit') { $id = $_POST['id']; $name = $_POST['nm']; $email = $_POST['em']; $phone = $_POST['hp']; $address = $_POST['al']; $stmt = $db->prepare("update crud set name=?, email=?, phone=?, address=? where id=?"); $stmt->bindParam(1, $name); $stmt->bindParam(2, $email); $stmt->bindParam(3, $phone); $stmt->bindParam(4, $address); $stmt->bindParam(5, $id); $status = $stmt->execute(); }else if ($page === 'del') { # code... }else{ $stmt = $db->prepare("SELECT * from crud order by id asc"); $stmt->execute(); while($row = $stmt->fetch()){ ?> <tr> <td><?php echo $row['id'] ?></td> <td><?php echo $row['name'] ?></td> <td><?php echo $row['email'] ?></td> <td><?php echo $row['phone'] ?></td> <td><?php echo $row['address'] ?></td> <td> <button class="btn btn-warning" data-toggle="modal" data-target="#edit-<?php echo $row['id'] ?>">Edit</button> <!-- Modal --> <div class="modal fade" id="edit-<?php echo $row['id'] ?>" tabindex="-1" role="dialog" aria-labelledby="editLabel-<?php echo $row['id'] ?>"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4 class="modal-title" id="editLabel-<?php echo $row['id'] ?>">Edit Data</h4> </div> <form> <div class="modal-body"> <div class="form-group"> <label for="nm">Full Name</label> <input type="hidden" class="form-control" id="nm-<?php echo $row['id'] ?>" value="nm-<?php echo $row['name'] ?>"> </div> <div class="form-group"> <label for="em">EMail</label> <input type="email" class="form-control" id="em-<?php echo $row['emid'] ?>" value=" em-<?php echo $row['email'] ?>"> </div> <div class="form-group"> <label for="hp">Phone Number</label> <input type="number" class="form-control" id="hp-<?php echo $row['id'] ?>" value="hp-<?php echo $row['phone'] ?>"> </div> <div class="form-group"> <label for="al">Address</label> <textarea class="form-control" id="al-<?php echo $row['id'] ?>" value="al-<?php echo $row['name'] ?>"></textarea> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="submit" onclick="updateData(<?php echo row['id'] ?>)" class="btn btn-primary">Update</button> </div> </form> </div> </div> </div> <button class="btn btn-danger">Edit</button> </td> </tr> <?php } } /*else if ($page === 'select') { $_GET['id'] = filter_input(INPUT_GET, 'id', FILTER_SANITIZE_SPECIAL_CHARS); try { $stmt = $db->query("SELECT * FROM crud WHERE id = {$_GET['id']};"); if (!$stmt) throw new Exception("Não foi possível executar QUERY"); $result = $stmt->fetch(); } catch (Exception $ex) { $result = $ex->getMessage(); } } */ Att, Mateus Guedes
×
×
  • Create New...