PHP - Problem Calling Header.php.
Similar TutorialsHi, Using arabic characters, I have a project, in the admin panel, where i am trying to change the value in the text box(ajax) on onblur js function. Firefox simply working great but i am getting square brackets in the text box in the browser ie. I simply guessing the value from the text box is not in the form of utf-8 encoding, i am calling the external javascript file, this is the code am using.. Code: [Select] // JavaScript Document var xmlhttp; //function namechange(name_fieldvalue) function namechange(name_fieldvalue,name_fieldname,id_val,id_fieldname,table_name) { /* alert(name_fieldvalue); alert(name_fieldname); alert(id_val); alert(id_fieldname); alert(table_name); */ if (name_fieldvalue.length==0) { document.getElementById("txtHint").innerHTML=""; return; } xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Your browser does not support XMLHTTP!"); return; } var url="ajax_namechange.php"; url=url+"?name_fieldvalue="+name_fieldvalue; url=url+"&name_fieldname="+name_fieldname; url=url+"&id_val="+id_val; url=url+"&id_fieldname="+id_fieldname; url=url+"&table_name="+table_name; xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); } function stateChanged() { if (xmlhttp.readyState==4) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } Anyone has the idea on this, please help me. Thanks, Hi, I'm using an EPP for boring stuff that wont interest you guys anyway. The problem I'm having is the EPP comes with its own API which parses XML for you. The problem with it parsing XML is that the XML that is received comes in a format which has :'s in the keys. Example: Code: [Select] SidnEppResult Object ( [message:SidnEppResult:private] => [status:SidnEppResult:private] => domain_unavailable [code:SidnEppResult:private] => [notifyUser:SidnEppResult:private] => ) Then I want to be able to put this information to use, so I call the constants like this: Code: (php) [Select] <?php echo $object->status:SidnEppResult:private; The problem then is that PHP throws me a little parse error. Any help is appreciated, Chris I've got this sign in code: Code: [Select] [php] <?php include("conf.inc.php"); // Includes the db and form info. if ($_SESSION['logged'] == 1) { // User is already logged in. $_SESSION['email'] = $email; header("Location: main.php"); // Goes to main page. exit(); // Stops the rest of the script. } else { if (!isset($_POST['submit'])) { // If the form HAS NOT been submitted. echo "<td width=\"320\" height=\"50\" align=\"left\" valign=\"middle\"> </td>"; echo "<td width=\"360\" height=\"50\" align=\"left\" valign=\"middle\">"; echo "<form name=\"form\" action=\"index.php\" method=\"POST\" style=\"margin-bottom:0;\">"; echo "<a href=\"signup.php\" class=\"bluelink\">Sign Me Up!</a> "; echo "<a href=\"pwordhelp.php\" class=\"bluelink\" onMouseOver=\"window.name = 'main'\" onClick=\"return popup(this, 'notes')\">Forgot Password</a><br>"; echo "<input type=\"text\" name=\"email\" size=\"17\" value=\"Email...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Email...') {this.value=''; this.style.color='#000000'}\"> "; echo "<input type=\"password\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000';}\"> "; echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">"; echo "</form>"; } else { // If the form HAS been submitted $email = form($_POST['email']); $pword = md5($_POST['pword']); // Encrypts the password. $q = mysql_query("SELECT * FROM `signin` WHERE email = '$email' AND pword = '$pword'") or die (mysql_error()); // mySQL query $r = mysql_num_rows($q); // Checks to see if anything is in the db. if (!$r) { // There is nothing in the db. The username/password do not match up. echo "<td width=\"108\" height=\"50\" align=\"left\" valign=\"middle\"> </td>"; echo "<td width=\"572\" height=\"50\" align=\"left\" valign=\"middle\">"; echo "<form name=\"form\" action=\"index.php\" method=\"POST\" style=\"margin-bottom:0;\">"; echo " <a href=\"signup.php\" class=\"bluelink\">Sign Me Up!</a> "; echo "<a href=\"pwordhelp.php\" class=\"bluelink\" onClick=\"return popup(this, 'notes')\">Forgot Password</a><br>"; echo "<font color=\"#FF0000\"><strong>Incorrect Email or Password.</strong></font> "; echo "<input type=\"text\" name=\"email\" size=\"17\" value=\"Email...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Email...') {this.value=''; this.style.color='#000000'}\"> "; echo "<input type=\"password\" name=\"pword\" size=\"17\" value=\"Password...\" style=\"color: #999999\" onfocus=\"if (this.value == 'Password...') {this.value=''; this.style.color='#000000';}\"> "; echo "<input type=\"submit\" name=\"submit\" value=\"Submit\">"; echo "</form>"; } else { // If the username/password is invalid $_SESSION['logged'] = 1; // Sets the session. $_SESSION['email'] = $email; header("Location: main.php"); // THIS IS LINE 111 exit(); // Stops the rest of the script. } } } ?> [/php] And when I sign in with my user name and password, I get this warning message: Warning: Cannot modify header information - headers already sent by (output started at /home/content/29/6879529/html/calhoun/index.php:9) in /home/content/29/6879529/html/calhoun/head1.inc.php on line 111 Can anyone help me out and tell me what I need to do to correct this? Thanks in advance for your help! the page below worked until i added the php include part to the top of the page and now i get the header error message for some of my web pages but i have fixed them all but this one. How do i fix this because i can't move them to the top of the page just under the php include like i needed to do with the other pages because if i move them up it will put the forms at the top aswell. <?php include("protect page file location"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Dvds</title> <link href="../../style.css" rel="stylesheet" type="text/css" /> </head> <link href="uploadify/uploadify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="uploadify/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="uploadify/swfobject.js"></script> <script type="text/javascript" src="uploadify/jquery.uploadify.v2.1.4.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#file_upload').uploadify({ 'uploader' : 'uploadify/uploadify.swf', 'script' : 'uploadify/uploadify.php', 'cancelImg' : 'uploadify/cancel.png', 'folder' : '../../dvds/dvd_files', 'displayData' : 'percentage', 'auto' : true, 'multi' : true }); }); </script> <body> <div class="container"> <div class="header"><br /><br /><br /> </div> <div class="sidebar1"> <ul class="nav"><b> <li><a href="../../">Home</a></li> <li><a href="../">Testimonials upload</a></li> <li><a href="../audio/">Audio Testimonials upload</a></li> <li><a href="../dvds/">Dvd's upload</a></li> <li><a href="../newsletter/">Newsletter upload</a></li> <li><a href="../news/">News box update</a></li> <li><a href="http://www.weblink.co.cc/admin/?logout=1">Logout</a></li> </b></ul></div> <div class="content"><div class="text"> <center><h3>Admin</h3> <br /> <p><input id="file_upload" name="file_upload" type="file" /></p></center> <center><p><form method="get" action="index.php"> <select name="id" class="inputstandard"> <option value="default">Select Dvd</option><?php include("dbinfo1.inc.php"); mysql_connect($localhost,$username,$password); mysql_select_db($database) or die( "Unable to select database"); $result = mysql_query('SELECT * FROM Dvd ORDER BY id ASC') or die (mysql_error()); while ($row = mysql_fetch_assoc($result)) { echo '<option value="' . $row['id'] . '" name="' . $row['id']. '">Dvd ' . $row['id']. '</option>'; } ?> </select> <input type="submit" value="Submit"> </form></p> <p><?php include("dbinfo1.inc.php"); $link=mysql_connect($localhost,$username,$password); mysql_select_db($database) or die("unable to connect"); $file = $_GET["id"]; $result=mysql_query("SELECT * FROM Dvd where id='$file'") or die("ERROR:".mysql_error()); $row=mysql_fetch_array($result,MYSQL_ASSOC); print '<form method="POST" action="insert_dvd.php">'; print '<table border="0">'; print '<tr>'; print '<td><input type="hidden" name="id" value="'.$file.'"></td>'; print '</tr>'; print '<tr>'; print '<td align="right">Dvd Name:</td>'; print '<td><input type="text" name="Watch" value="'.$row['Watch'].'" /></td>'; print '</tr>'; print '<td colspan="2" align="center"><input type="submit" name="submit" value="Update"></td>'; print '</tr>'; print '</table>'; print '</form>'; mysql_close($link); ?><br /><?php include("dbinfo1.inc.php"); $link=mysql_connect($localhost,$username,$password); mysql_select_db($database) or die("unable to connect"); $file = $_GET["id"]; $result=mysql_query("SELECT * FROM Dvd where id='$file'") or die("ERROR:".mysql_error()); $row=mysql_fetch_array($result,MYSQL_ASSOC); print '<form method="GET" action="delete.php">'; print '<table border="0">'; print '<tr>'; print '<td><input type="hidden" name="id" value="'.$file.'"></td>'; print '</tr>'; print '<tr>'; print '<td align="right">Dvd Name:</td>'; print '<td><input type="text" name="Watch" value="'.$row['Watch'].'.wmv" /></td>'; print '</tr>'; print '<td colspan="2" align="center"><input type="submit" name="submit" value="Delete"></td>'; print '</tr>'; print '</table>'; print '</form>'; mysql_close($link); ?> </p></center></div> </div> <div class="sidebar2"> <center><h4>Help</h4></center> <p>text here</p> </div> <div class="footer"> <center><p>&#169; Copyright 2010</p></center> </div> </div> </body> </html> the below are the php parts causing the problems. <?php include("dbinfo1.inc.php"); $link=mysql_connect($localhost,$username,$password); mysql_select_db($database) or die("unable to connect"); $file = $_GET["id"]; $result=mysql_query("SELECT * FROM Dvd where id='$file'") or die("ERROR:".mysql_error()); $row=mysql_fetch_array($result,MYSQL_ASSOC); print '<form method="POST" action="insert_dvd.php">'; print '<table border="0">'; print '<tr>'; print '<td><input type="hidden" name="id" value="'.$file.'"></td>'; print '</tr>'; print '<tr>'; print '<td align="right">Dvd Name:</td>'; print '<td><input type="text" name="Watch" value="'.$row['Watch'].'" /></td>'; print '</tr>'; print '<td colspan="2" align="center"><input type="submit" name="submit" value="Update"></td>'; print '</tr>'; print '</table>'; print '</form>'; mysql_close($link); ?> <br /> <?php include("dbinfo1.inc.php"); $link=mysql_connect($localhost,$username,$password); mysql_select_db($database) or die("unable to connect"); $file = $_GET["id"]; $result=mysql_query("SELECT * FROM Dvd where id='$file'") or die("ERROR:".mysql_error()); $row=mysql_fetch_array($result,MYSQL_ASSOC); print '<form method="GET" action="delete.php">'; print '<table border="0">'; print '<tr>'; print '<td><input type="hidden" name="id" value="'.$file.'"></td>'; print '</tr>'; print '<tr>'; print '<td align="right">Dvd Name:</td>'; print '<td><input type="text" name="Watch" value="'.$row['Watch'].'.wmv" /></td>'; print '</tr>'; print '<td colspan="2" align="center"><input type="submit" name="submit" value="Delete"></td>'; print '</tr>'; print '</table>'; print '</form>'; mysql_close($link); ?> Hi guys, I've got a header problem. I've read the header sticky post but i'm still not getting anywhere. I am currently working on a registration form which loops though checking the data entered meets certain criteria by calling various functions (min length, max length, preg match, etc...), if anything returns 'false' then the form is reproduced with the error message of why it failed and what needs to be changed. If everything returned is 'true' then all day matches what is expected and the code then runs an 'insert' command. If the insert is successful then the code should forward the user to a new page displaying 'registration complete'. However, the way I have written my code I am finding it near impossible to get the forward to be before anything is output to the browser therefore causing the header error. I have tried moving things around but i'm having no luck. The error I am getting is: Warning: Cannot modify header information - headers already sent by (output started at /websites/blahblahblah/register.php:6) in /websites/blahblahblah/register.php on line 77 The code there is relevant though as it is the code that make the connection to my DB. Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php // *** Connection - START *** // connect to database $connect = @mysql_connect("test", "test", "test") or die(mysql_error()); if (!$connect) { do_error("Could not connect to the server"); } @mysql_select_db("test_db",$connect)or do_error("Could not connect to the database"); // *** Connection - END *** // This file includes all of the check functions for the code to run through include("check.php"); if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) { $data= new check($_POST); $data->name('forename'); $data->name('surname'); if ( $data->pass == true ) { // Now we have the required data in the correct format do the code required to complete registration $forename=$data->input['forename']; $surname=$data->input['surname']; $query="INSERT INTO users ( forename, surname ) VALUES ('$forename' , '$surname' )"; if (mysql_query($query,$connect)) { //echo "success"; // once data is inserted, go to complete page header ("location: complete.php"); exit; } else { echo "Error: Please try again."; } } } else { $data= new check(); } ?> What am I actually doing wrong and how can i possibly get the insert script higher up the code?? Thanks Hello! My server hosting company has updated PHP from 4 to 5 version, and now the header function doesn't work very well anymore. It does load the new page everytime, like it should, but the data is not always refreshed. Not until I click "reload current page" from the browser. I'm using Firefox 3.6.3. Here's the code which worked just fine few days ago: Code: [Select] $url="thepage.php"; header("Location: ".$url); die(); I tried something like this, but that doesn't work either: Code: [Select] $url="thepage.php"; header("Refresh: 0; url=".$url); die(); This is really nasty problem... How can I fix it? Hi! I'm not a very experienced PHPer. I keep getting this error... Warning: Cannot modify header information - headers already sent by (output started at /home/content/j/2/6/j26183102/html/referral.php:11) in /home/content/j/2/6/j26183102/html/referral.php on line 295 Any suggestions? It works on one server but not my customers godaddy hosting site. What im trying to do is have the webpage forward the user to another page after they fill out something for a certain element in the database. But the once I put the variable into a header for forwarding, the variable is thought to be a string instead of outputting its value it holds. Heres my code.... $variable = "nextPage"; header('Location:webpage.php?id=$variable'); But whats its doing is sending the user to the url "webpage.php?id=$variable" instead of "webpage.php?id=nextPage" What can I do to get the header to read the variable value and not the variable name? All help is greatly appreciated!!! My session start is in my session object and I include it at the top of my page prior my html code, yet I still get this warning: Code: [Select] Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Users/Sites/writepaps/index.php:2) in /Users/Sites/writepaps/includes/functions/sessions.php on line 11 I include the object in index line 2. and line 11 is where my session start is in my construct function <?php require_once("database.php"); require_once("user.php"); class Sessions { public $logged_in = false; protected $username; protected $password; function __construct(){ session_start(); $this->check_login(); } .... Why is this happening? Problem with this header. $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "From: $to\r\n" . "Reply-To: $email\r\n" . "X-Mailer: PHP/" . phpversion(); $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $body = "<html><body>".$table."</body></html>"; Can anyone tell me why? Hi all, I am trying to send an image through header so I have two php files: test0.php Code: [Select] <html> <head> </head> <body> <?php $imagename='test.php'; ?> <img src="<?php echo $imagename; ?>"/> </body> </html> and test.php: Code: [Select] <html> <html> <head> </hesd> <body> <?php $image = imagecreatefromjpeg('images/1.jpg'); header('Content-Type: image/jpeg'); imagejpeg($image, '', 100); ?> </body> </html> but the image doesn't show . What is the correct way? Thank you in advance.
My script has 3 classes (that are relevant to this discussion): DB, User and Validate. They are all in independent files and loaded automatically, when required, by an autoloader.
The error messages I am getting a Any pointers as to what I am doing wrong, or what I should be doing, would be most welcome. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=350027.0 Hello everyone, I'm just starting out with PHP as I need to create an online bookstore for a school project. I'm working by a magazine which should teach you exactly how to do this using PHP, but I've had a bunch of problems with the code they use and I don't really know what's going on. Anyway, this looks really simple and basically what it does is allows you to post a comment on a book, then returns you to the book's page. Problem is, I'm getting the Header may not contain more than a single header, new line detected. error and I can't figure out why. I've tried researching into the matter but all the cases I found had to do with returning to an url, which is not my case. Anyway, here's the snippet of code: The form: Code: [Select] <div style="width:400px; border:1px solid #ffffff; background-color:#F9F1E7; padding:5px"> <b>Adauga opinia ta:</b> <hr size="1"> <form action="adauga_comentariu.php" method="POST"> Nume: <input type="text" name="nume_utilizator"><br><br> Email: <input type="text" name="adresa_email"><br><br> Comentariu: <br> <textarea name="comentariu" cols="45"></textarea><br><br> <input type="hidden" name="id_carte" value="<?=id_carte?>"> <center><input type="submit" value="Adauga"</center> </form> </div> The script adaugare_comentariu.php: Code: [Select] <?php ob_start(); include("conectare.php"); $numeFaraTags=strip_tags($_POST['nume_utilizator']); $emailFaraTags=strip_tags($_POST['adresa_email']); $comentariuFaraTags=strip_tags($_POST['comentariu']); $sql="insert into comentarii (id_carte, nume_utilizator, adresa_email, comentariu) values(".$_POST['id_carte'].", '".$numeFaraTags."','".$emailFaraTags."','".$comentariuFaraTags."')"; mysql_query($sql); $inapoi="carte.php?id_carte=".$_POST['id_carte']; header("location:urldecode($inapoi)"); ob_end_flush(); ?> conectare.php connects to the mysql database. $inapoi is the variable which returns the user to carte.php (the book he posted a comment on), where id_carte is the book's unique id. I'm getting Header may not contain more than a single header, new line detected on line ten, which is the header line. Can anyone help me? I've been stumped on this for a few days now and I've just let it pass and started working on other bits, but it's bugging me too much and I'd like to fix it. Hello, I am having some issues with a project I am working on. I am calling a php file on another server using Code: [Select] <script type="text/javascript" src="http://www.website.com/test/file.php"></script> I have the correct type header in my php file and the php outputs JS. example Code: [Select] echo "document.write(\"some stuff\");"; that kind of thing happens alot I also have it outputting a few JS functions, example Code: [Select] echo 'function dostuff(){ stuff }'; the problem I am having is when I add the JS call to the page that calls the php it does nothing I am using document.ready I am not really sure where to go from here, I know php well enough to do anything I need but I do not know JS at all I can not post the actual source code, I know that would be much easier to troubleshoot this but this is something I just can not do. Also this needs to be done this way, I need to call to php files on another server so they can do some stuff and then use JS to change some things on another page on another server. This is a content locker, a lot like CPALead and things like that. What am I missing? Any help is greatly appreciated I am trying to call a javascript function from a php script. This is the approach I'm using. I have an alert in the function, just to confirm the function executes. Code: [Select] echo "<script type='text/javascript' src='http://localhost/Project/JScript/File.js'>"; echo "<script type='text/javascript'>functionName();</script>"; Is this the correct approach? How can i call a specific row when ever a like. example : Code: [Select] $record = mysql_query("select * from table_name"); ($getValue= mysql_fetch_row($record) //i'm not sure what should i use. should i use mysql_fetch_array, mysql_ fetch_ assoc, mysql_ fetch_ object, mysql_ field_ name and etc. print $getValue[$column_name][0]; 0 = value 1st row in the database/table_name 1 = value 2nd row in the database/table_name 2 = value 3rd row in the database/table_name ...... .... ...... ..... etc. is there a code i can do except from using sql_fetch_array then loop and put in into a multidimensional array? This is probably a quick one. I am pretty new to OOP, in fact somewhat a novice. I am working a lot more with objects lately as my previous "flat" php experience doesn't allow me to create clean and expandable applications. Of course though, questions will always pop up (that's what you guys are for?) One concept I am having trouble understanding, is the method to call a class. What is the difference between?: Code: [Select] <?php $cat = new class(); ?> and just simply: Code: [Select] <?php new class(); ?> Both appear to have the same output from my small amount of practice, but the first way seems strange to me. Being that I am very new to OO PHP, the first way looks like it is just defining a var. But in reality it is calling the class and running it? This seems very backwards to me and I am having a hell of a time understanding it. I am aware that the first way seems to be the "proper" way, but just can't fathom it. Could someone explain this to me a little further? thanks much, I define a Javascript in the <head> section of a .php file and call it from the <body> section with the following: echo "<script language='javascript'>function();</script>". The function displays a confirm box with the normal Cancel and OK buttons just fine, but I want to capture the function return of true or false for which button was selected. So far I haven't found a way to get return a value from the function. Any ideas??? i have a constructor Quote public function __construct(){ // check if any action related to this page was generated if(isset($_GET['action'])){ $this->action = ucwords($_GET['action']) . '()'; self::{$this->maction}; } //code to generate the list of all the systems users $user = new userDAO; $this->results = $user->fetchAll(); } if action is present in the querystring, eg. delete, it would be stored into $this->action as Delete(). Similarly, if the action was edit, it would be stored as Edit(). My intent is to call the method named Delete() or Edit() depending upon which action was generated. I have defined the methods in the same class. Once i assign the current action to the $this->action, i want to call the method without explicitly specifying the method name.... here i have tried self::$this->action.... i even tried $this->action only but its not working? i think the string stored in the self::$this->action is not being interpolated? or....sth. i dont know. pls help out guys |