brel Posted August 5, 2015 Share Posted August 5, 2015 (edited) Hello every body i'm a beginner in php programming, i wroth for a php code it's works into my local seveur but don't works on line i need help please: <?php if(!empty($_POST['po'])) {?> <?php $message=mysql_real_escape_string(htmlentities($_POST['message'])); $id=($_POST['id']); $chemin1=uploaderhistorique1('img1'); $chemin2=uploaderhistorique2('img2'); $chemin3=uploaderhistorique3('img3'); if($chemin1 !="erreur" AND $chemin2 !="erreur" AND $chemin3 !="erreur"){ $resultat=uphistorique($message, $chemin1, $chemin2, $chemin3, $id); header("location:listerhistorique.php?mesg=<h2 style='color:white;'>Modification effectif</h2>"); exit(); }else{header("location:uphistorique.php?id=$id&mesg=<h2 style='color:red;'>Modification non effectif</h2>"); exit(); ?> <?php }}?> Edited August 5, 2015 by brel Link to comment Share on other sites More sharing options...
Ingolme Posted August 5, 2015 Share Posted August 5, 2015 There are two things about location headers. 1. For all headers in general, they must be sent before any content is displayed. This portion of code is display a few line breaks, so the header won't work: {?><?php 2. The location header should have an absolute URL including "http:" and the full domain name Link to comment Share on other sites More sharing options...
brel Posted August 5, 2015 Author Share Posted August 5, 2015 (edited) i have all readdy done it with an absolut url with a full domaine name but it doesn't work in this case, that works in some without the url can i have an example please this is my first methode : <?php if(!empty($_POST['po'])) {?> <?php $message=mysql_real_escape_string(htmlentities($_POST['message'])); $id=($_POST['id']); $chemin1=uploaderhistorique1('img1'); $chemin2=uploaderhistorique2('img2'); $chemin3=uploaderhistorique3('img3'); if($chemin1 !="erreur" AND $chemin2 !="erreur" AND $chemin3 !="erreur"){ $resultat=uphistorique($message, $chemin1, $chemin2, $chemin3, $id); header("location:http://mydomainename.com/contentfolder/listerhistorique.php?mesg=<h2 style='color:white;'>Modification effectif</h2>"); exit(); }else{header("location:http://mydomainename.com/contentfolder/uphistorique.php?id=$id&mesg=<h2 style='color:red;'>Modification non effectif</h2>"); exit(); ?> <?php }}?> Edited August 5, 2015 by brel Link to comment Share on other sites More sharing options...
justsomeguy Posted August 5, 2015 Share Posted August 5, 2015 What exactly happens, what is the problem? In any case, add this to the top of your code while debugging: ini_set('display_errors', 1);error_reporting(E_ALL); Link to comment Share on other sites More sharing options...
Ingolme Posted August 5, 2015 Share Posted August 5, 2015 Like I mentioned earlier, you have line breaks being sent from the server. You don't really need to separate your code into multiple PHP blocks, put it all within the same <?php ?> block and make sure there are no spaces or line breaks preceding it. Link to comment Share on other sites More sharing options...
brel Posted August 5, 2015 Author Share Posted August 5, 2015 i change my code but it doesnt works any more: <?php if(!empty($_POST['po'])){ $message=mysql_real_escape_string(htmlentities($_POST['message'])); $id=($_POST['id']); $chemin1=uploaderhistorique1('img1'); $chemin2=uploaderhistorique2('img2'); $chemin3=uploaderhistorique3('img3'); if($chemin1 !="erreur" AND $chemin2 !="erreur" AND $chemin3 !="erreur"){ $resultat=uphistorique($message, $chemin1, $chemin2, $chemin3, $id); header("location:http://mydomainename.com/contentfolder/listerhistorique.php?mesg=<h2 style='color:white;'>Modification effectif</h2>"); exit(); }else{header("location:http://mydomainename.com/contentfolder/uphistorique.php?id=$id&mesg=<h2 style='color:red;'>Modification non effectif</h2>"); exit();} ?> Link to comment Share on other sites More sharing options...
justsomeguy Posted August 5, 2015 Share Posted August 5, 2015 You're not providing a lot of information to help. What does "not work" mean, what actually happens? Add that error reporting code to the top, do you see any error messages then? Link to comment Share on other sites More sharing options...
brel Posted August 6, 2015 Author Share Posted August 6, 2015 (edited) i post it like this in my page: <?php ini_set('display_errors', 1); error_reporting(E_ALL); include ("../db_conx6/db_conx6.php"); include ("root/php/include/fonc.php"); include ("adminses.php.inc"); if(!empty($_POST['po'])){ $message=mysql_real_escape_string(htmlentities($_POST['message'])); $id=($_POST['id']); $chemin1=uploaderhistorique1('img1'); $chemin2=uploaderhistorique2('img2'); $chemin3=uploaderhistorique3('img3'); if($chemin1 !="erreur" AND $chemin2 !="erreur" AND $chemin3 !="erreur"){ $resultat=uphistorique($message, $chemin1, $chemin2, $chemin3, $id); header("location:http://******/******/listerhistorique.php?mesg=<h2 style='color:white;'>Modification effectif</h2>"); }else{header("location:http://******/****/uphistorique.php?id=$id&mesg=<h2 style='color:red;'>Modification non effectif</h2>");} } ?> but nothing display, i juste got a white page nothing more, but into my error_log file on the server 'ive got this : [06-Aug-2015 11:00:27 Europe/Berlin] PHP Parse error: syntax error, unexpected '}' in /home/-----/public_html/-----/valhistorique.php on line 16, please somebody can tell me what should i do because i try to correct it but nothing change, Thanks Edited August 6, 2015 by brel Link to comment Share on other sites More sharing options...
Ingolme Posted August 6, 2015 Share Posted August 6, 2015 It looks like you have an extra closing brace at the end of your code that shouldn't be there. If your code were indented properly it would be easy to catch that. Link to comment Share on other sites More sharing options...
brel Posted August 6, 2015 Author Share Posted August 6, 2015 Ok, i'm trying to shearch for the error then i will let you know, thanks for helping.. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now