PHP - Variable In Header Problem, Need Help!
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!!! Similar TutorialsHi... I'm a little bit new to php and it seems I am getting a small issue that I am not able to resolve... Basicly I just have a page in wich you see the account file of a customer and you can add notes into it. Here's the account file script Code: [Select] <?php mysql_connect("localhost", "user", "pass") or die(mysql_error()); mysql_select_db("db") or die(mysql_error()); if( ($_GET['cmd']=="view") && (is_numeric($_GET['id'])) ) { $id=$_GET['id']; $data = mysql_query("select * from client_table WHERE id_client='$id'") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { echo " <table border=\"0\" celppadding=\"0\" cellspacing=\"0\" style=\"font-weight: bold; width: 820px;\"> <tr> <td colspan=\"2\" style=\"height: 50px;\"><a href=\"../dashboard.php\">Panneau de controle</a> > <a href=\"clients.php\">clients</a> > <a href=\"view_client.php?cmd=view&id=".$info['id_client']."\">Fiche client</a> > Notes > ".$info['entreprise']."</td> </tr> <tr> <td style=\"padding-left: 10px\"> NEQ : ".$info['neq']."<br /> <h2>Nom de l'entreprise : ".$info['entreprise']."<br /></h2> <h2>Telephone : ".$info['client_phone']."<br /></h2> </td> </tr> </table> "; } } ?> <form enctype="multipart/form-data" action="process/insert_note.php" method="POST" target="main"> <input type="hidden" name="id_client" value="<?php echo $id; ?>"> <input type="hidden" name="note_date" value="<?php echo date("Y-m-d"); ?>"> <input type="hidden" name="note_time" value="<?php echo date("G:i:s"); ?>"> <table border="0" celppadding="0" cellspacing="0" style="font-weight: bold; width: 780px;"> <tr> <td colspan="0" style="padding-left: 10px">Ajouter une note : <br /><textarea name="note" style="height: 80px;" cols="90"></textarea><br /> <input type="submit" value="Ajouter une note"> </td> </tr> </table> </form> So when I add the note....the form data is passed to a php script to insert the note into the MySQL DB and I just want to be redirected back to the acount file page with the note on it.... Here's the insert script : Code: [Select] <?php header('location:../view_notes.php?cmd=view&id=$id_client'); require_once('../../auth.php'); $id_client = $_POST['id_client']; $con = mysql_connect("localhost","user","pass"); $note_date = $_POST['note_date']; $note_time = mysql_real_escape_string($_POST['note_time']); $note = mysql_real_escape_string($_POST['note']); if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("db", $con); $sql="INSERT INTO notes_table ( id_client, note_date, note_time, note) VALUES ('$id_client','$note_date','$note_time','$note')";if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } ?> The problem I have is that the HEADER part is working but the value : header('location:../view_notes.php?cmd=view&id=$id_client'); is not passed so I am redirected to a blank page..... I tried to find the info on google but can't seems to find what wrong... Any help will be appreciated! Thanks The org variable holds the value of the folder name. The problem is that the header is sending out ".$org." and not the actual value of $org. Example output url: http://127.0.0.1/application/".$org."/display/trackingboard.php I want this url if the value is test: http://127.0.0.1/application/test/display/trackingboard.php Thanks! Code: [Select] $org = "test"; header('Location: ../application/".$org."/display/trackingboard.php'); 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); ?> 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! 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 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? 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. 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. 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. Hi guys, I have a bit of a problem, Im using php and mysql and have succeded in storing variables inside of a URL: echo "<a href='report.php?id=$varmemberid&colour=$varcolour'>test</a> "; i retrieve varmemberid and colour from the mysql database: $tbl_name = "members"; mysql_select_db($db_name) or die (mysql_error()); $query="SELECT * FROM $db_name ORDER BY `members`.`the_members` ASC"; $result=mysql_query($query); $num=mysql_numrows($result); $i=0; while ($i < $num) { $varmemberid=mysql_result($result,$i,"member_id"); $varcolour=mysql_result($result,$i,"colour"); that works all fine and dandy for numbers eg: "123" however if i go to insert a member id of "123t" i get this error: Code: [Select] Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 12 in /home/flashx/public_html/login/report-header.php on line 47 im guessing it has something to do with the 'int' in this line: $memberid = (int) $_GET['memberid']; how do i fix this? Cheers So. I wrote this class that redirects a user to a new url: Code: [Select] <?php class PotentGate{ private $endURL, $sourceURL = 'http'; private function Gate_setURL(){ //THE BLOCK BELOW WIL ULTIMATELY REFERECE A DATABASE BACKEND FOR DESTINATION URLS. if ($this->sourceURL=="http://blah.com/blah/misc.php"){$this->endURL="http://blah.com/blah/misc2.php?r=" . $this->Gate_sourceURL;} else {} } public function Gate_getURL(){ $this->Gate_sourceURL(); echo $this->sourceURL . "<br />"; $this->Gate_setURL(); //set our destination URL based on source echo $this->endURL . "<br />"; return header('Location:' . $this->endURL); //redirect } private function Gate_sourceURL() { //TODO: Fix the $_SERVER['HTTPS'] below for https:// support. //if ($_SERVER['HTTPS'] == "on") {$this->sourceURL .= "s";} $this->sourceURL .= "://"; if ($_SERVER['SERVER_PORT'] != "80") { $this->sourceURL .= $_SERVER['SERVER_NAME'].":".$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI']; } else { $this->sourceURL .= $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; } return $this->sourceURL; } }//end It is implemented as such: Code: [Select] <?php include("PotentGate.php"); $gate = new PotentGate(); $gate->Gate_getURL(); //IGNORE //function below will acquire get variable //echo "You came from:" . $gate->Gate_getReferrer(); ?> This works all well and good, as far as redirection goes, but refuses to add the $Gate_sourceURL to the end url. I am left with a url like: http://blah.com/blah/misc2.php?r= and what I am trying to achieve is that it assign $Gate_sourceURL to r (so I can use the source url as a value later on), as opposed to be being blank. ex. http://blah.com/blah/misc2.php?r=http://blah.com/blah/misc1.php Any Ideas? I'm not sure what is going on in this code, but for some reason it is not echoing my variable. I'm probably just having a total brain fart right now. Code: [Select] <?php <?php $opponent_check = isset($_POST['player_username']); $session = isset($_SESSION['user']); if($opponent_check){ include_once('connect.php'); $find_player = "SELECT * FROM stats WHERE Username = '$session'"; $s = mysql_fetch_array(mysql_query($find_player)) or trigger_error(mysql_error()); $player = $s['Username']; $player_HBS = $s['HBS']; $player_level = $s['Level']; $player_level_image = $s['Level_Image']; $player_skill = $s['Skill']; $player_attack = $s['Attack']; $player_defense = $s['Defense']; $player_strength = $s['Strength']; $player_speed = $s['Speed']; $player_accuracy = $s['Accuracy']; $player_range = $s['Range']; echo $player; }else{ echo " You didn't start a battle.<br/><br/> <a href='index.php'>Back to Matchmaking</a> <br/><br/> "; } ?> ?> My error is: Notice: in C:\xampp\htdocs\halobattles\headtohead.php on line 277 which is the fetch array line. I'm coding a google map script in php/javascript, and I'm having a hell of a time with the address. It seems to not like any spaces for what I can tell (and I'm no php programmer). Code: [Select] /* Create an array of address values */ addresses = [ <?php for($i=0; $i < count($dataArray); $i++) { $p = $dataArray[$i]; $p = explode(":", $p); $addr = $p[4]; echo "$addr,\n"; } ?> ]; Here is data file (just one line for testing): 1315414069:41.100908:-81.442699:33:150 North Ave Tallmadge OH:1 Here is "view source" from browser: /* Create an array of address values */ addresses = [ 150 North Ave Tallmadge OH, ]; I'm stumped The map will not display with this. If I change the $addr to another variable in the array, it works fine. Trying to put the address in an info window on the map. TIA, Roots I set up e-commence system for our company, there is a problem in this project. When I try to add the product in the cart, it can not do the Extended Price over one thousand dollars. If the Extended Price is lower than one thousand dollars, it is working. I do not know how to fix this problem . Please tell me , thank you very much The link is http://www.ptiimaging.ca/po.php?wd=1551 This is the code. <?php include("connection.php"); $sessid=session_id(); $select="select * from carttemp where sess= '$sessid'"; $result2=mysql_query($select, $connection) or die (mysql_error()); $rows=mysql_num_rows($result2); ?> <p align="center"> You currently have <?php echo "$rows "; ?>product(s) in your cart.</p> <br> <div class="tabbanner"><strong>View the Shopping cart </strong></div> <table class="tableinsert"> <tr> <th>Quantity</th> <th>Item Name</th> <th>Price Each</th> <th>Extended Price</th> <th></th> <th></th> <th></th> </tr> <?php while ($row=mysql_fetch_array($result2)) { extract($row); $price; $quan; $extprice=number_format($price*$quan,2); ?> <tr> <td> <form action="change1.php" method="post"> <input type="hidden" name="prodnum" value="<?php echo $row['prodnum']; ?>"/> <input type="hidden" name="sessid" value="<?php echo $row['sess']; ?>" /> <input type="hidden" name="hidden" value="<?php echo $row['hidden']; ?>"/> <input type="text" name="qty" size="5" value="<?php echo $row['quan']; ?>"/> </td> <td><?php echo $row['prodnum']; ?></td> <td><?php echo $row['price']; ?></td> <td><?php echo $extprice ; ?></td> <td> <input type="submit" name="submit" value="change Qty" /> </form> </td> <td> <form action="xid.php" method="post"> <input type="hidden" name="prodnum" value="<?php echo $row['prodnum']; ?>"/> <input type="hidden" name="sessid" value="<?php echo $row['sess']; ?>" /> <input type="hidden" name="hidden" value="<?php echo $row['hidden']; ?>" <input type="hidden" name="qty" size="2" value="<?php echo $row['quan']; ?>" /> <input type="submit" value="Delete Item" name="submit" /> </form> </td> </tr> <?php $total=$extprice+$total; }; ?> Firstly, here's the code i'm having trouble with: 'products.php': Code: [Select] <?php class product{ public $id,$brand,$partnumber,$price,$per; public function dump(){ echo "dump"; echo "<table><tr><td>$id</td><td>$brand</td><td>$partnumber</td><td>$price</td><td>$per</td></tr></table>"; } public function search($strSearch){ include ("db.php"); $query = "SELECT * FROM products WHERE partnumber=\"$strSearch\";"; $db_conn = mysql_connect($dbserver,$user,$pass); @mysql_select_db($database) or die("unable to connect to database"); $result = mysql_query($query); $num_rows = mysql_num_rows($result); if($num_rows==1){ while ($row = mysql_fetch_assoc($result)) { $id = $row["id"]; $brand = $row["brand"]; $partnumber = $row["partnumber"]; $price = $row["price"]; $per = $row["per"]; //DEBUG #1: echo "<table><tr><td>$id</td><td>$brand</td><td>$partnumber</td><td>$price</td><td>$per</td></tr></table>"; } } if($num_rows>1){ // code selection (disambiguation) here } if($num_rows<1){ // code secondary searchs here } } } ?> findprod.php: Code: [Select] <body> <form action="findprod.php" method="GET"> <input type="text" name="searchstr"> <input type="submit" value="Search"> </form> </body> <?php if(isset($_GET['searchstr'])){ $searchStr = $_GET['searchstr']; include ("products.php"); $np = new product(); $np->search($searchStr); $np->dump(); echo $np->brand; } ?> Here's my problem: after typing in a part-number to search for, I'm initializing a new 'product' class, and searching for that partnumber. I know that the query is returning 1 record just like it should. The 'DEBUG#1' line that echo's the table works just fine. The problem is, when I try to call the 'dump' method (from 'findprod.php') the variables are empty. Same thing if I try to access the variables directly. Am I doing something wrong? Perhaps I don't understand classes in PHP correctly, but it's almost as if the methods in the 'product' class aren't sharing the variables between each other. Can anyone show me what I can do to make this work? BTW: I have google'd everything I could think of for the past few days, but I just can't seem to find anything to solve this problem on my own. I've thought of possibly using SESSION variables to accomplish this task, but I'd rather not. I'm also just really curious to know why this isn't working. I'm more or less a noob. I have used the below code on another webpage, but on a new site that I am working on I attempted to trim the variable and now the page won't load. Can someone show me what I did wrong or a better way to accomplish this? Code: [Select] <?php # GRAB THE VARIABLES FROM THE URL $x = $_GET['x']; $valid = array('cat:1', 'cat:2', 'cat:3', 'cat:4', 'cat:5', 'cat:6', 'cat:7', 'cat:8', 'cat:9', 'cat:10', 'cat:11'); if(in_array($x, $valid)) $trimmed = trim($x, "cat:"); include_once $trimmed . '.inc'; else include '1.inc'; ?> When I used this before my variables did not have a colon in them, so I did not have to trim the variable, thus the last part of the script was: Code: [Select] if(in_array($x, $valid)) include_once $x . '.inc'; else include('1.inc'); ?> |