Saturday, November 17, 2012

html – php function display an empty page instead of the result

In order to separate my html displaying and the treatment PHP, I decided to make functions that I will include on my own library.


For the first page Ive done a function but instead of returning to me something good, it display to me a white pages;


Here is my code:



<?php

/**
* FONCTION DE CREATION DES ANNONCES (page add-annonce.php)
*/
function addAnnonce($session) {
$sql = \"SELECT `nom`,`prenom`,`type` FROM `gestionnaire` WHERE `id`=\'{$session}\'\";
$result = mysql_query($sql);
$donnees = mysql_fetch_assoc($result);
return $donnees;
}

function saveAnnonce($form, $annonce, $to) {
if (isset($form)) {
$donnees = addAnnonce($_SESSION[\'id\']);
$by = $donnees[\'nom\'] . \' \' . $donnees[\'prenom\'];
$sql = \"INSERT INTO `cometchat_announcements` SET
`announcement` =\'\" . mysql_real_escape_string($annonce) . \"\',
`by` =\'\" . mysql_real_escape_string($by) . \"\',
`time` =\'\" . mysql_real_escape_string(time()) . \"\',
`to` =\'\" . mysql_real_escape_string($to) . \"\'\";
mysql_query($sql);
echo \"<div class=\\\"success\\\">L\'annoncea bien été ajoutée , vous pouvez continuer vos actions<br>La mise à jour interviendra après actualisation</div>\";
echo \"<SCRIPT type=\\\"text/javascript\\\">
<!--
alert(\\\"Ajout d\\\'une nouvelle annonce : Ok !\\\");
// -->
</SCRIPT> \";
}
}
isset($_POST[\'enreg\']) ? saveAnnonce($_POST[\'enreg\'], $_POST[\'annonce\'],$_POST[\'to\']) :\'\' ;

?>


I have no mistakes or error message.


Anykind of help will be much appreciated.






Rating: 4 out of 5 based on 3 ratings



The post html – php function display an empty page instead of the result appeared first on Javascript ASK.






via Javascript ASK http://javascriptask.phpfogapp.com/html-php-function-display-an-empty-page-instead-of-the-result.html

No comments:

Post a Comment