1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

初心者にご教授願います。

Posted at

気づけばプロ並み php改訂版という本で
独学でプログラミングを勉強していて
付随しているソースコードを使っても
意味は理解できているつもりなのにうまくいかない箇所があります。

try{ (条件)
}catch{(エラーメッセージ)

の内容でエラーが出ます。
具体的なソースも下記に貼ります。

ろくまる農園 $pro_name=htmlspecialchars($pro_name,ENT_QUOTES,'UTF-8');
$pro_price=htmlspecialchars($pro_price,ENT_QUOTES,'UTF-8');

$sql='INSERT INTO mst_product(name,price) VALUES (?,?)';
$stmt=$dbh->prepare($sql);
$data[]=$pro_name;
$data[]=$pro_price;
$stmt->execute($data);

$dbh=null;

print $pro_name;
print 'を追加しました。
';

}
catch(Exception$e)
{
print'ただいま障害により大変ご迷惑をお掛けしております。';
exit();
}

?>

戻る

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?