PHP - My Code Is Not Executing? Very Simple Code
Hi, this is my first time posting here.
I am just delving into PHP and I am learning about foreach loops. I have written code in Notepad++ EXACTLY the way I saw it in a tutorial video I watched (I wish I could show the tutorial video to you, but it is on Lynda.com and you have to pay to watch) I attached the file with my code. The example 1 code works just fine. The example 2 code is the one that is not working for some reason. However, it worked for the guy that wrote it in the video, so I am not sure where I am going wrong? *The comments in green are mainly for myself, I explain things to myself so that I don't forget what the code does forloops.php 1.74KB 2 downloads I would appreciate some help. Thank you!!! Similar TutorialsI am trying to use some php code inside of an html document and it does not work. I have a script.php file that executes perfectly when I try and use it. Here is the code I am currently using: Code: [Select] <?php echo "<title>"; echo "the Homepage!"; echo "</title>"; ?> Any suggestions would be great. I am playing around with php but the script doesnt execute to the last point and with no error...
What i am trying to do is checking the input of the user and comparing it what is in db and then applying conditions. So i have 2 files. update.php and home.php. home.php is my html form page and i included 'update.php' in it In my update.php, i have these codes
<?php error_reporting(E_ALL); include_once('database.php'); if(isset($_POST['submit'])) { $q = $_GET['q']; $next = $q + 1; if($q == 26) { echo '<h2>You have Completed the Exam.Congrats!!</h2>'; } elseif($q <= 25){ $sql = "SELECT * FROM Students WHERE Email=?"; $stmt = $conn->prepare($sql); $stmt->bind_param('s', $_SESSION['login']); $stmt->execute(); $result = $stmt->get_result(); $row = $result->fetch_assoc(); $Mark = $row['Mark']; $Correct = $Mark + 1; $Fail = $Mark + 0; $sqlb = "SELECT * FROM Answers WHERE qid = ?"; $stmtb = $conn->prepare($sqlb); $stmtb->bind_param('s', $q); $stmtb->execute(); $resultb = $stmtb->get_result(); $rowb = $resultb->fetch_assoc(); $Answer = $rowb['Answer']; $Pick = $_POST['ans']; if($Pick == $Answer) { $sqld = "UPDATE Students SET Mark=? WHERE Email = ?"; $stmtd = $conn->prepare($sqld); $stmtd->bind_param('ss', $Correct,$_SESSION['login']); $stmtd->execute(); $resultd = $stmtd->get_result(); echo "correct" ; } } else { echo 'Ate'; echo "<script type='text/javascript'>document.location.href='home.php?q='.$next.';</script>"; } }//post submit ?> The else statement doesnt run. so it keeps reloading the same page. Also i want to ask why i keep getting the value of 2 for my $Correct variable stored on the database into column Mark for a single correct question instead of 1. What could be wrong? Lastly, i dont want the script to run if the browser is edited by the user by changing the value of $q from the browser, because i am using get method, is there a way to do that. Please be nice with your comments. Thanks in advance.!!! Hi All Basically I have 4 fields in my database image2, image3, image4, image5 I have an image uploader to upload the files but I need what I need is if image2 is empty put in image3, if image3 is empty put in image4 so far I have this //so first is the query to find the right row which gives the variable $row //now here is what im doing if($row['image2']!==""){ //run this code } elseif($row['image3']!==""){ //run this code } elseif($row['image4']!==""){ //run this code } elseif($row['image5']!==""){ //run this code } Now the problem I'm having is the code that is always executing is the first one of $row['image2'] even if image2 has a value in the database it still runs that code and over writes the field in the database. It never moves on to field 3 or 4. Can someone please tell me if I've done something wrong. I'm not storing the image in the database just the name. Thanks Danny In a PHP file [php_one.php], I wrote some PHP code that contained a form. I used ECHO to write the HTML inside of the PHP tags. On another PHP page [php_two.php], I wanted to show the code that was used to create the first page [php_one.php]. My first effort provided an interesting result, since the PHP code was readable. However, all HTML code was visible in its executed form. There was an actual input field and a submit button (not the code used to produce them) in the context of my coding. I have tried using:
file_get_contents("FILE") All results were similar and carried the same problem. How can I view code so that even the HTML is visible as code? Hello ..Im so glad to be here with u all I am a novice in the use of this php/sql and I have to complete my project..but Unfortunately, I got this problem and I couldent figure out where the mistake lies.. please any advice here u my code Code: [Select] <html> <body background="3d-background-blue.jpg"> <?php $x1=$_POST['fname']; $x2=$_POST['age']; $x3=$_POST['password']; $x4=$_POST['email']; $x5=$_POST['yourtype']; mysql_connect("localhost","root","")or die("there is a problem "); mysql_select_db("order1")or die("no DB"); // check if the username is taken $check = "select id from users where fname = '$x1'"; $qry = mysql_query($check) or die ("Could not match data because ".mysql_error()); $num_rows = mysql_num_rows($qry); if ($num_rows != 0) { echo "Sorry, there the username $x1 is already taken. "; echo "Try again"; echo "<a href= iinterface.html >home</a>"; echo "<br>"; exit(); } else { // insert the data $query="insert into users (fname,age,password,email,type) values('$x1','$x2','$x3','$x4','$x5')"; $result=mysql_query($query); if($result){ echo "thanks for registering $x1 " ;echo "<br>"; echo "the date of registeration is "; Echo gmdate ("D, d M Y H:i:s"); echo "<br>"; echo "<br>"; echo "<a href=iinterface.html > back to main </a>"; echo "<br>"; } else {echo"insertion error"; } ?> </body> </html> the massege of error is : Quote Parse error: parse error in insert2.php on line 45 Hi!
I'm new to php so, please forgive if this is a really simple question or if it doesn't make sense.
I have an www.domain.com web site and then I have an microprocessor at home connected to the internet also hosting and simple page. That page is acessible from the internet.
When I'm browising on my www.domain.com i want to add an botton that sends an request to the microprocessor, right now what i do is when the button is clicked, it opens the microprocessor page like : microprocessor.ddns.net/?update=1.
How can i make the www.domain.com send the "?update=1" to the microprocessor without the user have to see the microprocessor page.
The main purpose is to hide the microprocessor address so it's harder to be hacked..
Thanks for the help!
Hello I do not know anything about php this is the code <?php echo do_shortcode( “[covid19 country=‘Pakistan’ title=‘Pakistan’]” ); echo do_shortcode( “[covid19 country=‘India’ title=‘India’]” ); echo do_shortcode( “[covid19]” ); ?>
can anyone help me to center the numbers of cases death recovered:
Okay so I have a table that displays grades. If the stupid has 100 for the grade points then I want a A to be displayed under the table... I think it does something like this... if grade_type >=100 $final_grade = A Idk, im new to php and need help doing this... here is my code... Code: [Select] <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); require_once('database.php'); session_start(); if (isset($_POST['add_grade'])) { $query = "INSERT INTO grades (grade_id, student_id, grade_type, grade_name, grade_points) "; $query .= "VALUES (:grade_id, :student_id, :grade_type, :grade_name, :grade_points) "; $statement = $db->prepare($query); $statement->bindValue (':student_id', $_SESSION['student_id']); $statement->bindValue (':grade_id', $_SESSION['grade_id']); $statement->bindValue (':grade_type', $_POST['grade_type']); $statement->bindValue (':grade_name', $_POST['grade_name']); $statement->bindValue (':grade_points', $_POST['grade_points']); $statement->execute(); $statement->closeCursor(); } ?> <!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>View Course Grades</title> <link rel="stylesheet" type="text/css" href="main.css" /> </head> <body> <?php $student_name = $_SESSION['student_name']; $student_id = $_SESSION['student_id']; $query = "SELECT * FROM grades WHERE student_id = :student_id "; $statement = $db->prepare($query); $statement->bindValue (':student_id', $student_id); $statement->execute(); $grades = $statement->fetchAll(); $statement->closeCursor(); echo "<h1>Show Grades for $student_name </h1>"; foreach ($grades as $grade) { echo $grade['grade_type'] . " " . $grade['grade_name']. " " . $grade['grade_points'] . "<br />"; } ?> <div id="content"> <!-- display a table of products --> <table> <tr> <th>Grade Type</th> <th>Grade Name</th> <th>Grade Points</th> <th>Remove</th> </tr> <?php foreach ($grades as $grade) : ?> <tr> <td><?php echo $grade['grade_type']; ?></td> <td><?php echo $grade['grade_name']; ?></td> <td><?php echo $grade['grade_points']; ?></td> <td><form action="delete_grade.php" method="post"> <input type="submit" name="remove" value="Delete" /> <input type="submit" name="update" value="Update" /> </form></td> </tr> <?php endforeach; ?> </table> </div> </div> <div id="footer"> </div> <form name="grades" method="post" action="grades.php"> <p>Grade Type<SELECT NAME="grade_type"> <OPTION VALUE="Mid-Term">Mid-Term <OPTION VALUE="Final">Final <OPTION VALUE="Lab">Lab </SELECT> <br> Grade Name:<input type="text" name="grade_name" value=""><br /> Grade Points:<input type="text" name="grade_point" value=""> <input type="submit" name="add_grade" value="Add Grade"> </form> </table> </body> </html> Code: [Select] <html> <head> <title>Delete Grade</title> </head> <body> <form method="post" action="delete_grade.php"> <?php ini_set ("display_errors", "1"); error_reporting(E_ALL); $dbc = mysqli_connect('localhost', 'se266_user', 'pwd', 'se266') or die(mysql_error()); //delete grades if (isset($_POST['remove'])) { foreach($_POST['delete'] as $delete_id) { $query = "DELETE FROM grades WHERE grade_id = $delete_id"; mysqli_query($dbc, $query) or die ('can\'t delete user'); } echo 'grade has been deleted.<br />'; } if (isset($_POST['update'])) { foreach($_POST['update'] as $update_id) { $query = "UPDATE grades SET grade_id = $update_id"; mysqli_query($dbc, $query) or die ('can\'t update user'); } } //Display grade info with checkbox to delete $query = "SELECT * FROM grades"; $result = mysqli_query($dbc, $query); while($row = mysqli_fetch_array($result)) { echo '<input type="checkbox" value="' .$row['grade_id'] . '" name="delete[]" />'; echo ' ' .$row['grade_type'] .' '. $row['grade_name']; echo '<br />'; } mysqli_close($dbc); ?> <p>Grade Type<SELECT NAME="grade_type"> <OPTION VALUE="Mid-Term">Mid-Term <OPTION VALUE="Final">Final <OPTION VALUE="Lab">Lab </SELECT> <br> Grade Name:<input type="text" name="grade_name" value=""><br /> Grade Points:<input type="text" name="grade_point" value=""> <input type="submit" name="remove" value="Remove" /> <input type="submit" name="update" value="Update" /> </form> </body> </html> This is a simple php class code it worked for me before but i don't know what's wrong with it now This is a little test code to help me understand classes alittle better and i can't get it to work grrrr class person { private $name; function setname($name){ $this->name=$name; } function getname($name){ return $this->$name; } }; $prezident = new person(); $prezident->setname('prezident'); $dayday = new person(); $dayday->setname('dayday'); print $dayday->getname()."<br/>"; print $prezident->getname()."<br/>"; Dear friends, I have a class to validate a form. This is not my own class & i got it from some where. This is my class Code: [Select] <?php class validation { function email_validation($email, $email_label) { //E-mail validation: We use regexp to validate email. $email = trim($email); if (strlen($email) >= 1 ) { if(preg_match("/^[a-zA-Z]\w+(\.\w+)*\@\w+(\.[0-9a-zA-Z]+)*\.[a-zA-Z]{2,4}$/", $email) === 0) $error = 'You have to enter a valid '.$email_label; else $error = null; }else $error = 'You have to enter your '.$email_label; return $error; } } ?> My question is in this function consider this line of code Code: [Select] if(preg_match("/^[a-zA-Z]\w+(\.\w+)*\@\w+(\.[0-9a-zA-Z]+)*\.[a-zA-Z]{2,4}$/", $email) === 0) $error = 'You have to enter a valid '.$email_label; else $error = null; here we do not using this "{" and "}" inside the if statement but is working without it. Iam confused about it and anyone can clear it out ?? Why we do not using that on the function & why did it does not producing the error ?? Thanks In Advance!! Guys i wrote one pinging script but i don't know it works or not... Someone help me about it works or not? <?php site1("http://site.com/sitemap.xml"); site2("http://site2.com/sitemap.xml"); function site1($url){ @file_get_contents("http://www.google.com/webmasters/tools/ping?sitemap=" . $url); @file_get_contents("http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=YahooDemo&url=" . $url); @file_get_contents("http://www.bing.com/webmaster/ping.aspx?siteMap=" . $url); @file_get_contents("http://submissions.ask.com/ping?sitemap=" . $url); } Print "Pinging1 success"; function site2($url){ @file_get_contents("http://www.google.com/webmasters/tools/ping?sitemap=" . $url); @file_get_contents("http://search.yahooapis.com/SiteExplorerService/V1/updateNotification?appid=YahooDemo&url=" . $url); @file_get_contents("http://www.bing.com/webmaster/ping.aspx?siteMap=" . $url); @file_get_contents("http://submissions.ask.com/ping?sitemap=" . $url); } Print "<br>Pinging2 success"; ?> Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\wamp\www\parkhall\quantities.php on line 21 This is the error message. This is the code. simple array query to display contents of table and I cant see where i have made the mistake. hopefully someone can help. <?php mysql_connect ("localhost", "******", "*****") or die ('I cannot connect to the database becuase: ' . mysql_error()); mysql_select_db ("matquant"); $query = mysql_query("SELECT * FROM quantities"); while ($row = mysql_fetch_array($query)) { //line referred to in error message echo "<br /> ID: " .$row ['id']. " material : " .$row ['material']. "quantity:" .$row['quantity']. "<br />";} ?> Please point out the probably glaring error. I'm relatively new to this and I am really not finding php easy to learn. heres the code... <?php mysql_connect("localhost","peter","tizer") or die("Error: ".mysqlerror()); mysql_select_db("matquant"); //replace TestTable with the name of your table //also in a real app you would get the id dynamically $idtochange=$_POST['idtochange']; $sql="select * from `quantites` where id = $idtochange"; $query=mysql_query($sql); while ($row=mysql_fetch_array($query)){ $id = $row['id']; $material = $row['material']; $quantity = $row['quantity']; $unit = $row['unit']; //we will echo these into the proper fields } mysql_free_result($query); ?> <html> <head> <title>Edit material list</title> <link href="css/quant1.css" rel="stylesheet" type="text/css"> </head> <body> <div id="leftcol"> <form "method="post"> <p><br/> <input type="text"value="1" name="idtochange" > <p> <input type="submit"value="submit changes"/> </form> <form action="changequan.php"method="post"> <p>Material Id currently active<br/> <input type="text"value="<?php echo $id;?>" name="id" disabled/> </p> <p> Enter new material name: </p> <input type="text"value="<?php echo $material;?>" name="material"/> <br/> change quantity: <input type="text"value="<?php echo $quantity;?>" name="quantity"/> <br/> unit of mesurement for quantity<br/> <input type="text"value="<?php echo $unit;?>" name="unit"/> <br/> </p> <input type="submit"value="submit changes"/> </form> </div> <div id="rightcol"><?php // make connection mysql_connect ("localhost", "peter", "tizer") or die ('I cannot connect to the database becuase: ' . mysql_error()); mysql_select_db ("matquant"); // build query $query = mysql_query("SELECT * FROM `quantites` ORDER BY `id` ASC"); // display results while ($row = mysql_fetch_array($query)) { echo "<br /> ..... " .$row ['id']. " ....... " .$row ['material']. " ...... " .$row['quantity']. " ...... " .$row['unit']. "<br />";} echo mysql_error(); ?> <a href="index.html">Home </a> <p> <a href="quanform.php">Insert new material and quantity form</a></p></div> </body> </html> I'm struggling with php. Any help anyone can give would be appreciated. Sorry this page is not available or has been accessed in error An error occurred in script 'C:\xampp\htdocs\public_html\login\plugins\delete_product.php' on line 45: Undefined variable: id Date/Time: 8-24-2010 00:50:10 Array ( [GLOBALS] => Array *RECURSION* [_POST] => Array ( ) [_GET] => Array ( [id] => 2 ) <?php # Script 9.2 - delete_product.php // This page is for deleting a album. require_once ('../includes/config.inc.php'); // Check for a valid product ID, through GET or POST: if ( (isset($id)) && (is_numeric($id)) ) { // From editproducts.php $id = $_GET['id']; } elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form submission. $id = $_POST['id']; } else { echo '<p class="error">Sorry this page is not available or has been accessed in error</p>'; } echo $id; require_once(MYSQL); // Check if the form has been submitted: if (isset($_POST['submitted'])) { if ($_POST['sure'] == 'Yes') { // Delete the record. // Make the query: $q = "DELETE FROM products WHERE product_id='$id' LIMIT 1"; $r = @mysqli_query ($dbc, $q); if (mysqli_affected_rows($dbc) == 1) { // If it ran OK. // Print a message: echo '<p>The Product has been deleted.</p>'; } else { // If the query did not run OK. echo '<p class="error">The Product could not be deleted due to a system error.</p>'; // Public message. echo '<p>' . mysqli_error($dbc) . '<br />Query: ' . $q . '</p>'; // Debugging message. } // Make the query: $q = "DELETE FROM photos WHERE product_id='$id'"; $r = @mysqli_query ($dbc, $q); } else { // No confirmation of deletion. echo '<p>The Product has NOT been deleted.</p>'; } } else { // Show the form. // Retrieve the albums information: $q = "SELECT name FROM products WHERE product_id='$id' Limit 1"; $r = @mysqli_query ($dbc, $q); if (mysqli_num_rows($r) == 1) { // Valid user ID, show the form. // Get the user's information: $row = mysqli_fetch_array ($r, MYSQLI_NUM); $form = $_SERVER['PHP_SELF']; // Create the form: echo '<form action="' . $form . '" method="post"> <h1>Delete ' . $row[0] . '?</h1> <p>Are you sure you want to delete ' . $row[0] . '?<br /> <p><b>Warning if you delete this album all content inside of it will be losed!</b><br /> <input type="radio" name="sure" value="Yes" /> Yes <input type="radio" name="sure" value="No" checked="checked" /> No</p> <p><input type="submit" name="submit" value="Submit" /></p> <input type="hidden" name="submitted" value="TRUE" /> <input type="hidden" name="id" value="' . $id . '" /> </form>'; } } mysqli_close($dbc); ?> Looke on the PHP manual for the "count" function and it has confused me. it seems to count arrays more than anything. i have a small site and i wanted to display how many items are contained within a Database table. for example i want it to count the amount of users are in the user table. and i then need to echo that amount + 100. Can someone help me with the code. i have already included a database connect script within the header of the page with includes etc. Help would be appreciated. but i would like to know how the code works else i will never learn. I need a bit of help. I'm at the end of my rope for the night. I'm a total noob when it comes to programming, and i'm trying to make a bit of a complex randomizer generate 6 unique numbers for me. For some reason, this simple randomize code throws my html browser into an infinite loop every now and then. It's weird, because most of the time it works, but every now and then the while statements are causing it to hit an infinite loop, (which is obviously no code). Can someone help me find where the problem is stemming from? Code: <?php function NetworkInfo ($textfieldUsername) { $myFile = "../../USER_INFO/" . $textfieldUsername . "-Network.txt"; $fh = fopen($myFile, 'r'); $Gate = "__"; while (strcmp(trim($Gate),trim($ZeroHolder)) <> 0) { $counter = $counter + 1; $Gate = fgets($fh); } $TotalNetworkNums = $counter - 1; if ($TotalNetworkNums > 0) { $FirstNetworkNum = rand (1, $TotalNetworkNums); } if ($TotalNetworkNums > 1) { $SecondNetworkNum = rand (1, $TotalNetworkNums); do { $SecondNetworkNum = rand (1, $TotalNetworkNums); } while ($SecondNetworkNum==$FirstNetworkNum); } if ($TotalNetworkNums > 2) { $ThirdNetworkNum = rand (1, $TotalNetworkNums); do { $ThirdNetworkNum = rand (1, $TotalNetworkNums); } while (($FirstNetworkNum==$ThirdNetworkNum) || ($SecondNetworkNum==$ThirdNetworkNum)); } if ($TotalNetworkNums > 3) { $FourthNetworkNum = rand (1, $TotalNetworkNums); do { $FourthNetworkNum = rand (1, $TotalNetworkNums); } while (($FirstNetworkNum==$FourthNetworkNum) || ($SecondNetworkNum==$FourthNetworkNum) || ($ThirdNetworkNum==$FourthNetworkNum)); } if ($TotalNetworkNums > 4) { $FifthNetworkNum = rand (1, $TotalNetworkNums); do { $FifthNetworkNum = rand (1, $TotalNetworkNums); } while (($FirstNetworkNum==$FifthNetworkNum) || ($SecondNetworkNum==$FifthNetworkNum) || ($ThirdNetworkNum==$FifthNetworkNum) || ($FourthNetworkNum==$FifthNetworkNum)); } if ($TotalNetworkNums > 5) { $SixthNetworkNum = rand (1, $TotalNetworkNums); do { $FifthNetworkNum = rand (1, $TotalNetworkNums); } while (($FirstNetworkNum==$SixthNetworkNum) || ($SecondNetworkNum==$SixthNetworkNum) || ($ThirdNetworkNum==$SixthNetworkNum) || ($FourthNetworkNum==$SixthNetworkNum) || ($FifthNetworkNum==$SixthNetworkNum)); } echo "" . $FirstNetworkNum . " " . $SecondNetworkNum . " " . $ThirdNetworkNum . " " . $FourthNetworkNum . " " . $FifthNetworkNum . " " . $SixthNetworkNum . " "; fclose($fh); } NetworkInfo ($_REQUEST['textfieldUsername']); I'm messing around with unconventional coding practices, just to .... practice. The following code isn't being used for any amazing projects or anything, it's just me messing around with things getting practice. It's a simple code but it keeps telling me the constants are undefined. //defining the variables through an array $db['db_host'] = "localhost"; $db['db_user'] = "root"; $db['db_pass'] = ""; $db['db_name'] = "cms"; //fancy way of making them constants foreach($db as $key => $value) { define(strtoupper($key), $value); } $conn = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME); if($conn) { echo "We are connected"; } Simple, simple, very simple but can someone tell me why it's not creating the constants? All of them in $conn are coming back as undefined. I am running PHP Version 5.3.1. The following Code does not write to my database. It is code that I took from the PHP Pocket Reference from O'Reilly but it does not work... What's wrong with this code? Thanks in advance. Guy <?php if($vote && !$already_voted) SetCookie('already_voted',1); ?> <html> <head> <title>Name the Baby</title> </head> <h3>Name the Baby</h3> <form action="baby.php" method="POST"> <p>Suggestion: <input type="text" name="new_name"/> </p> <input type="submit" value="Submit idea and/or vote"/> <?php mysql_pconnect("localhost","root","password"); $db = "babynames"; $table = "baby_names"; if($new_name) { if(!mysql_db_query($db, "insert into $table values ('$new_name',0)")) { echo mysql_errno().': '. mysql_error()."<br />\n"; } } if($vote && $already_voted) { echo '<p><b>Hey, you voted already '; echo "Vote ignored.</b></p>\n"; } else if($vote) { if(!mysql_db_query($db, "update $table set votes=votes+1 where name='$vote'")) { echo mysql_errno().': '. mysql_error()."<br />\n"; } } $result=mysql_db_query($db,"select sum(votes) as sum from $table"); if($result) { $sum = (int) mysql_result($result,0,"sum"); mysql_free_result($result); } $result=mysql_db_query($db, "select * from $table order by votes DESC"); echo <<<EOD <table border="0"><tr><th>Vote</th> <th>Idea</th><th colspan="2">Votes</th></tr> EOD; while($row=mysql_fetch_row($result)) { echo <<<FOO <tr><td align="center"> <input type="radio" name="vote" value="$row[0]"></td> <td>$row[0]</td> <td align="right">$row[1]</td> <td> FOO; if ($sum && (int)$row[1]) { $per = (int)(100 * $row[1]/$sum); echo '<img src="bline.gif" height=12 '; echo "width=$per> $per %</td>"; } echo "</tr>\n"; } echo "</table>\n"; mysql_free_result($result); ?> <input type="submit" value="Submit idea and/or vote" /> <input type="reset" /> </form> </body></html> Hello; I'm new to php and to programming in general, but i want to do a little app to help a process on my work, you know, just being pro-active (hoping it doesnt come and byte me in the a** in the future, you know.. "you did it now our life depend on it and you fix it right now!!). So.. I have this really simple piece of code, but its not working and i cant figure out why. I'm trying to use echo to print a couple of link but when i put in the second line everything messes up. the code is: (note the "test lines" i just added them to try to understand what is doing) <?php $client = $_GET['client']; echo "Client " . $client . "<br />"; echo "test line 1"; echo "<a href=\"link1.php?client=".$client.">Link 1</a><br>"; echo "test line 2"; echo "test line 3"; echo "<a href=\"link2.php?client=".$client.">Link 2</a><br>"; ?> When i open the page on firefox i get: === Client myclient test line 1Link 2 === Where the link (underlined) text is "Link 2" but the it points to something totally different (a mix of the rest of the code). If I remove the second link, like he <?php $client = $_GET['client']; echo "Client " . $client . "<br />"; echo "test line 1"; echo "<a href=\"link1.php?client=".$client.">Link 1</a><br>"; echo "test line 2"; echo "test line 3"; ?> I get what i'd expect: === Client myclient test line 1Link 1 test line 2test line 3 === Im totally lost, im not sure if its a browser issue, a server issue or just the code My setup: WAMP 2.1 (Apache) I'm opening the "site" with Firefox 3.6.15 and IE6, both show the same result Windows XP (dont know if it matters) The file is saved as php tried changing "echo" with "print", same result Umm.. thats it... Please let me know if you need any more info Thanks everyone edit: typo on subject edit: yet another typo |