PHP - % Isn't Displayed Back From Mysql
Similar TutorialsI've spent the past 2 days googling and trying different methods that people have recommended other people try yet still I come up with the same problem. I am new to coding and I am learning the basic functions so all feedback is welcome in aiding my learning endeavor. I am using a form and all of the inputs are submitting to the database other than the text area which comes up blank. I do not get an error when submitting the form I just get a blank value for the text area 'Comments'.
FORM
<form action="contactdb.php" method="post" form="contactdb"/> Hello everyone. I'm creating a website that has a sort of messaging system built in and I'm trying to get the information pulled out of the database to display exactly as it was typed. For example, if someone types this message: "This is the first line. This is the second line. And this is two lines below the second line." (By the way, when I view this message using phpMyAdmin, the message is displayed in the above format.) I would like to have the message displayed the same way when it is queried from the database. As of now, this is what I'm seeing instead: "This is the first line. This is the second line. And this is two lines below the second line." How can I achieve this? I would post the code that I'm using, but it's just a basic mysql query to get a variable "$message" then I'm just using echo "$message"; to put it on the page. Any help to point me in the right direction would be greatly appreciated. Thanks! Ok so I have this site where I'm posting a message to my Database. But when I go to pull the message from the MYSQL DB it's one long sentence. Any suggestions? Hi am in processes of making a bespoke CMS for a project in uni am having a problem with my scrip basically i have three php files i have content which echos out the database tables i wish to edit with a link to an update_content page when u click on that it bring u too update_content.php which allows the user to modifier the content in the tables but when i hit update am getting a Parse error: syntax error, unexpected T_IF in line 4 of my update_ac file any help would be great cheers richie <?php require("includes/connection.php") // If form button has been pressed then do the following if(isset($_POST['update'])){ // Get id of post $id = $_GET['id']; $header = $_POST['header']; $content = $_POST['content']; // Update database table $query = "UPDATE pages SET header = '$header', content = '$content' WHERE id = '$id'"; $result = mysql_query($query); if ($result){ echo "Successfully edited entry"; } else { echo "There was error editing entry"; } } ?> I have these two tables...
schedule (gameid, homeid, awayid, weekno, seasonno)
teams (teamid, location, nickname)
This mysql query below gets me schedule info for ALL 32 teams in an array...
$sql = "SELECT h.nickname AS home, a.nickname AS away, h.teamid AS homeid, a.teamid AS awayid, s.weekno FROM schedule s INNER JOIN teams h ON s.homeid = h.teamid LEFT JOIN teams a ON s.awayid = a.teamid WHERE s.seasonno =2014"; $schedule= mysqli_query($connection, $sql); if (!$schedule) { die("Database query failed: " . mysqli_error($connection)); } else { // Placeholder for data $data = array(); while($row = mysqli_fetch_assoc($schedule)) { if ($row['away'] == "") {$row['away']="BYE";} $data[$row['homeid']][$row['weekno']] = $row['away']; $data[$row['awayid']][$row['weekno']] = '@ '.$row['home']; } }However, I only want to get info for one specific team, which is stored in the $teamid variable. This should be very easy, right? I have tried multiple things, including this one below (where I added an AND statement of "AND (h.teamid=$teamid OR a.teamid=$teamid)"), but this one still outputs too much... $sql = "SELECT h.nickname AS home, a.nickname AS away, h.teamid AS homeid, a.teamid AS awayid, s.weekno FROM schedule s INNER JOIN teams h ON s.homeid = h.teamid LEFT JOIN teams a ON s.awayid = a.teamid WHERE s.seasonno =2014 AND (h.teamid=$teamid OR a.teamid=$teamid)"; $schedule= mysqli_query($connection, $sql); if (!$schedule) { die("Database query failed: " . mysqli_error($connection)); } else { // Placeholder for data $data = array(); while($row = mysqli_fetch_assoc($schedule)) { if ($row['away'] == "") {$row['away']="BYE";} $data[$row['homeid']][$row['weekno']] = $row['away']; $data[$row['awayid']][$row['weekno']] = '@ '.$row['home']; } }Below is the array that the above outputs. In a nutshell, all I want is that 1st array ([1]) which has, in this example, the Eagles full schedule. It's not giving me too much else and I guess I could live with it and just ignore the other stuff, but I'd rather be as efficient as possible and only get what I need... Array ( [1] => Array ( [1] => Jaguars [2] => @ Colts [3] => Redskins [4] => @ 49ers [5] => Rams [6] => Giants [7] => BYE [8] => @ Cardinals [9] => @ Texans [10] => Panthers [11] => @ Packers [12] => Titans [13] => @ Cowboys [14] => Seahawks [15] => Cowboys [16] => @ Redskins [17] => @ Giants ) [27] => Array ( [1] => @ Eagles ) [28] => Array ( [2] => Eagles ) [4] => Array ( [3] => @ Eagles [16] => Eagles ) [14] => Array ( [4] => Eagles ) [15] => Array ( [5] => @ Eagles ) [3] => Array ( [6] => @ Eagles [17] => Eagles ) [] => Array ( [7] => @ Eagles ) [16] => Array ( [8] => Eagles ) [25] => Array ( [9] => Eagles ) [11] => Array ( [10] => @ Eagles ) [7] => Array ( [11] => Eagles ) [26] => Array ( [12] => @ Eagles ) [2] => Array ( [13] => Eagles [15] => @ Eagles ) [13] => Array ( [14] => @ Eagles ) ) Lets start out by saying I'm a nube to sql/php things so I am learning as I go. I try to read all that I can before I post, and only post when I cant figure it out on my own. That being said. What I want to do in simplest terms is be able to assign a variable to each item in an sql table. So say I have an mysql table that has ID, username, fontcolor. I want to be able to pull those out so say.... while($row = mysql_fetch_array($users)) { $username[$i] = $row[username]; $fontcolor[$i] = $row[fontcolor]; } Then on the page I can just call to $username[1] type thing. I have tried mixing this several different ways with for and while and I keep getting errors on the page. I realize the code isn't showing everything but its just there to show you the idea of what I'm trying to do. I just want it to generate a list(array) that will make it easier for me to call back just the items I need on parts of the page with out having to have extra coding everywhere. Thanks in advance. Jim Hello to all, I have problem figuring out how to properly display data fetched from MySQL database in a HTML table. In the below example I am using two while loops, where the second one is nested inside first one, that check two different expressions fetching data from tables found in a MySQL database. The second expression compares the two tables IDs and after their match it displays the email of the account holder in each column in the HTML table. The main problem is that the 'email' row is displayed properly while its while expression is not nested and alone(meaning the other data is omitted or commented out), but either nested or neighbored to the first while loop, it is displayed horizontally and the other data ('validity', 'valid_from', 'valid_to') is not displayed.'
Can someone help me on this, I guess the problem lies in the while loop? <thead> <tr> <th data-column-id="id" data-type="numeric">ID</th> <th data-column-id="email">Subscriber's Email</th> <th data-column-id="validity">Validity</th> <th data-column-id="valid_from">Valid From</th> <th data-column-id="valid_to">Valid To</th> </tr> </thead> Here is part of the PHP code:
<?php while($row = $stmt->fetch(PDO::FETCH_ASSOC)) { echo ' <tr> <td>'.$row["id"].'</td> '; while ($row1 = $stmt1->fetch(PDO::FETCH_ASSOC)) { echo ' <td>'.$row1["email"].'</td> '; } if($row["validity"] == 1) { echo '<td>'.$row["validity"].' month</td>'; }else{ echo '<td>'.$row["validity"].' months</td>'; } echo ' <td>'.$row["valid_from"].'</td> <td>'.$row["valid_to"].'</td> </tr>'; } ?>
Thank you. Please, take a look to the following code.After clicking Next it goes to overview.php.Why when I click back on my browser to return to this page again, it is not returning back? When I click back I receive "Confirm Form Resubmission" message. After refreshing page it loads page. I guess problem is in "session_start();" part. Something to do with cookies. Please, help me it is very urgent for me. <?php session_start(); echo "<html> <head> <title>Hello World</title> <meta http-equiv='Content-Type' content='text/html; charset=Windows-1252'/> </head>"; require_once ('functions.inc'); if(!isset($_POST['userid'])) { echo "<script type='text/javascript'>"; echo "window.location = 'index.php'"; echo "</script>"; exit; }else{ session_register("userid", "userpassword"); $username = auth_user($_POST['userid'], $_POST['userpassword']); if(!$username) { $PHP_SELF = $_SERVER['PHP_SELF']; session_unregister("userid"); session_unregister("userpassword"); echo "Authentication failed " . "Please, write correct username or password. " . "try again "; echo "<A HREF=\"index.php\">Login</A><BR>"; exit; } } function auth_user($userid, $userpassword){ global $default_dbname, $user_tablename; $user_tablename = 'user'; $link_id = db_connect($default_dbname); mysql_select_db("d12826", $link_id); $query = "SELECT username FROM $user_tablename WHERE username = '$userid' AND password = '$userpassword'"; $result = mysql_query($query) or die(mysql_error()); if(!mysql_num_rows($result)){ return 0; }else{ $query_data = mysql_fetch_row($result); return $query_data[0]; } } echo "hello"; echo "<form method='POST' name='myform' action='overview.php'>"; echo "<input type='submit' value='Next'>"; echo "</form>"; ?> Say I have the following text stored in a MySQL database... Code: [Select] <b>Classic Quote from movie</b> and I retrieve it into a variable called $text, how do I properly echo that so that it keeps the bold tags and actually display the text "Classic quote from movie" in BOLD? I'm doing something wrong somewhere along the line (simply doing "echo $text;") because it displays on the page as... Code: [Select] <b>Classic Quote from movie</b> Instead of... Classic Quote from movie Any info on properly storing and echoing back HTML would be very appreciated. Hi, I am generating certificates in php i can display the name in arabic but it will not print on the certicate. It can show the English names though! is there a special code to be able to show that? code: <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> <title>Certificate Generator</title> </head> <body> <center> <br><br><br> <h3>Certificate Generator</h3> <br><br><br><br> <form method="post" action=""> <div class="form-group col-sm-6"> <input type="text" name="name" class="form-control" id="name" placeholder="Enter Name Here..."> </div> <button type="submit" name="generate" class="btn btn-primary">Generate</button> </form> <br> <?php if (isset($_POST['generate'])) { $name = strtoupper($_POST['name']); $name_len = strlen($_POST['name']); if ($name == "" ) { echo " <div class='alert alert-danger col-sm-6' role='alert'> Ensure you fill all the fields! </div> "; }else{ echo " <div class='alert alert-success col-sm-6' role='alert'> Congratulations! $name on your excellent success. </div> "; //designed certificate picture $image = "certi.png"; $createimage = imagecreatefrompng($image); //this is going to be created once the generate button is clicked $output = "certificate.png"; //then we make use of the imagecolorallocate inbuilt php function which i used to set color to the text we are displaying on the image in RGB format $white = imagecolorallocate($createimage, 205, 245, 255); $black = imagecolorallocate($createimage, 0, 0, 0); //Then we make use of the angle since we will also make use of it when calling the imagettftext function below $rotation = 0; //we then set the x and y axis to fix the position of our text name $origin_x = 200; $origin_y=240; //we then set the x and y axis to fix the position of our text occupation $origin1_x = 120; $origin1_y=90; //we then set the differnet size range based on the lenght of the text which we have declared when we called values from the form if($name_len<=7){ $font_size = 25; $origin_x = 190; } elseif($name_len<=12){ $font_size = 30; } elseif($name_len<=15){ $font_size = 26; } elseif($name_len<=20){ $font_size = 18; } elseif($name_len<=22){ $font_size = 15; } elseif($name_len<=33){ $font_size=11; } else { $font_size =10; } $certificate_text = $name; //font directory for name $drFont = dirname(__FILE__)."/developer.ttf"; //function to display name on certificate picture $text1 = imagettftext($createimage, $font_size, $rotation, $origin_x, $origin_y, $black,$drFont, $certificate_text); imagepng($createimage,$output,3); ?> <!-- this displays the image below --> <img src="<?php echo $output; ?>"> <br> <br> <!-- this provides a download button --> <a href="<?php echo $output; ?>" class="btn btn-success">Download My Internship Certificate</a> <br><br> <?php } } ?> </center> <footer> <center><p>Built with ❤ by <a href="https://olawanlejoel.github.io/portfolio/">Olawanle Joel</a></p></center> </footer> <!-- Optional JavaScript --> <!-- jQuery first, then Popper.js, then Bootstrap JS --> <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> </body> </html> Edited May 22, 2020 by ramiwahdan typo error I am trying to run a php code on my site but it kept on saying page cannot be found. Any idea why its saying that??? I want to output the data and also the buttons in my php codes. But i do not know why the buttons does not output as coded. Can anyone let me know where did my codes go wrong? I've been searching it but i cant't find the problem. Thanks in advance. <?php if(isset($_POST['invoice_details'])) { $discountsql = "INSERT INTO `invoice_price` (`order_id`) VALUES ('.$order_id.') "; $conn->query($discountsql); } ?> <?php $sql2 = " SELECT order_id FROM ordered_items GROUP BY order_id WHERE order_id = '".$row[order_id]."' "; $query2 = $conn -> query($sql2); while ($row2 = $query2 -> fetch_assoc()) { ?> <div class="col-12 form-group"> <p> <?php echo $row2['order_id']; ?></p> <p class="text-success" pointer-events="none" style="font-weight: bold; font-size: 25px; text-align:center; ">Your order is confirmed !</p> <a href="order-list.php"> <input class="btn btn-block checkoutbtn" type="button" name="invoice_details" value="Go to Order Page"> </a> </div> <?php } ?>
Code: [Select] function my_fav_quote_show_optin_form() { if (!empty($_POST['my_fav_quote_email'])) { my_fav_quote_opt_in(); } $out2 = ''; $out = '<form action="" name="myform "method="post" id="requestQuote">'; $out .= '<table style="padding="0px" width="40px">'; $out .= '<tr><td>Name:*</td><td><input type="text" name="my_fav_quote_name" id="my_fav_quote_name"/></td></tr>'; $out .= ''; $out .= '<tr><td>Email:*</td><td><input type="text" name="my_fav_quote_email" id="my_fav_quote_email"/></td></tr>'; $out .= ''; $out .= '<tr><td>Phone:*</td><td><input type="text" name="my_fav_quote_phone" id="my_fav_quote_phone"/></td></tr>'; $out .= ''; $out .= '<tr><td>Event Date(optional):</td><td><input type="text" name="my_fav_quote_date" id="my_fav_quote_date"/></td></tr>'; $out .= ''; $out .= '<tr><td>Estimated Number of Guests(optional):</td><td><input type="text" name="my_fav_quote_guest" id="my_fav_quote_guest"/></td></tr>'; $out .= ''; $out .= '<tr><td>Desired Price Range Per Person (optional):</td><td><input type="text" name="my_fav_quote_rate" id="my_fav_quote_rate"/></td></tr>'; $out .= ''; $out .= '<tr><td style="vertical-align: middle;">Message:<br>(List your special requests, any food allergies , event description , special menu items that are not listed or any other information you think will helpful) </td><td><textarea placeholder="" name="my_fav_quote_message" id="my_fav_quote_message"></textarea></td></tr>'; $out .= ''; $out .= '<tr><td>Security code:*</td><td><img src='.get_bloginfo('wpurl').'/wp-content/plugins/quote-cart/captcha.php?width=60&height=30&characters=5" /></td></tr>'; $out .= ''; $out .= '<tr><td>Input Above Security Code He *</td><td><input type="text" name="security_code" id="security_code" size="5"></td></tr>'; $out .= ''; $out .='<tr><td colspan="2">'; if ( function_exists( 'my_fav_quote_display' ) ){ $out .= my_fav_quote_display(); } if ( function_exists( 'my_fav_quote_display3' ) ){ $out .= my_fav_quote_display3(); } $out .='</td></tr>'; $out .= '<tr><td colspan=2 align=center><input type="submit" value="Request Quote" onclick="return chk_validation()" style="background-color:#000;color:#FFF;padding:5px;margin-top:10px;border:none;cursor:pointer;"/> <input type="button" onclick="formReset()" value="Reset form" /> </td></tr>'; $out .='</table></form>'; echo $out; ?> <script language="javascript" type="text/javascript"> //<![CDATA[ function validate_email(field,alerttxt) { apos=field.indexOf("@"); // alert(apos); dotpos=field.lastIndexOf("."); //alert(dotpos); if (apos<1||dotpos-apos<2) { return false;} else {return true;} } function chk_validation() { if(document.getElementById("my_fav_quote_name") && document.getElementById("my_fav_quote_name").value == '') { alert("Please Enter Name"); document.getElementById("my_fav_quote_name").focus(); return false; } if(document.getElementById("my_fav_quote_email").value == '') { alert("Please Enter Email"); document.getElementById("my_fav_quote_email").focus(); return false; } else { //alert(validate_email(document.getElementById("my_fav_quote_email").value,"Not a valid e-mail address!"); if (validate_email(document.getElementById("my_fav_quote_email").value,"Please enter valid e-mail address!")==false) { alert("Please enter valid e-mail address!"); document.getElementById("my_fav_quote_email").focus(); return false; } } if(document.getElementById("security_code").value == '') { alert("Please Enter Security Code"); document.getElementById("security_code").focus(); return false; } if(document.getElementById("quotes").value == '') { alert("Please add atleast one request quote"); document.getElementById("quotes").focus(); return false; } //return true; } //]]> </script> <?php } i need a form reset the actual problem is the normal reset is only reseting the fields but i need the information displayed using functions should also be reseted Hey All, As of this morning our gallery has started to show the incorrect dates. Please go to: http://www.nightlifeguestlist.com/c...n/74/Carbon.htm you will see the first date is Fri, 29 October 10 this should be Sat, 30 October 10. In the database the date is in putted as 2010-10-30. The dates from Fri, 29 October 10 to Fri, 2 April 10 are all incorrect. These happen to be all BST times. While the dates for GMT are OK. The clocks here in the UK are now GMT and not BST. Has this anything to do with it? The code used is as follows: <? $location = false; if(isset($_GET['l'])){ $location = $_GET['l']; } $venue = false; if(isset($_GET['v'])){ $venue = $_GET['v']; } $event = false; if(isset($_GET['e'])){ $event = $_GET['e']; } $page = 0; if(isset($_GET['p'])){ $page = $_GET['p']; $page--; } $query_events = ""; if(!$location){ $query_events = "SELECT ec_venues.location FROM ec_venues GROUP BY ec_venues.location"; } else if($location && !$venue && !$event){ $query_events = "SELECT ec_venues.venue_name, UNIX_TIMESTAMP(ec_events.event_date) AS event_date, ec_venues.venue_id, ec_events.event_id,ec_venues.location FROM ec_events INNER JOIN ec_venues ON ec_events.venue_id = ec_venues.venue_id WHERE ec_events.event_date IS NOT NULL AND ec_venues.location='".$location."' ORDER BY UNIX_TIMESTAMP(ec_events.event_date) DESC LIMIT 0,1"; } else if($venue && !$event){ $query_events = "SELECT UNIX_TIMESTAMP(ec_events.event_date) AS event_date, ec_venues.venue_name, ec_venues.venue_id, ec_events.event_id, ec_events.event_name,ec_venues.location FROM ec_events INNER JOIN ec_venues ON ec_events.venue_id = ec_venues.venue_id WHERE ec_venues.venue_id=".$venue." ORDER BY UNIX_TIMESTAMP(ec_events.event_date) DESC"; } else if($venue && $event){ $query_events = "SELECT ec_venues.venue_name, ec_events.event_name, UNIX_TIMESTAMP(ec_events.event_date) AS event_date, ec_events.image_folder, ec_venues.images_per_page,ec_venues.location FROM ec_events INNER JOIN ec_venues ON ec_events.venue_id = ec_venues.venue_id WHERE ec_events.event_id=".$event." AND ec_venues.venue_id=".$venue.""; } mysql_select_db($database_nightlife2 , $nightlife2 ); // $query_events = "SELECT ec_venues.venue_name, ec_events.event_name, UNIX_TIMESTAMP(ec_events.event_date) AS event_date, ec_events.image_folder, ec_venues.images_per_page FROM ec_events INNER JOIN ec_venues ON ec_events.venue_id = ec_venues.venue_id WHERE ec_events.event_id=".$event." AND ec_venues.venue_id=".$venue.""; //echo $query_events; $events = mysql_query($query_events, $nightlife2 ) or die(mysql_error()); $row_events = mysql_fetch_assoc($events); $totalRows_events = mysql_num_rows($events); ?> <!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=iso-8859-1" /> <title><?=(!$location?"Elite Parties Photos":"Nightlife Guestlist @ ".$location." Club - ".$row_events['venue_name'])?></title> <link href="http://www.nightlifeguestlist.com/wp-content/themes/NLGL/style.css" rel="stylesheet" type="text/css" /> <!--[if IE 6]> <link rel="stylesheet" type="text/css" href="http://www.nightlifeguestlist.com/wp-content/themes/NLGL/IE-6.css" /> <![endif]--> <!--[if IE]> <link rel="stylesheet" type="text/css" href="http://www.nightlifeguestlist.com/wp-content/themes/NLGL/IE-8.css" /> <![endif]--> <? if($_SERVER['HTTP_HOST']=="elite"){?> <BASE HREF="http://elite/"> <? } else { ?> <BASE HREF="http://www.nightlifeguestlist.com/"> <? } ?> <SCRIPT language="JavaScript" src="/mircoFinestra.js"></script> <script src="/AC_RunActiveContent.js" type="text/javascript"></script> </style> </head> <body> <div class="wrapper"> <div id="head"> <div id="header"> </div> <!-- nav --> <div id="nav"> <div id="nav-area"> <ul> <li class='page_item current_page_item'><a href='http://www.nightlifeguestlist.com' title='Home'>Home</a></li><li class="page_item page-item-3"><a href="http://www.nightlifeguestlist.com/guest-lists" title="Guest Lists">Guest Lists</a></li> <li class="page_item page-item-5"><a href="http://www.nightlifeguestlist.com/photogallery.php" title="Photo Gallery">Photo Gallery</a></li> <li class="page_item page-item-7"><a href="http://www.nightlifeguestlist.com/video-gallery" title="Video Gallery">Video Gallery</a></li> <li class="page_item page-item-9"><a href="http://www.nightlifeguestlist.com/jobs" title="Jobs">Jobs</a></li> <li class="page_item page-item-11"><a href="http://www.nightlifeguestlist.com/membership" title="Mailing List">Mailing List</a></li> <li class="page_item page-item-16"><a href="http://www.nightlifeguestlist.com/tables" title="Tables">Tables</a></li> <li class="page_item page-item-13"><a href="http://www.nightlifeguestlist.com/event-management" title="Event Management">Event Management</a></li> <li class="page_item page-item-538"><a href="http://www.nightlifeguestlist.com/blog" title="Blog">Gossip Blog</a></li> </ul> </div> </div> <!-- end nav --> <div class="clear"></div> </div> <!--/head --> <div class="narrowcolumn"> <div class="entry"> <div id="content-area"> <!-- 1 --> <div id="section"> <? if($venue && !$event){ ?><?php $pCount = 0; $myNum = sprintf("%02d",$venue); echo "<img src='interiors/" . $myNum . "_logo.gif' vspace='2' hspace='2'>\n"; if ($handle = opendir('interiors')) { while (false !== ($file = readdir($handle))) { if (substr($file,0,6) == $myNum . "_pic") { echo '<img src="interiors/' . $file . '" vspace="2" hspace="2">'; if($pCount++ % 2 == 1) echo ""; } } closedir($handle); } ?> <? } ?> <? if(!$location){?> <!-- 2 --> <div id="section"> <? do{ $query_latest = "SELECT ec_venues.venue_name, UNIX_TIMESTAMP(ec_events.event_date) AS event_date, ec_venues.venue_id, ec_events.event_id FROM ec_events INNER JOIN ec_venues ON ec_events.venue_id = ec_venues.venue_id WHERE ((ec_events.event_date) IS NOT NULL) AND ec_venues.location='".$row_events['location']."' ORDER BY UNIX_TIMESTAMP(ec_events.event_date) DESC LIMIT 0,1"; $latest = mysql_query($query_latest, $nightlife2 ) or die(mysql_error()); $row_latest = mysql_fetch_assoc($latest); $totalRows_latest = mysql_num_rows($latest); ?> <a href="club_dates/<?=$row_events['location']?>/<?=$row_latest['venue_id']?>/<?=$row_latest['event_id']?>/<?=str_replace(" ","_",$row_latest['venue_name'])?>_page1.htm "><?=$row_events['location']?> - <?php echo date("l jS F",$row_latest['event_date']); ?> @ <?php echo $row_latest['venue_name']; ?></a><br> <? } while ($row_events = mysql_fetch_assoc($events)); mysql_free_result($latest); ?> </div> <!-- 3 --> <div id="section"> <? } else if(!$venue){ ?> </div> <!-- 4 --> <div id="section"> Our most recent event was <strong><a style="color:#000000; font-weight:bold;" href="club_dates/<?=$row_events['location']?>/<?=$row_events['venue_id']?>/<?=$row_events['event_id']?>/<?=str_replace(" ","_",$row_events['venue_name'])?>_page1.htm "><?php echo date("l jS F",$row_events['event_date']); ?> @ <?php echo $row_events['venue_name']; ?></a></strong> <? } else if($venue && !$event){?> </div> <!-- 5 --> <div id="section"> <table width="100%" border="0" align="left" cellpadding="0" cellspacing="10"> <tr> <td colspan="4"><? if($totalRows_events==0){ ?> No photos are avaliable yet for this venue. <? } else { ?> Select a Date for <?php echo $row_events['venue_name']; ?> <? } ?> </td> </tr> <? $count = 0; do { if($count % 3 == 0){ echo '<tr>'; } ?> <td width="713"><a style="color:#000000; font-weight:bold;" href="club_dates/<?=$location?>/<?=$venue?>/<?=$row_events['event_id']?>/<?=str_replace(" ","_",$row_events['venue_name'])?>_page1.htm"><? echo ($row_events['event_date']==""?$row_events['event_name']:date("D, j F y",$row_events['event_date'])); ?></a></td> <?php if($count % 3 == 2){ echo "</tr>"; } $count++; } while ($row_events = mysql_fetch_assoc($events)); echo str_repeat("<td> </td>",4-($count % 4)); ?> </table> </div> <!-- 6 --> <div id="section"> <? } else if($venue && $event){ ?> </div> <!-- 7 --> <div id="section"> <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0"> <tr> <td><? if ($dir = @opendir("photos/".$row_events['image_folder'])){ while (($file = readdir($dir)) !== false) { if(substr($file,0,4) == "page"){ $dirlist[] = $file; } } sort ($dirlist); reset ($dirlist); closedir($dir); } if ($dir = @opendir("photos/".$row_events['image_folder']."/".$dirlist[$page])){ while (false !== ($file = readdir($dir))) { if(substr($file,-3)=="jpg"){ $imglist[] = $file; } } usort($imglist,"strnatcmp"); reset ($imglist); closedir($dir); } $count = 0; $paging = ""; if($page==0){ $paging .= "<< "; } else $paging .= "<a href='/club_dates/".$location."/".$venue."/".$event."/".str_replace(" ","_",$row_events['venue_name'])."_page".($page).".htm' style='color:#000000; font-weight:bold;'><<</a> "; foreach($dirlist as $f){ if($page!=$count){ $paging .= "<a href='/club_dates/".$location."/".$venue."/".$event."/".str_replace(" ","_",$row_events['venue_name'])."_page".($count+1).".htm' style='color:#000000; font-weight:bold;'>".($count+1)."</a> "; } else { $paging .= ($count+1)." "; } $count++; } if($page==count($dirlist)-1){ $paging .= ">> "; } else $paging .= "<a href='/club_dates/".$location."/".$venue."/".$event."/".str_replace(" ","_",$row_events['venue_name'])."_page".($page+2).".htm' style='color:#000000; font-weight:bold;'>>></a>"; ?></td> </tr> <tr> <td><? echo "<table width='720'><tr><td>Nightlife Guestlist @ ".$row_events['venue_name'].($row_events['event_date']!="" ?" - ".date("l jS F Y", $row_events['event_date']) : "")." - ".$location."</td><td align='right'>".$paging."</td></tr></table>\n"; ?></td> </tr> <tr> <td><? for($count=0;$count<count($imglist);$count++){ echo "<a href='javascript:;'><img alt='".$imglist[$count]." @ ".$location." Club ".$row_events['venue_name'].", ".date("jS F Y", $row_events['event_date'])."' border='0' width='90px' height='60px' hspace='5px' vspace='5px' src='"."photos/".$row_events['image_folder']."/".$dirlist[$page]."/thumbs/".$imglist[$count]."' onclick='NewWindow(\"/popup.php?t=".count($imglist)."&n=".$count."&f=".$row_events['image_folder']."&p=".$dirlist[$page]."&title=".urlencode($location." Club ".$row_events['venue_name']." on ".date("jS F Y", $row_events['event_date']))."\",\"name\",\"600\",\"420\",\"no\");return false;'></a>\n"; if($count % 7 == 6){ echo "<br>\n"; } } ?> <? } ?></td> </tr> <tr> <td> </td> </tr> </table> </div> <div id="section"> <? if(!$location){ ?> <? } else { include("getClubLogos.php"); } ?> (Sorry for the amount of code!) I use the same code for another site on another server and it works fine. I guess I need to alter the code somehow? The gallery works ok just the dates show are wrong. Any ideas on how to fix this? The server settings/time seems are OK. The line which prints the date is:<? echo ($row_events['event_date']==""?$row_events['event_name']:date ("D, j F y", $row_events['event_date'])) ; ?> When I echo the date echo date('c'); I receive 2010-10-29T23:00:00+00:00 for Fri, 29 October 10. Thanks Is there a way to have the values that are DISPLAYED by a FORM actually result in another set of VALUES actually being returned? For example, having arbitrary values displayed to the user to generate another set of values? Thanks! I have following error when i try to enter my student info into the database. ! ) Warning: Header may not contain more than a single header, new line detected. in C:\wamp\www\Student registration\new student registration\newStudentRegistrationFormvalidation.php on line 43 newStudentRegistrationFormvalidation.php <?php $admission_no=$_POST['admission_no']; $admission_date=$_POST['admission_date']; $full_name=$_POST['full_name']; $name_with_initial=$_POST['name_with_initial']; $date_of_birth=$_POST['date_of_birth']; $religion=$_POST['religion']; $address=$_POST['address']; $telephone=$_POST['telephone']; $grade_on_admission=$_POST['grade_on_admission']; $grade_ID=$_POST['grade_ID']; $stream_ID=isset($_POST['stream_ID']) ? $_POST['stream_ID'] :''; $class_ID=$_POST['class_ID']; $student_house=$_POST['student_house']; $password=$_POST['password']; $description_about_st=$_POST['description_about_st']; $payment=$_POST["payment"]; $currentdate=getdate(time()); $year=$currentdate["year"]; //admission number validation $answer=''; $con=mysql_connect("localhost","root",""); mysql_select_db("student_management",$con); $query="SELECT admission_no FROM student_info WHERE student_info.admission_no='$admission_no'"; $result=mysql_query($query); while($row=mysql_fetch_array($result)){ $answer=$row['admission_no'];} if($answer==0) { //line 43 header("location:student registrationDatabase.php?admission_no=".$admission_no."&year=".$year."&admission_date=".$admission_date."&full_name=".$full_name."&name_with_initial=".$name_with_initial."&date_of_birth=".$date_of_birth."&religion=".$religion."&address=".$address."&telephone=".$telephone."&grade_on_admission=".$grade_on_admission."&grade_ID=".$grade_ID."&stream_ID=".$stream_ID."&class_ID=".$class_ID."&student_house=".$student_house."&password=".$password."&description_about_st=".$description_about_st."&payment=".$payment); exit(); }else{ ?> <body> <?php echo "Admission number".$admission_no."This student has been alredy entered to the system ."."<BR>"."<BR>"."<BR>"; echo "<a href='newStudentRegistrationForm.php'>GO to manage student details page</a> "; exit(); }?> studentregistrationDatabase.php <?PHP $admission_no=$_POST['admission_no']; $admission_date=$_POST['admission_date']; $full_name=$_POST['full_name']; $name_with_initials=$_POST['name_with_initial']; $dob=$_POST['date_of_birth']; $religion=$_POST['religion']; //$gender=$_GET['gender']; $address=$_POST['address']; $telephone=$_POST['telephone']; $grade_on_admission=$_POST['grade_on_admission']; $present_grade=$_POST['grade_ID']; $stream=$_POST['stream_ID']; $present_class=$_POST['class_ID']; $student_house=$_POST['student_house']; $password=$_POST['password']; $description_about_st=$_POST['description_about_st']; $payment=$_POST["payment"]; $current=getdate(time()); $year=$current["year"]; $today = date("Y-m-d"); $con=mysql_connect("localhost","root",""); mysql_select_db("student_management",$con); //insert to database $query="select count(*) from student_info where admission_no='$admission_no'"; $result=mysql_query($query); $row=mysql_fetch_array($result); if($row[0]==0) { $query="insert into student_info values(null,'$admission_no','$admission_date','$full_name','$name_with_initials','$dob','$religion','$address','$telephone','$grade_on_admission','$password','$student_house','$description_about_st')"; $result=mysql_query($query); if($stream!=null){ $query="select class_id from class where class.grade_id='$present_grade' and class.class_name='$present_class' and class.stream='$stream'"; }else{ $query="select class_id from class where class.grade_id='$present_grade' and class.class_name='$present_class'"; } $result=mysql_query($query); while($row=mysql_fetch_array($result)){ $class_id=$row['class_id']; } $query="insert into student_class values('$admission_no','$class_id','$year')"; $result=mysql_query($query); if($payment=="2000") { $query="insert into payment_amount values(null,'2000','$today')"; $result=mysql_query($query); $query="SELECT amount_id FROM payment_amount order by amount_id DESC limit 1"; $result=mysql_query($query); while($row = mysql_fetch_array($result)) { $amount_id=$row['amount_id']; } $query="insert into payment values('$admission_no','$amount_id')"; $result=mysql_query($query); }else{ $query="insert into payment_amount values(null,'0','$today')"; $result=mysql_query($query); $query="SELECT amount_id FROM payment_amount order by amount_id DESC limit 1"; $result=mysql_query($query); while($row = mysql_fetch_array($result)) { $amount_id=$row['amount_id']; } $query="insert into payment values('$admission_no','$amount_id')"; $result=mysql_query($query); } header("location:../new student registration-parent details/studentRegistrationParentDetailsForm.php?admission_no=".$admission_no); exit(); } else{ ?> <?php echo "Admission number".$admission_no."This student has been already entered to the system"."<BR>"."<BR>"."<BR>"; echo "<a href='student registration.php'>GO to registration page</a>"; exit(); } ?> when I test this script on browser. This is all that I see. invalid username or password Code: [Select] <?php //start session session_start(); include 'functions.php'; if (loggedin()) { header("Location: userarea.php"); exit(); } if ($_POST['login']) { //get data $username = $_POST['username']; $password = $_POST['password']; $rememberme = $_POST['rememberme']; } if (username&&$password) { $login = mysql_query("SELECT * FROM users WHERE username='$username'"); while ($row = mysql_fetch_assoc($login)) { $db_password = $row['password']; if (md5($password)==$db_password) $loginok =TRUE; else $loginok = FALSE; if ($loginok ==TRUE); { if($rememberme=="on") setcookie("username",$username, time()+7200); else if ($rememberme=="") $_SESSION['username']=$username; header("Location: userarea.php"); exit(); } } } else { die("invalid username or password"); } ?> <form action="login.php" method="POST"> username:<br /> <input type="text" name="username" /><br /> password:<br /> <input type="password" name="password" /><br /> <input type="checkbox" name="rememberme">remember me<br /> <input type="submit" name="login" value="Log in" /> </form> Hi all, I want to get the current page name as displayed in the URL, not neccesarily the name of the PHP script that is running. E.g. I have a PHP file 'home.php' that contains iframes that contain other PHP files such as 'frame1.php'. What I want is a script that can be run from frame1.php but that will return 'home.php' as the current page (as displayed in the URL in the browser). How do I do this? Thanks! so I am a beginner and have this very beginner-level PHP doubt. I have some basic code which is supposed to fetch the contents of a table and then display them in a table. What it's actually showing is the PHP code itself, instead of the table contents, in the browser. I'm using WAMP When I searched the net reasons given were 1. using short tags, and 2. some configuration problem. I haven't used short tags, and my wamp installation was done a long time back. Moreover this problem is not occuring all the time, even when I run the same code. Many thanks if anyone can suggest anything helpful. Sorry if I posted in the wrong place (new here). I'm teaching myself how to use php and mysql... I created a form to insert data into a mysql database, all went well and when I returned to the form it was blank. I then asked a friend to test it out aswell and when he loaded the form page, the data that entered before him was displayed? (it was still filled out with my info). Even after he refreshed it was still there... Hows this possible? How would I clear the form after its been submitted if it doesnt do it automatically? Thanks Drew |