PHP - Parse A Url Parameter On Form
Hi there im using dream weaver and ive created a form that can be updated:
Code: [Select] if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE ships SET FleetName=%s, HealthA=%s, HealthB=%s WHERE ShipID=%s", GetSQLValueString($_POST['select'], "text"), GetSQLValueString($_POST['textfield'], "int"), GetSQLValueString($_POST['textfield2'], "int"), GetSQLValueString($_POST['hiddenField'], "int")); mysql_select_db($database_swb, $swb); $Result1 = mysql_query($updateSQL, $swb) or die(mysql_error()); $updateGoTo = "fleet.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } I want to parse a parameter after its updated and directed to another page but i cant seem to get it to work: Code: [Select] $updateGoTo = "fleet.php?recordID=$row_Ship['FleetName']"; Please help Thanks Similar TutorialsHi there im trying to parse a url parameter in a hyperlink, i cant seem to get it to work, im sure its a problem with the braces. This is the original code: Code: [Select] echo '<a href="http://localhost/swb/planet.php/"> <p class="rmoncalamari tmoncalamari">' . $moncalamari. "1-1-2-6".'</p></a>'; and i tried to modify it to parse the record id... Code: [Select] echo '<a href="http://localhost/swb/planet.php?recordID= '$row_cats['CatName'];/"> <p class="rmoncalamari tmoncalamari">' . $moncalamari. "1-1-2-6".'</p></a>'; If you could help me that would be ace. Thank you Hello, I want to use this function in form. How can I pass parameter in form ? please help me. Thanks <?php function displayName($fetch) { echo "your Name is ".$fetch; } ?> Hi all I am working on a filter system that when a user selects a drop down menu item it automatically updates the page taking the value from the form and sending it through the URL parameter to update the page accordingly: <form id="category_filter" name="category_filter" method="post" action=""> <label for="category_filter"></label> <select name="category_filter" id="category_filter" style="width: 160px" onchange="this.form.submit();" > <option value="" selected class="meter-calc-text">Category</option> <?php $fetchcategories=mysql_query("SELECT * FROM `categories` ORDER BY position ASC"); while($returnedcategories=mysql_fetch_array($fetchcategories)) { echo "<option value=\"".$returnedcategories['name']."\" >".$returnedcategories['name']."</option>"; } ?> </select> </form> The only thing is, it doesn't pass the value to the url, it remains blank Many thanks for your help. Pete Hi all I am in the process of creating a product page where the user can type in three initials into a form and then 'clicks add to basket'. The button doesn't use a form just a url: basket.php?action=add&id=1&qty=1 This adds the item into a basket using sessions rather than a database. The question is, how do I add three variables into my form so that they are sent via the URL and into the session? Wil I have to start again with a form? Here's the code: <td class="table-font-grey">Why not make your whip extra special by adding up to three elegantly engraved Kunstler script initials.</td> <td width="42" style="border: 1px solid grey;"><input name="initial_1" type="text" size="8" maxlength="1" height="40px" /></td> <td width="43" style="border: 1px solid grey;"><input name="initial_2" type="text" size="8" maxlength="1" height="40px" /></td> <td width="43" style="border: 1px solid grey;"><input name="initial_3" type="text" size="8" maxlength="1" height="40px" /></td> </tr> <tr> <td height="15"> </td> <td width="328" class="table-font"> </td> <td width="42" align="center" class="table-font">1</td> <td width="43" align="center" class="table-font">2</td> <td align="center" class="table-font">3</td> </tr> <tr> <td> </td> <td colspan="3" class="table-font"> </td> <td align="right" class="table-font"> </td> </tr> </table> <hr /> <p> </p> <table width="494" border="0"> <tr class="table-font"> <td width="263" height="24"> <a href="<?php echo "basket.php?action=add&id=1&qty=1" ?>" title="Add <?php echo $product['name'] ?> to Cart"> <a href="<?php echo WEB_URL."basket.php?action=add&id=1&qty=1" ?>" title="Add <?php echo $product['name'] ?> to Cart"> <img src="<?php echo WEB_URL."images/product-add-button.gif" ?>" alt="Buy <?php echo $product['name'] ?>" /></a> Many thanks Pete Hello,
I recently posted here about an issue I was having with my database orientated products page.
I have now run into another problem where say if, /db.php was typed or /db.php?p=IDoNotExist was typed, it returns blank.
I have in my code the desired content to be displayed, but it just doesn't seem to want to make a show.
I was also wondering if it is possible to show different content for whatever the URL is, so for no parameter, the content about the products, and a non existent one, maybe "Product not found"?
Here is my code:
<?php $db=mysql_connect ("localhost", "webwibco_charlie", "Hello123") or die ('I cannot connect to the database because: ' . mysql_error()); $mydb=mysql_select_db("webwibco_products"); include("header.php"); $status = htmlspecialchars( @$_GET ['p'] ); if ($status == "floorpuzzles") { echo "<h1>Our Floor Puzzles</h1>"; $sql="SELECT ID, Name, Tags, Description, Category FROM products WHERE Category LIKE '%" . FloorPuzzles . "%'"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ $Name =$row['Name']; $ID =$row['ID']; $Description =$row['Description']; echo "<div class=\"box\">"; echo "<h1>$Name</h1>"; echo "<div class=\"floorbox\"><a href=\"?p=$ID\"><img src=\"images/products/catalogue/big/floorpuzzles/$ID.jpg\" class=\"small\"></a></div>"; echo "<h2>$Description</h2>"; echo "</div>"; } ?> <? }else{ if ($status == $_GET["p"]) { $sql="SELECT ID, Name, Tags, Description, Pieces, Size, Barcode, Category FROM products WHERE ID = '" . $_GET['p'] . "'"; $result=mysql_query($sql); while($row=mysql_fetch_array($result)){ $Name =$row['Name']; $ID =$row['ID']; $Description =$row['Description']; $Pieces =$row['Pieces']; $Size =$row['Size']; $Barcode =$row['Barcode']; echo "<div class=\"1\">"; echo "<h1>$Name</h1>"; echo "<div class=\"bigbox\">"; echo "<div class=\"floorbox\"><img src=\"images/products/catalogue/big/floorpuzzles/$ID.jpg\" class=\"big\"></div>"; echo "</div>"; echo "</div>"; echo "<div class=\"2\">"; echo "<p>Puzzle Pieces: $Pieces</p> <p>Puzzle Size: $Size</p> <p>Barcode: $Barcode</p>"; echo "</div>"; } }else{ ?> <? echo"<h1>Our Products</h1> <p>Our jigsaw puzzles are hand cut by skilled craftsmen and therefore each one is unique with self-correcting pieces. There is a strict quality control process at all stages by our highly experienced staff. The puzzles are durable and provide fun and excitement, enhancing learning and a child’s development.<p> <p>All of our jigsaws are made using materials from sustainable resources grown in managed forests. Where possible we support companies in the UK and source our components locally, most of our suppliers are in the East Midlands, many in Derbyshire and Nottinghamshire. We keep packaging to a minimum and take our environmental and ethical responsibilities very seriously.</p> <p>Reducing waste and recycling was a way of life for us before it became fashionable. We are constantly searching for new ideas and consult teachers when developing our jigsaws, which are often used within the national curriculum.</p> <p>As well as making our own range, we manufacture for leading suppliers to the education market. Check for \"Made in Britain\" and it is probably made by us.</p> <p>We have a wide variety of products available for viewing, from classic floor puzzles to innovative inset trays. You can take a look at all our products on this page, simply use the navigation buttons to your left.</p>"; }} include("footer.php"); ?>The final echo is what I wish to be displayed on the URL without or with an invalid parameter. Here is my site URL: http://www.webwib.co...saws/search.php (note that only the "Floor Puzzles" category has content within it). Thank you in advance for assistance. I have the following code just to insert a username and hashed password into the database but somehow I am getting this error and I couldn't find out where I am doing it wrong...can someone please give me a hand?
I tried it in two ways and both errors...
the first few lines are just connecting database which worked fine and a password.php so I can use password_hash() with my php version
$hash = password_hash('xx', PASSWORD_BCRYPT, array('cost' => 10)); $username = 'xx'; $insertQuery = $db->prepare(" INSERT INTO et_todo (username, password) VALUES (:username, :hash) "); $insertQuery->execute(array( 'username' => $username, 'password' => $hash ));also tried $hash = password_hash('xx', PASSWORD_BCRYPT, array('cost' => 10)); $insertQuery = $db->prepare(" INSERT INTO et_todo (username, password) VALUES ('xx', :hash) "); $insertQuery->execute(array( 'username' => 'xx', 'password' => $hash )); Okay I have index.php in which i used <?php echo $_GET['name']; ?> and its working fine all over the page except a wizard form that loads on a button click. <?php echo $_GET['name']; ?> is working on entire page text (wherever i have used this) except a wizard form which loads on a button click. All the files of that wizard form are located in my website folder (e.g. wizard.php, wizard.js & wizard.css). here's how wizard.php code starts: <div class="wizard-container"> <div class="card wizard-card" data-color="green" id="wizardProfile"> <form action=""> <div class="wizard-header"> <h3 class="wizard-title"> GENERATE A FRESH <?php echo $_GET['name']; ?> CODE </h3> <h5 style="margin-left: 10px; margin-right: 10px;">Our interactive generator will guide your through the process</h5> </div> i want that <?php echo $_GET['name']; ?> should also work in wizard form but it shows the following error: C:\xampp\htdocs\NameGenerator\content\hbox\html\wizard.php on line 7 Sorry for my bad explanation i don't know much about php so i explained it like this Please help... Hi I struggle with something i'm trying to achieve. Maybe this is not the correct approach, i don't know. My goal is to attribute a string of a field of the form to a string variable in order to use this string variable in order to "auto fill" the field of the form previously completed. This is to do what is apparently called a sticky form... First the program attributes the string of a field of the form to a string variable : $EmitterFirstName = $_POST["EmitterFirstName"]; Then in the html form there is a field called "EmitterFirstName", and i want to use the string variable $EmitterFirstName in order to auto fill the field with the string previously typed by the user : <input type="text" name="EmitterFirstName" value="<?php $EmitterFirstName ?>"/> But it doesn't work as expected. Do you have any idea why or maybe an advice on how to code such a thing ? Thanks, Hey Guys, I've got a section of code that generates a date and time. This is currently standalone however I'm looking to integrate it with a standard page. This is the code page: <?php error_reporting(0); include("options.php"); include("include/functions.php"); include("include/class.php"); list($year,$month,$day) = explode("-",date("Y-n-j",strtotime($_REQUEST["date"]))); $bookFrom = formatDateByCalendarId($day,$month,$year,$_REQUEST["cid"]); $sql = "SELECT * FROM ".$TABLES["Calendars"]." WHERE id=".$_REQUEST["cid"]; $sql_result = mysql_query ($sql, $connection ) or die ('request "Could not execute SQL query" '.$sql); $Calendar = mysql_fetch_assoc($sql_result); $CalendarOptions = unserialize($Calendar["options"]); $fontFamily = $Fonts[$CalendarOptions["fonts"]]; $daysFontSize = $FontSize[$CalendarOptions["daysFontSize"]]; $daysFontStyle = $Styles[$CalendarOptions["daysFontStyle"]]; $availableDaysFontSize = $FontSize[$CalendarOptions["availableDaysFontSize"]]; $availableDaysFontStyle = $Styles[$CalendarOptions["availableDaysFontStyle"]]; $timeSlot=new Timeslot($_REQUEST["cid"]); $reservations=$timeSlot->getFreeFilter($CalendarOptions["startTime"],$CalendarOptions["endTime"],$year,$month,$day,$CalendarOptions["timeSlot"]); if (!isset($_REQUEST["view"])) { $view = '1'; } else { $view = $_REQUEST["view"]; }; if ($_REQUEST["ac"]=='book') { $message =''; $format = GetCalendarDateFormat($_REQUEST["cid"]); $sYear = GetYear($format,$_REQUEST["startDate"]); $sMonth = GetMonth($format,$_REQUEST["startDate"]); $sDay = GetDay($format,$_REQUEST["startDate"]); $reservations=$timeSlot->getFreeFilter($CalendarOptions["startTime"],$CalendarOptions["endTime"],$sYear,$sMonth,$sDay,$CalendarOptions["timeSlot"]); $sDateLong = strtotime($CalendarOptions["startTime"],mktime(0,0,0,$sMonth,$sDay,$sYear)); $first=-1; $last=-1; for ($i=0;$i<count($reservations);$i++) { if (($_REQUEST[$i]=="on")&&((($reservations[$i]>0)&&($reservations[$i]==$_REQUEST["rid"]))||(!$reservations[$i]))) { if ($first<0) $first=$i; $last=$i; } } $eDateLong = strtotime("+".($CalendarOptions["timeSlot"]*($last+1))." minutes",$sDateLong); $sDateLong= strtotime("+".($CalendarOptions["timeSlot"]*$first)." minutes",$sDateLong); if($_REQUEST["rid"]>0) { $updateRange = $_REQUEST["rid"]; } else $updateRange = NULL; if(! $timeSlot->checkInterval($sDateLong,$eDateLong,$updateRange)){ $message = "Some of the timeslots on the selected date are already booked."; } else { $settings["status"]=$CalendarOptions["reservationStatus"]; $settings["notes"]=mysql_escape_string(utf8_encode($_REQUEST["notes"])); $settings["customerName"]=mysql_escape_string(utf8_encode($_REQUEST["customerName"])); $settings["phone"]=mysql_escape_string(utf8_encode($_REQUEST["phone"])); $settings["email"]=mysql_escape_string(utf8_encode($_REQUEST["email"])); $settings["price"]=$_REQUEST["price"]; if (! isset($updateRange)) $settings["dt"]=date("Y-m-d H:i:s"); if (! $timeSlot->addReservation($sDateLong,$eDateLong,$settings,$updateRange)) $message = 'Failed saving'; else { if($_REQUEST["findReservation"]=="1") $_REQUEST["ac"]='findReservation'; else $_REQUEST["ac"]='view'; $_REQUEST["month"] = $sMonth*1; $_REQUEST["year"] = $sYear; $search_tokens=array("<Name>","<Email>","<Phone>","<Notes>","<Date>","<StartTime>","<EndTime>","<Price>"); $replace_tokens=array($_REQUEST["customerName"],$_REQUEST["email"],$_REQUEST["phone"],stripslashes($_REQUEST["notes"]),$_REQUEST["startDate"],formatTime($sDateLong,$_REQUEST["cid"]),formatTime($eDateLong,$_REQUEST["cid"]),$_REQUEST["price"]); $MESSAGE_BODY=$CalendarOptions["emailMessage"]; $MESSAGE_BODY=nl2br(str_replace($search_tokens,$replace_tokens,$MESSAGE_BODY)); $mailheader = "From: ".$CalendarOptions["NotificationEmail"]."\r\n"; $mailheader .= "Reply-To: ".$CalendarOptions["NotificationEmail"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; if ($CalendarOptions["NotificationEmail"]<>'') { if(!mail($CalendarOptions["NotificationEmail"], 'Reservation Confirmation', $MESSAGE_BODY, $mailheader)) $message="Failure sending e-mails.<br />"; }; if ($_REQUEST["email"]<>'') { if (!mail($_REQUEST["email"], 'Reservation Confirmation', $MESSAGE_BODY, $mailheader)) $message="Failure sending e-mails.<br />"; }; if($CalendarOptions["allowPaypal"]=="true" and $CalendarOptions["paypalAddress"]<>"" and $CalendarOptions["depositPayment"]>0 and isset($_REQUEST["price"]) and $_REQUEST["price"]>0){ $price = $_REQUEST["price"]; $deposit = $price * ($CalendarOptions["depositPayment"] / 100); $_REQUEST["ac"] = "redirectToPaypal"; } else { unset($_REQUEST["ac"]); } $message.='Reservation saved.'; } } } echo '<div style="font-family:'.$fontFamily.'; color:#'.$CalendarOptions["availableDaysFontColor"].'; font-size:'.$availableDaysFontSize.'px; font-weight:bold">'.$message.'</div>'; if($_REQUEST["ac"]=="redirectToPaypal"){ } else { ?> <?php if(isset($_REQUEST["date"])){ ?> <form action="load-bookingform.php" method="post" name="frm" style="margin:0px; padding:0px" onsubmit="return false"> <table width="<?php echo $CalendarOptions["width"]; ?>" border="0" cellspacing="0" cellpadding="2" style='font-family:"<?php echo $fontFamily; ?>"; color:#<?php echo $CalendarOptions["availableDaysFontColor"]; ?>; font-size:<?php echo $availableDaysFontSize; ?>px; <?php echo $availableDaysFontStyle; ?>'> <tr> <td width="16%" align="left">Date:</td> <td width="85%" align="left" name="startDate" id="startDate"><strong><?php echo $bookFrom; ?></strong></td> </tr> <?php $price = 0; ?> <tr> <td colspan="2"> <table width="100%" border="0" cellspacing="2" cellpadding="2"> <tr> <td width="33%" valign="top" bgcolor="#DDDDDD">Start time</td> <td width="33%" valign="top" bgcolor="#DDDDDD">End time</td> <td colspan="2" valign="top" bgcolor="#DDDDDD">Book </td> </tr> <?php for ($i=0;$i<count($reservations);$i++) { ?> <tr> <td align="left" style="border-bottom:1px solid #DFE4E8"><?php if ($CalendarOptions["timeFormat"]=='12') echo date("h:i A",strtotime("+".($CalendarOptions["timeSlot"]*$i)." minutes",strtotime($CalendarOptions["startTime"]))); else echo date("H:i",strtotime("+".($CalendarOptions["timeSlot"]*$i)." minutes",strtotime($CalendarOptions["startTime"]))); ?></td> <td align="left" style="border-bottom:1px solid #DFE4E8"><?php if ($CalendarOptions["timeFormat"]=='12') echo date("h:i A",strtotime("+".($CalendarOptions["timeSlot"]*($i+1))." minutes",strtotime($CalendarOptions["startTime"]))); else echo date("H:i",strtotime("+".($CalendarOptions["timeSlot"]*($i+1))." minutes",strtotime($CalendarOptions["startTime"]))); ?></td> <td width="34%" align="left" valign="top" style="border-bottom:1px solid #DFE4E8"><input type="checkbox" id="<?php echo $i; ?>" name="<?php echo $i; ?>" <?php if ($reservations[$i]) { echo "checked"; echo ' disabled="disabled"'; } ?> onclick="selectTimeSlot()" /></td> </tr> <?php }; ?> </table> </td> </tr> <tr> <td align="left"> </td> <td align="left"> <input type="button" name="Button" value="Book" onclick="pass=checkForm(); if (pass) submitBooking('<?php echo $bookFrom; ?>','<?php echo date("n",strtotime($_REQUEST["date"])); ?>','<?php echo date("Y",strtotime($_REQUEST["date"])); ?>')" /> <input type="button" name="Button" value="Cancel" onclick="javascript: ajaxpage('<?php echo $SETTINGS["installFolder"]; ?>load-bookingform.php?cid=<?php echo $_REQUEST["cid"]; ?>','DateBookings<?php echo $_REQUEST["cid"]; ?>','get'); " /> </td> </tr> <?php } ?> </table> </form> <?php }; ?> I already have a checkout page, that this info needs to be parsed to. Any ideas how I can integrate it? Im trying to make my form remember the last input made by user, so I wrote the following and I get a syntax error on the input line. The error is: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in C:\wamp\www\ezsynonym\index.php on line 90 Code: [Select] <form id="searchform" method="post" action="index.php"> <input id="input" name="synonymsearch" type="text" value="<?php echo $_POST['synonymsearch']; ?>" maxlength="400px" /> </form> TIA Hello All,
Being a newbie at PHP coding I'm at my wits end trying to figure out:
a) how to pull-in values from a delimeted text field (in a MySQL table) and check/select the appropriate checkboxes, based on the values that were stored in the text field,
b) how to write any changes (made by the user) back to the tables' text field.
Note that this is for an "update.php" file/process.
My "create.php" file/process uses the following HTML to display and accept the checkbox values:
<div class="control-group"> <label class="control-label">Limited Time Sale Days:</label> <div class="lts-checkboxes-container"> <label class="indent-to-the-left"> <input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='F'><span class='no-highlight'>Fri</span> </label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Sa'><span class='no-highlight'>Sat</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Su'><span class='no-highlight'>Sun</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='M'><span class='no-highlight'>Mon</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Tu'><span class='no-highlight'>Tue</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='W'><span class='no-highlight'>Wed</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Th'><span class='no-highlight'>Thu</span></label> </div> </div>And the code (certainly not the best code in the world, but it works) to collect, delemit/concatenate, and save to DB is as follows: if(empty($_POST['limited_time_sale'])) { // echo("You didn't select any weekday."); $selected_lts = ''; $limited_time_sale = ''; } else { $limited_time_sale = $_POST['limited_time_sale']; $N = count($limited_time_sale); $selected_lts = ''; // echo("You selected $N DoW(s): "); for($i=0; $i < $N; $i++) { // echo($limited_time_sale[$i] . " "); if ($i < ($N - 1)) { $selected_lts .= $limited_time_sale[$i] . "-"; } else { $selected_lts .= $limited_time_sale[$i]; } } } if(!empty($selected_lts)) { $limited_time_sale = $selected_lts; }Now, I've figured out how to bring-in, and separate the stored values using the following code, however I have no idea what to do next...in order to have only the approprite boxes checked/selected (in the event that all boxes were not selected during the create stage). $limited_time_sale = isset($values['limited_time_sale']) ? $values['limited_time_sale'] : ''; $checked_lts = explode("-", $limited_time_sale);In my "update.php" file, the HTML for the forms' checkboxes is as follows: <div class="control-group"> <label class="control-label">Limited Time Sale Days:</label> <div class="lts-checkboxes-container"> <label class="indent-to-the-left"> <input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='F' <?php echo $lts1; ?>><span class='no-highlight'>Fri</span> </label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Sa' <?php echo $lts2; ?>><span class='no-highlight'>Sat</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Su' <?php echo $lts3; ?>><span class='no-highlight'>Sun</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='M' <?php echo $lts4; ?>><span class='no-highlight'>Mon</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Tu' <?php echo $lts5; ?>><span class='no-highlight'>Tue</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='W' <?php echo $lts6; ?>><span class='no-highlight'>Wed</span></label> <label><input class='lts-checkbox' type='checkbox' name='limited_time_sale[]' value ='Th' <?php echo $lts7; ?>><span class='no-highlight'>Thu</span></label> </div> </div>Attached picture shows that selected checkboxes are saved to the text field as/in the format of "F-Sa-Su-M-Tu-W-Th" - if all checkboxes/weekdays were selected....or as "Sa-M-W-Th" - if only Sat, Mon, Wed, and Thu checkboxes were selected Thanks. Attached Files checkbox-Question.png 403.99KB 0 downloads hi all am new to this forum help me to overcome from this error Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in D:\wamp\www\quiz1\quiz1.php on line 12 Code: [Select] <?php include("contentdb.php"); $display = mysql_query("SELECT * FROM $table ORDER BY id",$db); if (!$submit) { echo "<form method=post action=$_SERVER['PHP_SELF']>"; echo "<table border=0>"; while ($row = mysql_fetch_array($display)) { $id = $row["id"]; $question = $row["question"]; $opt1 = $row["opt1"]; $opt2 = $row["opt2"]; $opt3 = $row["opt3"]; $answer = $row["answer"]; echo "<tr><td colspan=3><br><b>$question</b></td></tr>"; echo "<tr><td>$opt1 <input type=radio name=q$id value=\"$opt1\"></td><td>$opt2 <input type=radio name=q$id value=\"$opt2\"></td><td>$opt3 <input type=radio name=q$id value=\"$opt3\"></td></tr>"; } echo "</table>"; echo "<input type='submit' value='See how you did' name='submit'>"; echo "</form>"; } elseif ($submit) { $score = 0; $total = mysql_num_rows($display); while ($result = mysql_fetch_array($display)) { $answer = $result["answer"]; $q = $result["q"]; if ($$q == $answer) { $score++; } } echo "<p align=center><b>You scored $score out of $total</b></p>"; echo "<p>"; if ($score == $total) { echo "Congratulations! You got every question right!"; } elseif ($score/$total < 0.34) { echo "Oh dear. Not the best score, but don't worry, it's only a quiz."; } elseif ($score/$total > 0.67) { echo "Well done! You certainly know your stuff."; } else { echo "Not bad - but there were a few that caught you out!"; } echo "</p>"; echo "<p>Here are the answers:"; echo "<table border=0>"; $display = mysql_query("SELECT * FROM $table ORDER BY id",$db); while ($row = mysql_fetch_array($display)) { $question = $row["question"]; $answer = $row["answer"]; $q = $row["q"]; echo "<tr><td><br>$question</td></tr>"; if ($$q == $answer) { echo "<tr><td>»you answered ${$q}, which is correct</td></tr>"; } elseif ($$q == "") { echo "<tr><td>»you didn't select an answer. The answer is $answer</td></tr>"; } else { echo "<tr><td>»you answered ${$q}. The answer is $answer</td></tr>"; } } echo "</table></p>"; } ?> thanks in adavance Hello I have one problem with fwrite() I have one script to get width and height from javascript and echo it with PHP. echo "Screen width is: ". $_GET['width'] ."<br />\n"; echo "Screen height is: ". $_GET['height'] ."<br />\n"; It works but i want to store the result in a file fwrite($info,"Height: $_GET['height'] <br />"); But then I get error Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING //////////////////////// it would be even better if I don't have to print the values but directly store them in $iinfo sorry if something similar was soved but those examples were different or i was unable to transform it to solve my problem I am trying to put a href on a line to link me to another php module, but get an error: Parse error: parse error in C:\wamp\www\editpolicy.php on line 47 My code: while ($row2 = mysql_fetch_array($result2) ) { print "<tr><td>"; <a href='editpayment.php?payid=$row2[PaymentID]'>$row2[PaymentID]</a> .........THIS IS LINE 47 ??? print "</td><td>"; print $row2['Actioned']; print "</td><td align='right'>"; print $row2['PremiumPaidAmount']; print "</td><td align='right'>"; print $row2['Risk']; print "</td></tr>"; } echo "</select></td>\r\n </tr>\r\n \r\n <tr>\r\n <td align=\"right\">Total Views Allowed:</td>\r\n <td><input type=\"text\" id=\"ad_total_views\" style=\"width:50px;\" value=\"\" disabled=\"disabled\" /> <label><input type=\"checkbox\" checked=\"checked\" onclick=\"if(this.checked==true){$('#ad_total_views').val('');$('#ad_total_views').attr('disabled','disabled');}else{$('#ad_total_views').val('');$('#ad_total_views').removeAttr('disabled');$('#ad_total_views').focus()}\" />Unlimited</label></td>\r\n </tr>\r\n \r\n <tr>\r\n <td align=\"right\">Total Clicks Allowed:</td>\r\n <td><input type=\"text\" id=\"ad_total_clicks\" style=\"width:50px;\" value=\"\" disabled=\"disabled\" /> <label><input type=\"checkbox\" checked=\"checked\" onclick=\"if(this.checked==true){$('#ad_total_clicks').val('');$('#ad_total_clicks').attr('disabled','disabled');}else{$('#ad_total_clicks').val('');$('#ad_total_clicks').removeAttr('disabled');$('#ad_total_clicks').focus()}\" />Unlimited</label></td>\r\n </tr>\r\n </table></td>\r\n </tr>\r\n <tr bgcolor=\"#FFFFFF\">\r\n <td class=\"td_th\" align=\"center\">Smarty Code (Developer)</td>\r\n <td>{\$ads->getAdCode(<span id=\"smartycode\">1</span>)}</td>\r\n </tr>\r\n <tr bgcolor=\"#FFFFFF\">\r\n <td class=\"td_th\" align=\"center\"> </td>\r\n <td><input type=\"button\" value=\"Create New Campaign\" onclick=\"new_ad()\" /></td>\r\n </tr>\r\n </TBODY></TABLE>\r\n<br />\r\n\r\n<TABLE cellSpacing=1 cellPadding=4 width=\"100%\" border=0>\r\n <TBODY>\r\n <TR class=\"td_title\">\r\n <TD colSpan=7>Ad Campaigns</TD></TR>\r\n <TR bgColor=#ffffff>\r\n \r\n <TD width=\"10%\" align=\"center\" class=\"td_th\"> </TD>\r\n <TD width=\"4%\" align=\"center\" class=\"td_th\">ID</TD>\r\n <TD width=\"29%\" align=\"center\" class=\"td_th\">Campaign Name</TD>\r\n <TD width=\"12%\" align=\"center\" class=\"td_th\">Start Date</TD>\r\n <TD width=\"11%\" align=\"center\" class=\"td_th\">End Date</TD>\r\n <TD width=\"17%\" align=\"center\" class=\"td_th\">Viewed / Views Allowed</TD>\r\n <TD width=\"17%\" align=\"center\" class=\"td_th\">Clicked / Clicks Allowed</TD>\r\n </TR>\r\n "; $BoxSize = array("smallbox" = array("length" => 12, "width" => 10, "depth" => 2.5), "mediumbox" = array("length" => 30, "width" => 20, "depth" => 4), "largebox" = array("length" => 60, "width" => 40, "depth" => 11.5)); Code: [Select] This is a clip of my PHP file: <?php $con = mysql_connect($host,$username,$password); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($database, $con); $result = mysql_query("SELECT * FROM purchase_order WHERE purchase_order_number=='$purchase_order_number'"); while($row = mysql_fetch_array($result)) { $vendor=$row['vendor']; $purchase_order_date=$row['purchase_order_date']; $ship=$row['ship']; $state=$row['state']; $fob=$row['fob']; $terms=$row['terms']; $buyer=$row['buyer']; $freight=$row['freight']; $req_date=$row['req_date']; $confirming_to=$row['confirming_to']; $remarks=$row['remarks']; $tax=$row['tax'] } // [i][u][b]<-- This is line 88 (The one with the error)[/b][/u][/i] ?>Thanks in advance! Hi! Code: [Select] $url = "http://www.youtube.com/watch?feature=player_embedded&v=IwPHy17Iu6E"; I have code Code: [Select] if (preg_match("/http:\/\/www.youtube.com\/watch\?v=([0-9a-zA-Z-_]*)(.*)/i", $url, $matches)) { return '<object height="'.$embed_height.'" width="'.$embed_width.'">'. '<param name="movie" value="http://www.youtube.com/v/'.$matches[1].'" />'. '<param name="wmode" value="transparent" />'. '<embed src="http://www.youtube.com/v/'.$matches[1].'&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" height="'.$embed_height.'" width="'.$embed_width.'" />'. '</object>'; }How to remove feature=player_embedded& from $url ? Hi guys, please help me to solve my problem. i want to get the url parameter using /
for now i use index.php?category_id=14
how can i change the ?category_id=14 to index.php/14
thank you so much.
Hi all
Is it possible to have a function with two parameters but and then check if one is passed before using it.
In this code here I want to remove spaces and change to lowercase.
If the $extra parameter is set I want to add that to the end of the string.
function className($nametoUse, $extra){ |