mysql - include and header function not working together in single php file -
i trying include config.php
file database after completing task , redirect other page shows error message.
"warning: cannot modify header information - headers sent (output started @ /home/prasan/public_html/theyplay.in/texttospeech/config.php:16) in /home/prasan/public_html/theyplay.in/texttospeech/input.php on line 14"
<?php include("config.php"); try { $mi = $_post['main']; $i = $_post['item']; $dbo->query("insert ld (mainitem, subitem, item,fav)values ('$mi','$i',0)") ; } catch (exception $e) { echo 'caught exception: ', $e->getmessage(), "\n"; } header("location: index.php"); ?>
edit: config.php
<?php $dbhost_name = "localhost"; $database = "rrr"; $username = "rrr"; $password = "rrr"; try { $dbo = new pdo('mysql:host=' . $dbhost_name . ';dbname=' . $database, $username, $password); } catch (pdoexception $e) { print "error!: " . $e->getmessage() . "<br/>"; die(); } ?>
header redirection place inside try. because have echo before header
function
<?php include("config.php"); try { $mi = $_post['main']; $i = $_post['item']; $dbo->query("insert ld (mainitem, subitem, item,fav)values ('$mi','$i',0)") ; header("location: index.php"); } catch (exception $e) { echo 'caught exception: ', $e->getmessage(), "\n"; } ?>
Comments
Post a Comment