PHP - Echo Table Statement Won't Work
// Other code //echo "<table border='10' cellpadding='3' cellspacing='2'>"; This works echo "<table class="my-table">"; //This does not work echo "<tr><th>First Name</th><th>Last Name</th><th>Home Phone</th><th>Cell Phone</th><th>email</th></tr>"; // keeps getting the next row until there are no more to get ================ while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table ========================== echo "<tr><td>"; echo $row['first']; echo "</td><td>"; echo $row['last']; echo "</td><td>"; echo $row['phone']; echo "</td><td>"; echo $row['cell']; echo "</td><td>"; echo $row['email']; echo "</td></tr>"; } echo "</table>"; ?> Error message: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/bayare27/public_html/content/pages/display_all_members1.php on line 29 Line 29 is: echo "<table class="my-table">"; <table class="my-table">" is a valid statement because It works in another program, but html not php Similar TutorialsI am using the Twitch API to tell if a user is live. I'm new to the Twitch API and PhP so please forgive me if I make any mistakes. Expand the Spoiler tags below to see the code. The code below SHOULD be telling me if a channel is not live or not. It tells me if they are live, but not if they are not live. I don't understand.
Spoiler
<?php if (!empty($_GET['channel'])) { $channel = $_GET['channel']; $dataArray = json_decode(@file_get_contents('https://api.twitch.tv/kraken/streams?channel='.$channel), true); foreach ((array) $dataArray['streams'] as $mydata) { if (!empty($mydata['_id'])) { echo "Channel is live<br><br>"; $uptime = $mydata['created_at']; $uptime = str_replace("Z", "UTC", $uptime); $uptime = preg_replace("/T/", "", $uptime, 1); echo "Twitch Uptime: ".$uptime."<br />"; date_default_timezone_set('UTC'); $localUptime = date('Y-m-dh:i:sT', time()); echo "UTC Local Time: ".$localUptime; } else { echo "Channel is not live"; } } } else { echo "No channel"; } ?> I am having a problem echoing a line of code. I am doing this on my local machine. Anyway, here are the to files involved... home.php <?php include $_SERVER['DOCUMENT_ROOT'] . '/includes/helpers.inc.php'; include $_SERVER['DOCUMENT_ROOT'] . '/includes/doctype.inc.php'; include $_SERVER['DOCUMENT_ROOT'] . '/includes/head.inc.php'; ?> </head> <body> <div id="wrapper"> <!-- start horizontal navigation --> <?php include $_SERVER['DOCUMENT_ROOT'] . '/includes/topnav.inc.php'; ?> <!-- end horizontal navigation --> <div id="content"> <h1><?php echo htmlout($cattitle); ?></h1> <span class="desc"><?php echo ($catdesc); ?></span> <?php include $_SERVER['DOCUMENT_ROOT'] . '/info.php'; ?> </div> <!-- start footer --> <?php include $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc.php'; ?> <!-- end footer --> </div> </body> </html> and info.php <?php $result = mysqli_query($link, 'SELECT * From includes where catid ='.$_GET['id']); if (!$result) { $error = 'Error getting categories: ' . mysqli_error($link); include 'error.php'; exit(); } while ($row = mysqli_fetch_array($result)) { $inc[] = array('id' => $row['id'], 'include' => $row['include'], 'inc_orderby' => $row['inc_orderby'], 'inc_avail' => $row['inc_avail']); } foreach ($inc as $include): { echo "include $_SERVER['DOCUMENT_ROOT'] . '/includes/' . $row['include'];"; } endforeach; ?> I can't get the echo statement at the bottom of info.php echo "include $_SERVER['DOCUMENT_ROOT'] . '/includes/' . $row['include'];"; to show up correctly on the home.php page in this spot. include $_SERVER['DOCUMENT_ROOT'] . '/info.php'; what i am attempting to do is loop through some additional information relevant to the page a user selects on the site and display it. (I still have to set up some qualifying statements but this was just the first step to see if anything would show up) This is the parse error I get. Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\info.php on line 18 I've tried messing with the quotes in the echo statement cause I'm sure they aren't right but I never came up with a quote combination that worked. I'm assuming that is the problem. Anyway thanks for taking a look. Welcome member. I am able to get data added to my db and when it gets to the welcome page I want it to welcome $firstname but it comes up blank. How can I fix my echo statement. <?php session_id(); session_start(); ?> <!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>Welcome</title> </head> <body> <?php /* Program: New_member.php * Desc: Displays the new member welcome page. Greets * member by name and gives a choice to enter * restricted section or go back to main page. */ if (@$_SESSION['auth'] != "yes") @include('Connections/connect_to_mysql.php'); $result = mysql_query("SELECT firstname FROM `Members` WHERE id='{$_SESSION['id']}'"); $row = mysql_fetch_array($result); echo "<html> <head><title>New Member Welcome</title></head> <body> <h2 style='margin-top: .7in; text-align: center'> Welcome, $firstName </h2>\n"; ?> <p>Your new Member accounts lets you enter the members only section of our web site. You'll find special discounts, a profile of matches, live advise for experts, and much more.</p> <p>Your new Member ID and password were emailed to you. Store them carefully for future use.</p> <div style="text-align: center"> <p style="margin-top: .5in; font-weight: bold"> Glad you could join us!</p> <form action="profile.php" method="post"> <input type="submit" value="Enter the Members Only Section"> </form> <form action="index.php" method="post"> <input type="submit" value="Go to Main Page"> </form> </div> </body> </html> I want to add a space after $item in the below statement so that there is more space between the output of Item and Qty. Hello guys im new to php i been coding for like a week now, i need some help here i have been stuck for like 6 hours XD,is it possible to write an IF Statement inside an echo? //this is what i want to do // echo a table and a delete button // and if you click on the delete button it echoes out "DELETED" echo " <table width='528px'> <tr> <td> </td> <td> <center><font size='5'>$tittle</font></center><br> </td> </tr> <tr> <td> </td> <td> $message </td> </tr> <tr> <td> </td> <td> <font size='1'>Posted By:<font color='green'>$author</font> on <font color='gray'>$date</font> at <font color='gray'>$time</font></font> <input id='delete' name='delete' type='submit' value='Delete' > if ($_POST['delete']) { echo "DELETED"; } <td> </td> </tr><br><br> </table> "; Hello,
I am working on this function that echo's out images from my database restricted to 10 images with 4 default images if the database is empty.
<?php $query = mysql_query('SELECT image_id, image_expiry FROM images ORDER BY RAND() LIMIT 10'); $i = 0; class myCounter3 implements Countable { public function count() { static $count = 0; return ++$count; } } $counter = new myCounter3; while ($row = mysql_fetch_array($query)) { if($i % 10 === 0) { } echo '<img src="http://www.mysite.com/'.$row['image_id'].'.jpg" width="300" height="auto"/>'; $i++; } for (; $i <= 4; $i++) { echo '<img src="http://www.mysite.com/default.jpg" width="300" height="auto"/>' } ?>I need to include an image expiry function with the function above, but I am not sure how to properly include it. Here is my planned expiry function (each image as an expiry date). $today = date("Y-m-d", time()); $expiry = $row['image_expiry'] if( $today > $expiry) { ## ignore expired image } else { ## display image }Bottom line I need to exclude expired images from being echoed out in the first function. Thanks in advance. Everything I have tried hasn't worked. Hey, I posted a thread before about a news cms I've been developing. And right now I'm trying to flesh out the css of the articles I post on the home page. Now the problem I having is everytime I place a <span class=""></span> or <p class=""></p> or even <div class=""></div>, my web page does NOT load, and instead gives me an error. Code: [Select] Parse error: syntax error, unexpected T_STRING in /home/content/d/j/s/djsmiley/html/index.php on line 405 Now, I know it's possible to add css to a PHP echo statement, but I'm clearly doing something wrong. Here's the code for the php echo statement with the css included: Code: [Select] <? include("dbconnect.php"); //include the file to connect to the database $getnews = mysql_query("SELECT * FROM mynews ORDER BY id DESC"); //query the database for all of the news while($r=mysql_fetch_array($getnews)){ //while there are rows in the table extract($r); //remove the $r so its just $variable echo("<br><span class="NewsID">$type</span> <span class=h2>$title</span><br><br> <em>posted by <strong>$user</strong> | added on $time</em><br><br> $message<br><br> <label class="fltlft2"><img src="../../Websites/DJSmiley.Net/images/Icons/Arrows/Right.png" width="20" height="20"/></label><a href=$url>Read more - $url</a> <div class="newsLikeShareRate"> <table width="100%" border="0"> <tr> <td width="3%" height="21"><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script> <fb:like href="$url" show_faces="true" width="450" font="arial"></fb:like> </td> <td width="65%"><a name="fb_share" id="fb_share4" type="icon_link" share_url="$url">Share</a> <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></td> <td width="32%">Rate this article: </td> </tr> </table> </div>"); } ?> If you're wondering why there's a facebook script in there, I made it to where everytime a new post is added, a facebook like and share button are added, and are assigned the url I specify when the article is posted. Well, I think that's it for the code. Can anyone tell me what I'm doing wrong? Code: [Select] echo("<p class=\"commentboxContainer\"><table width=100% border=0> <tr> <td bgcolor=\"#EEE\"><strong><p class=fltlft>$name </strong>says:</p></td> </tr> </table> <table width=100% border=0 bgcolor=\"#EEE\"> <tr> <td width=40%><img src=../images/Icons/People/Anonymous.png width=64 height=64 border=1 /></td> <td width=60%>$comment',0,6</td> </tr> </table> <table width=100% border=0> <tr> <td bgcolor=\"#EEE\" ><p class=fltlft><em>$email</em></p></td> </tr> <tr> <td bgcolor=\"#EEE\" ><p class=fltlft>added on $time</p></td> </tr> </table></p><br>"); Here's my echo statement for displaying comments by users. I want to add a substr (); function to limit the amount of characters of the $comment field. That way if a user makes a long comment it doesn't push the page down. I tried putting it after the echo (); but that didn't work. I also tried putting it before $comment and that didn't even work. I know that if I make two separate echo statements, this can be done, but the field "$comment" is displayed within a table that is part of the original echo statement, so what do I do? I have to put a link that can be clicked around the first name and last name variables in the echo statement below. I also need to add a variable from the Select query to the link such as: 'www.phpfreaks.com/admin/customers.php?page=1&cID="VARIABLE HERE" &action=edit' I've tried a bunch of things and none seem to work. while($row = mysql_fetch_array($result)){ echo '<tr><td>' . $row['customers_firstname'] . " " . $row['customers_lastname'] . '</td><td>' . date("M. d, Y", strtotime($row['date'])) . '</td><td>' . $row['plan_id'] . '</td></tr>'; David I want the login script to echo out a statement, and then after 5 seconds (if the user hasn't clicked the link manually) I want it to redirect with the header redirect. I'm using the sleep function for the delay of the redirect. Here's the concerned portion of the login script: // check to see if the INPUT DATA matches the DATABASE COLUMNS! if ($nickname == $dbuser_name && sha1($password) == $dbuser_password) { // set a session after login $_SESSION['user_name'] = $dbuser_name; $_SESSION['user_id'] = $dbuser_id; echo "<center>You're logged in! <a href='01.php'>Click here</a> to go to the main page.</center>"; sleep(5); // seconds to wait header ('Location: 01.php'); // password incorrect error message } else { echo "<center>Incorrect password!</center>"; } But the echo statement never gets printed out, any idea why it gets swallowed by the sleep function? Hi I am new to PHP and this is my first post one here so appologies is this questions seems a bit dumb! I have an if clause such that if a button is pressed on my web page then i want to reload the page and include a new form on it. I am having a problem getting the $_SERVER['PHP_SELF'] command to work from iside a echo command. I must not be escaping the code correctly with back slashes: I currently have the line : echo"<form method=\"POST\" action=\"\<?$_SERVER['PHP_SELF']?\>\">"; However this doesnt seem to work as my page just doesnt display in the browser. Any advice is much appreciated. Thanks for taking the time to read. I've been working on my email screen, adding a video to it, and some Css. Which seems to work quite fine. However when the page returns to the original screen (represented by the code 1.) It collapses the video image. Makes it really long horizontally and thin vertically.
If I remove this first piece, showing that the email was sent successfully. if(isset($_GET['Message'])){ echo $_GET['Message']; } It returns to the screen fine and the video looks as it should. Code1:- <?php if(isset($_GET['Message'])){ echo $_GET['Message']; } $uri = $_SERVER['REQUEST_URI']; $uri_dir = getcwd(); ?> <!DOCTYPE html> <html> <head> <link href="/LifeSaverHTML/Details/Database/stylevid2.css" rel="stylesheet" type="text/css"> <h1 class = "titler"> LifeTube </h1> <p></p> </head> <body> <video class = "tube" controls src="examplevid.mp4"> Your browser does not support the video tag. </video> <p></p> <div style="margin: 0 auto; text-align: center"> <a href='/PHPMailer/index.php?id=<?=$uri?>&dire=<?=$uri_dir?>' class="linker">Email Security</a> </div> </body> </html>
I'm using this piece of CSS = Code2. I've set all the defaults padding etc to default for testing. * { margin: 0; padding: 0; } As I say it looks great. Apart from when it returns with the email successful message. The whole thing just deflates.
Code2:- * { margin: 0; padding: 0; } body { background: url('/LifeSaverHTML/Details/Database/backround.jpg') no-repeat center center fixed; height: 100%; background-position: center; background-repeat: no-repeat; background-size: cover; } .tube { display: block; margin: auto; width: 50%; height: 20%; border: 10px solid green; } .button { margin: 0 auto; display:block; text-align: center; } .linker { background-color: #23b83c; border: 2px solid #020353; color: whitesmoke; padding: 1em 1.5em; text-align: center; text-decoration: none; font-size: 1em; display: inline-block; width: 12%; border-radius: 5px; box-shadow: 3px 3px 8px 0 #000; /* h-offset v-offset blur spread color */ } .linker:hover { color: red; } .titler { width: 20%; text-align: center; margin: 0 auto; color: #FFFFFF; border: 5px ridge rgba(124,252,0); border-radius: 36px; background: #232323; text-shadow: 0 0 5px #FFF, 0 0 10px #FFF, 0 0 15px #FFF, 0 0 20px #49ff18, 0 0 30px #49FF18, 0 0 40px #49FF18, 0 0 55px #49FF18, 0 0 75px #49ff18; } nav { width: 80%; margin: 0 auto; } nav ul { list-style: none; overflow: hidden; } nav ul li { float: left; width: 20%; } nav ul li a { text-align: center; padding: 8px 0; display: block; width: 100%; background: #cdeb8e; /* Old browsers */ background: -moz-linear-gradient(top, #cdeb8e 0%, #b0ca34 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#cdeb8e), color-stop(100%,#b0ca34)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #cdeb8e 0%,#b0ca34 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #cdeb8e 0%,#b0ca34 100%); /* Opera 11.10+ */ background: linear-gradient(to bottom, #cdeb8e 0%,#b0ca34 100%); /* W3C, IE10+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=’#cdeb8e’, endColorstr=’#b0ca34′,GradientType=0 ); /* IE6-9 */ } nav ul li a, nav ul li a:focus, nav ul li a:visited, nav ul li a:hover, nav ul li a:active { color: #000; text-decoration: none; } nav ul li a:hover, nav ul li a:active { background: #b0ca34; /* Old browsers */ background: -moz-linear-gradient(top, #b0ca34 0%, #96c40d 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b0ca34), color-stop(100%,#96c40d)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #b0ca34 0%,#96c40d 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #b0ca34 0%,#96c40d 100%); /* Opera 11.10+ */ background: linear-gradient(to bottom, #b0ca34 0%,#96c40d 100%); /* W3C, IE10+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=’#b0ca34′, endColorstr=’#96c40d’,GradientType=0 ); /* IE6-9 */ } nav ul li:first-child a { border-top-left-radius: 8px; border-bottom-left-radius: 8px; } nav ul li:last-child a { border-top-right-radius: 8px; border-bottom-right-radius: 8px; } Edited February 17, 2020 by JonnyDriller I'm trying to input the results from a query into html, but I'm just getting the variable names rather than their values. I used single quotes for the echo statement, but I think I must need to switch to double to do that. But then I have problems with the double quotes from the class names (ex. class="SideBoxTitle"). Code: [Select] <?php // get user's videos from database $conn = mysqli_connect($dbhost, $dbuser, $dbpass) or die("MySQL Error: " . mysql_error()); $query = "SELECT * FROM haas12_test.videos"; $result = mysqli_query($conn, $query) or die ("Couldn't execute query."); while($row = mysqli_fetch_assoc($result)) { extract($row); echo ' <div id="topBox" class="mainVideoSideBoxes" > <div class="SideBoxTitle" ><h3> $vidtitle </h3> </div><!-- close SideBoxTitle --> <div class="sideBoxVidContainer"> <div class="SideBoxScreenCast" > $vidurl </div><!-- close SideBoxScreenCast --> <div class="SideBoxDesc" ><p> $viddesc </p> </div><!-- close SideBoxDesc --> </div><!-- close sideBoxVidContainer --> </div><!-- close mainVideoSideBoxes --> </div><!-- close mainVideoSideBoxes --> '; // end echo staement } ?> Here's the code, this is the PHP in my html contacts page (that IS in fact saved with a PHP extension): <div class = "centercontainer"> Hi guys, in code below I have a section where users can check seat avillability, however it shows the seats taken but it doest say the seats available, can u help me find out whats wrong? thanks in advance guys this is the line below $checkavailability=mysql_query("SELECT * FROM booking WHERE date='$mybookingdate' AND time='$mytime' AND ride_id='$ride_id'"); while($row=mysql_fetch_array($checkavailability)) { $takenseats=$row['seat_no']; if (mysql_num_rows($checkavailability)>=1) { echo "<table>"; echo " <td>Seat No ".$takenseats." is taken</td> "; } else{ echo " <td>Seat No ".$takenseats." is Available</td> "; } } echo "</table>"; } ?> full code below: <?php session_start(); include ("includes/db.php"); include ("includes/function.php"); //authentication if (loggedin()==FALSE) { Header("Location: login.php"); exit(); } //username session $_SESSION['username']=='$username'; $username=$_SESSION['username']; echo "Welcome, " .$_SESSION['username']."!<p>"; //get details from user table to be passed to page(text fields) $getdetails=mysql_query("SELECT * FROM users WHERE username='$username'"); while($row = mysql_fetch_array($getdetails)) { $users_id=$row['id']; $first_name=$row['first_name']; $last_name=$row['last_name']; $email=$row['email']; } /////////////////////////////////////// //****************************// //post starts here if (isset($_POST['next']) && $_POST['next']) { $myfirstname = addslashes(strip_tags($_POST['firstname'])); $mylastname = addslashes(strip_tags($_POST['lastname'])); $myemail = addslashes(strip_tags($_POST['email'])); $mybookingdate = addslashes(strip_tags($_POST['datetime'])); $mytime = addslashes(strip_tags($_POST['time'])); $myseatnumber = addslashes(strip_tags($_POST['seatnumber'])); $ride_id=1; //check if booking exists $checkbooking=mysql_query("SELECT * FROM booking WHERE date='$mybookingdate' AND time='$mytime' AND seat_no='$myseatnumber'"); if (mysql_num_rows($checkbooking)>=1) { echo "Seat No $myseatnumber For $mybookingdate at $mytime has been already taken, Please try a different seat, time or date"; } else { $checktotoal=mysql_query("SELECT * FROM booking WHERE date='$mybookingdate' AND time='$mytime'"); if (mysql_num_rows($checkbooking)>=48) { echo "We are fully book for this time and date, please choose different time/date to continue your booking"; } //pass the variables here } } if (isset($_POST['availability']) && $_POST['availability']) { $mybookingdate = addslashes(strip_tags($_POST['datecheck'])); $mytime = addslashes(strip_tags($_POST['timecheck'])); $myseatnumber = addslashes(strip_tags($_POST['seatnumbercheck'])); $ride_id=1; $checkavailability=mysql_query("SELECT * FROM booking WHERE date='$mybookingdate' AND time='$mytime' AND ride_id='$ride_id'"); while($row=mysql_fetch_array($checkavailability)) { $takenseats=$row['seat_no']; if (mysql_num_rows($checkavailability)>=1) { echo "<table>"; echo " <td>Seat No ".$takenseats." is taken</td> "; } else{ echo " <td>Seat No ".$takenseats." is Available</td> "; } } echo "</table>"; } ?> <html> <head> <link type="text/css" href="css/smoothness/jquery-ui-1.8.6.custom.css" rel="stylesheet" /> <script type="text/javascript" src="includes/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="includes/jquery-ui-1.8.6.custom.min.js"></script> <script type="text/javascript"> $(function() { $('#datetime').datepicker({ dateFormat: 'dd.mm.yy' }); }); $(function() { $('#datecheck').datepicker({ dateFormat: 'dd.mm.yy' }); }); </script> </head> <body> <table width="665" border="0"> <tr> <td width="372"><form name="booking" method="post" action=""> <p>BOOK NOW <p> First Name:<br /> <input type="text" name='firstname' value="<? echo "$first_name";?>"> <p>Last Name:<br /> <input type="text" name='lastname' value="<? echo "$last_name";?>"> <p>Email:<br /> <input type="text" name='email' value="<? echo "$email";?>"> <p>Choose a Date:<br /> <input type="text" name='datetime' id="datetime"> </p> <p> Select a Time:<br/> <select name='time'> <option value="9:00">9:00 <option value="9:07">9:07 <option value="9:14">9:14 <option value="9:21">9:21 <option value="9:28">9:28 <option value="9:35">9:35 <option value="9:42">9:42 <option value="9:49">9:49 <option value="9:56">9:56 <option value="10:03">10:03 <option value="10:10">10:10 <option value="10:17">10:17 <option value="10:24">10:24 <option value="10:31">10:31 <option value="10:38">10:38 <option value="10:45">10:45 <option value="10:52">10:52 <option value="10:59">10:59 <option value="11:02">11:02 <option value="11:09">11:09 <option value="11:16">11:16 <option value="11:23">11:23 <option value="11:30">11:30 <option value="11:37">11:37 <option value="11:44">11:44 <option value="11:51">11:51 <option value="11:58">11:58 </select> </p> <p> Select Seat Number:<br/> <select name='seatnumber'> <option value="1">Seat 1 <option value="2">Seat 2 <option value="3">Seat 3 <option value="4">Seat 4 <option value="5">Seat 5 <option value="6">Seat 6 <option value="7">Seat 7 <option value="8">Seat 8 <option value="9">Seat 9 <option value="10">Seat 10 <option value="11">Seat 11 <option value="12">Seat 12 <option value="13">Seat 13 <option value="14">Seat 14 <option value="15">Seat 15 <option value="16">Seat 16 <option value="17">Seat 17 <option value="18">Seat 18 <option value="19">Seat 19 <option value="21">Seat 20 <option value="22">Seat 22 <option value="23">Seat 23 <option value="24">Seat 24 <option value="25">Seat 25 <option value="26">Seat 26 <option value="27">Seat 27 <option value="28">Seat 28 <option value="20">Seat 29 <option value="30">Seat 30 <option value="31">Seat 31 <option value="32">Seat 32 <option value="33">Seat 33 <option value="34">Seat 34 <option value="35">Seat 35 <option value="36">Seat 36 <option value="37">Seat 37 <option value="38">Seat 38 <option value="39">Seat 39 <option value="40">Seat 40 <option value="41">Seat 41 <option value="42">Seat 42 <option value="43">Seat 43 <option value="44">Seat 44 <option value="45">Seat 45 <option value="46">Seat 46 <option value="47">Seat 47 <option value="48">Seat 48 </select> <p> <input type='submit' name='next' value='Next Step'> </form></td> <td width="283"> <form name="booking" method="post" action=""> <p>Check Seat Availability<br /> <p><br /> <p>Choose a Date:<br /> <input type="text" name='datecheck' id="datecheck"> <p> Select Seat Number:<br/> <select name='seatnumbercheck'> <option value="1">Seat 1 <option value="2">Seat 2 <option value="3">Seat 3 <option value="4">Seat 4 <option value="5">Seat 5 <option value="6">Seat 6 <option value="7">Seat 7 <option value="8">Seat 8 <option value="9">Seat 9 <option value="10">Seat 10 <option value="11">Seat 11 <option value="12">Seat 12 <option value="13">Seat 13 <option value="14">Seat 14 <option value="15">Seat 15 <option value="16">Seat 16 <option value="17">Seat 17 <option value="18">Seat 18 <option value="19">Seat 19 <option value="21">Seat 20 <option value="22">Seat 22 <option value="23">Seat 23 <option value="24">Seat 24 <option value="25">Seat 25 <option value="26">Seat 26 <option value="27">Seat 27 <option value="28">Seat 28 <option value="20">Seat 29 <option value="30">Seat 30 <option value="31">Seat 31 <option value="32">Seat 32 <option value="33">Seat 33 <option value="34">Seat 34 <option value="35">Seat 35 <option value="36">Seat 36 <option value="37">Seat 37 <option value="38">Seat 38 <option value="39">Seat 39 <option value="40">Seat 40 <option value="41">Seat 41 <option value="42">Seat 42 <option value="43">Seat 43 <option value="44">Seat 44 <option value="45">Seat 45 <option value="46">Seat 46 <option value="47">Seat 47 <option value="48">Seat 48 </select> <p> </p> <p> Select a Time:<br/> <select name='timecheck'> <option value="9:00">9:00 <option value="9:07">9:07 <option value="9:14">9:14 <option value="9:21">9:21 <option value="9:28">9:28 <option value="9:35">9:35 <option value="9:42">9:42 <option value="9:49">9:49 <option value="9:56">9:56 <option value="10:03">10:03 <option value="10:10">10:10 <option value="10:17">10:17 <option value="10:24">10:24 <option value="10:31">10:31 <option value="10:38">10:38 <option value="10:45">10:45 <option value="10:52">10:52 <option value="10:59">10:59 <option value="11:02">11:02 <option value="11:09">11:09 <option value="11:16">11:16 <option value="11:23">11:23 <option value="11:30">11:30 <option value="11:37">11:37 <option value="11:44">11:44 <option value="11:51">11:51 <option value="11:58">11:58 </select> <p> <input type='submit' name='availability' value='Check Availability'> </form> </td> </tr> </table> <p> </body> </html> why cant I get this to echo? something so simple i dont understand what im doing wrong. can i simply not beable to display a sql timestamp with out converting 2011-12-19 14:57:45 Code: [Select] <?php $ban3 = "SELECT date FROM banned WHERE id = '".mysql_real_escape_string($_SESSION['user_id'])."'"; $ban2 = mysql_query($ban3) or die(mysql_error()); $ban1 = mysql_fetch_array($ban2); $pop = $ban1['date']; echo $pop; ?> Good day to everybody ! I'm working on a small to-do list. I have created a text editor to add no todo to it. Here is the code : <script> //modified version of http://www.webmasterworld.com/forum91/4686.htm //myField accepts an object reference, myValue accepts the text string to add function insertAtCursor(myField, myValue) { //fixed scroll position textAreaScrollPosition = myField.scrollTop; //IE support if (document.selection) { myField.focus(); //in effect we are creating a text range with zero //length at the cursor location and replacing it //with myValue sel = document.selection.createRange(); sel.text = myValue; //Mozilla/Firefox/Netscape 7+ support } else if (myField.selectionStart || myField.selectionStart == '0') { myField.focus(); //Here we get the start and end points of the //selection. Then we create substrings up to the //start of the selection and from the end point //of the selection to the end of the field value. //Then we concatenate the first substring, myValue, //and the second substring to get the new value. var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); myField.setSelectionRange(endPos+myValue.length, endPos+myValue.length); } else { myField.value += myValue; } //fixed scroll position myField.scrollTop = textAreaScrollPosition; } </script> <form action="ajoutage.php" method="post" name="ajout" id="ajout"> <table cellpadding="0" cellspacing"0" border="0"> <input type="hidden" name="sujet" value="<?PHP echo $_GET['sujet']; ?>"/> <input type="hidden" name="categorie" value="<?PHP echo $_GET['categorie']; ?>"/> <tr><td width="85px">Titre : </td><td><input type="text" name="titre"/></td> <td></td> <td>Ajouteur : </td><td align="right"><input type="text" name="ajouteur" value="<?PHP echo $qui; ?>"/></td> </tr> <tr><td width="85px">Sujet : </td><td><input type="text" name="sujet"/></td> <td></td> <td>Status : </td><td align="right"><input type="text" name="status"/></td> </tr> <tr><td width="85px">Catégorie : </td><td><input type="text" name="categorie"/></td> <td></td> <td>Niveau : </td><td align="right"><input type="text" name="niveau"/></td> </tr> <tr><td colspan="5">Tâche : <a href="#" onClick="insertAtCursor(document.ajout.tache, '<tr><td></td>\n<td>*&0&*</td>\n</tr>\n')">Progress</a> | <a href="#" onClick="insertAtCursor(document.ajout.tache, '<tr colspan=3>\n<td></td>\n</tr>\n')">Pleinne</a> | <br><textarea name="tache" id="tache" cols="70" rows="20" wrap="off" spellcheck="false"></textarea></td> </tr> <tr><td colspan="5"><input type="submit" value="Ajouter"/></td></tr> </table> </form> It works very fine, as you can see there is to links that is use to add some text in the textarea, where ever the cursor is. Where it starts : I have also created another form to modify the todo's once they are created. The only problem here is that my 2 links for adding text to the textarea don't work at all, they do nothng, no error shown, no text added. Here is the code use to modify the todos once created: <script type="text/javascript"> //modified version of http://www.webmasterworld.com/forum91/4686.htm //myField accepts an object reference, myValue accepts the text string to add function insertAtCursor(myField, myValue) { //fixed scroll position textAreaScrollPosition = myField.scrollTop; //IE support if (document.selection) { myField.focus(); //in effect we are creating a text range with zero //length at the cursor location and replacing it //with myValue sel = document.selection.createRange(); sel.text = myValue; //Mozilla/Firefox/Netscape 7+ support } else if (myField.selectionStart || myField.selectionStart == '0') { myField.focus(); //Here we get the start and end points of the //selection. Then we create substrings up to the //start of the selection and from the end point //of the selection to the end of the field value. //Then we concatenate the first substring, myValue, //and the second substring to get the new value. var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); myField.setSelectionRange(endPos+myValue.length, endPos+myValue.length); } else { myField.value += myValue; } //fixed scroll position myField.scrollTop = textAreaScrollPosition; } </script> <?php $con = mysql_connect("localhost","XXXXXX","XXXXXX"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("XXXXXX", $con); $id = $_GET['id']; $qui = $_GET['qui']; $sujet = $_GET['sujet']; $categorie = $_GET['categorie']; $result = mysql_query("SELECT * FROM todo where id='$id'"); while($row = mysql_fetch_array($result)) { echo " <form action=\"modifiage.php\" name=\"ajout\" id=\"ajout\" method=\"post\"> <table cellpadding=\"0\" cellspacing\"0\" border=\"0\"> <input type=\"hidden\" name=\"id\" value=\"" . $row['id'] . "\"/> <input type=\"hidden\" name=\"qui\" value=\"" . $row['ajouteur'] . "\"/> <input type=\"hidden\" name=\"sujet\" value=\"" . $row['sujet'] . "\"/> <input type=\"hidden\" name=\"categorie\" value=\"" . $row['categorie'] . "\"/> <tr><td width=\"85px\">Titre : </td><td><input type=\"text\" name=\"titre\" value=\"" . $row['titre'] . "\"/></td> <td></td> <td>Ajouteur : </td><td align=\"right\"><input type=\"text\" name=\"ajouteur\" value=\"" . $row['ajouteur'] . "\"/></td> </tr> <tr><td width=\"85px\">Sujet : </td><td><input type=\"text\" name=\"sujet\" value=\"" . $row['sujet'] . "\"/></td> <td></td> <td>Status : </td><td align=\"right\"><input type=\"text\" name=\"status\" value=\"" . $row['status'] . "\"/></td> </tr> <tr><td width=\"85px\">Catégorie : </td><td><input type=\"text\" name=\"categorie\" value=\"" . $row['categorie'] . "\"/></td> <td></td> <td>Niveau : </td><td align=\"right\"><input type=\"text\" name=\"niveau\" value=\"" . $row['niveau'] . "\"/></td> </tr> <tr> "; $tache = $row['tache']; $tache = str_replace("<div class=\"progress-containers\"><div style=\"width:","*&",$tache); $tache = str_replace("%\"><br></div></div>","&*",$tache); $onmouse = '<tr onMouseOver="this.className=**highlight**" onMouseOut="this.className=**normal**"><td>'; $tache = str_replace($onmouse,"<tr><td>",$tache); echo " <td colspan=\"5\">Tâche : <a href=\"#\" onClick=\"insertAtCursor(document.ajout.tache, '<tr><td></td>\n<td>*&0&*</td>\n</tr>\n')\">Progress</a> | <a href=\"#\" onClick=\"insertAtCursor(document.ajout.tache, '<tr colspan=3>\n<td></td>\n</tr>\n')\">Pleinne</a> | <br><textarea name=\"tache\" id=\"tache\" cols=\"70\" rows=\"20\" wrap=\"off\" spellcheck=\"false\">" . $tache . "</textarea></td> </tr> <tr><td colspan=\"5\"><input type=\"submit\" value=\"Modifier\"/></td> </tr> </table> </form> "; } mysql_close($con); ?> Sorry I'm still new to php. So I'm trying to get my update statement to work. I will post the statement I have for it, I will also post sql code from the database it is trying to update and I will also post my form page. Appreciate any help, thanks. Here is my update statement... Code: [Select] <?php if (isset($_POST['update'])) { foreach($_POST['update'] as $update_id) { $query = "UPDATE FROM users WHERE course_id = $update_id"; mysqli_query($dbc, $query) or die ('can\'t update course'); $course_id = $_POST['course_id']; $course_name = $_POST['course_name']; $student_id = $_POST['student_id']; $sql = "INSERT INTO users (course_id, course_name, student_id) VALUES ('$course_id', '$course_name', '$student_id');"; $db->exec($sql); } echo 'course has been updated.<br />'; } ?> Here is the page that the update statement is on... Code: [Select] <html> <head> <title>Update User</title> </head> <body> <form method="post" action="update_user2.php"> <?php $dbc = mysqli_connect('localhost', 'se266_user', 'pwd', 'se266') or die(mysql_error()); //delete users echo '<b>Delete or Update User</b>.<br />'; if (isset($_POST['remove'])) { foreach($_POST['delete'] as $delete_id) { $query = "DELETE FROM users WHERE course_id = $delete_id"; mysqli_query($dbc, $query) or die ('can\'t delete course'); } echo 'user has been deleted.<br />'; } if (isset($_POST['update'])) { foreach($_POST['update'] as $update_id) { $query = "UPDATE FROM users WHERE course_id = $update_id"; mysqli_query($dbc, $query) or die ('can\'t update course'); $course_id = $_POST['course_id']; $course_name = $_POST['course_name']; $student_id = $_POST['student_id']; $sql = "INSERT INTO users (course_id, course_name, student_id) VALUES ('$course_id', '$course_name', '$student_id');"; $db->exec($sql); } echo 'course has been updated.<br />'; } //display users info with checkbox to delete $query = "SELECT * FROM users"; $result = mysqli_query($dbc, $query); while($row = mysqli_fetch_array($result)) { echo '<input type="checkbox" value="' .$row['course_id'] . '" name="delete[]" />'; echo ' ' .$row['course_name'] .' '. $row['student_id']; echo '<br />'; } mysqli_close($dbc); ?> <input type="submit" name="remove" value="Remove" /> <input type="submit" name="update" value="Update" /> <br> <br> <form method="GET" action="update_user2.php"> <label for="course_id">Course ID:</label> <input type="text" id="course_id" name="course_id" /><br /> <label for="course_name">Course Name:</label> <input type="text" id="course_name" name="course_name" /><br /> <label for="course_name">Student ID:</label> <input type="text" id="student_id" name="student_id" /><br /> </form> </body> </html> Here is my sql database... Code: [Select] DROP DATABASE IF EXISTS se266; CREATE DATABASE se266; use se266; CREATE TABLE users ( course_id INT(11) NOT NULL AUTO_INCREMENT, course_name VARCHAR(50), student_id VARCHAR(50) NOT NULL, PRIMARY KEY (course_id) ); -- create the users and grant priveleges to those users GRANT SELECT, INSERT, DELETE, UPDATE ON se266.* TO se266_user@localhost IDENTIFIED BY 'pwd'; INSERT INTO users (course_id, course_name, student_id) VALUES ('se255', 'Web Design Using PHP', '43253256'); use se266; SELECT * FROM users; what am i doing wrong? <?php $input_value = a tall order; if ( $input_value == a tall order ) { echo 'Correct!'; } if ( $input_value = err on the side of caution ) { echo 'correct!'; } else { echo 'Sorry, try again.'; } ?> also, once i get this to work i want it to be able to have the input value be a submit form in HTML so that anything the user puts in the box will go through this piece of code to decide what to do with what they put in. Thanks! I am incorporating a very basic 'include' statement on a new site. One 'include' calls up menu.php and the second calls up article.php. Both of these files are located in the same file folder as all the pages for this site.
On the index.php page, everything works as expected and both files are showing like they are suppose to. However, the article.php file is not showing up on subsequent pages while the menu.php seems to work fine.
Now I am a complete moron when it comes to php so I have no clue what the problem is or how to fix it so I would really appreciate any help I can get to fix this.
The site is at http://pickmysmoker.com
My code for article 'include' is:
<div id="sidebar" class="link-box"> |