PHP - Noob With No Idea, Unexpected T_if , No Idea What Ive Done Wrong
Hi
First of all, I know VERY little about PHP, The effort below is a wile guess that has gone wrong. I get this error Parse error: syntax error, unexpected T_IF in /home/repairyo/public_html/shop/includes/content/viewOrders.inc.php on line 57 I have no idea what ive done wrong, may be I am stupid for attempting it. Cheers Paul This is the original code Code: [Select] $view_orders->assign('VAL_STATE',$lang['glob']['orderState_'.$orders[$i]['status']]); This is the modified code Code: [Select] $view_orders->assign('VAL_STATE',$state = $results[$i]['status'] if ($state == '1') { "<font color='#ff9900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '2') { "<font color='#009900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '4') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '5') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '6') { "<font color='#cc0000'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else if ($state == '7') { "<font color='#ff9900'>".$lang['glob']['orderState_'.$results[$i]['status']]."</font>"; } else { $lang['glob']['orderState_'.$orders[$i]['status']]); } Similar Tutorialsi dont know how to fix this problem..please help me guys --- so this is my index Code: [Select] <? session_start(); if(!isset($_SESSION['administrator'])){ header("location:../login.php"); } include ("../config.php"); ?> <!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>e-Leave</title> <link rel="stylesheet" href="../style.css" type="text/css" media="all" /> </head> <body> <!-- Header --> <div id="header"> <div class="shell"> <!-- Logo + Top Nav --> <div id="top"> <h1>e-Leave (Cpanel)</h1> <div id="top-navigation"> Welcome <a href="#"><strong><? $user=($_SESSION['administrator']); echo $user; ?></strong></a> <span>|</span> <a href="index.php">Home</a> <span>|</span> <a href="logout.php">Log out</a> </div> </div> <!-- End Logo + Top Nav --> <!-- Main Nav --> <? include ("../header/header_cpanel.php"); ?> <!-- End Main Nav --> </div> </div> <!-- End Header --> <!-- Container --> <div id="container"> <div class="shell"> <!-- Main --> <div id="main"> <div class="cl"> </div> <!-- Content --> <div id="content"> <? if(isset($_GET[view])) { $view = $_GET[view]; } if ($view == '' ){ include ('employeeleaveapplication.php'); } if ($view == 'createaccount' ){ include ('createaccount.php'); } if ($view == 'createaccounta' ){ include ('createaccount_add.php'); } if ($view == 'createaccounti' ){ include ('createaccount_insert.php'); } if ($view == 'createaccountd' ){ include ('createaccount_delete.php'); } if ($view == 'createaccounte' ){ include ('createaccount_edit.php'); } if ($view == 'createaccountu' ){ include ('createaccount_update.php'); } if ($view == 'createlogina' ){ include ('createlogin_add.php'); } if ($view == 'createlogini' ){ include ('createlogin_insert.php'); } if ($view == 'employeedirectory' ){ include ('employeedirectory.php'); } if ($view == 'employeedirectoryl' ){ include ('employeedirectory_list.php'); } if ($view == 'employeedirectorya' ){ include ('employeedirectory_adjustment.php'); } if ($view == 'employeedirectoryai' ){ include ('employeedirectory_adjustment_insert.php'); } if ($view == 'employeedirectoryca' ){ include ('employeedirectory_cancel_adjustment.php'); } if ($view == 'employeedirectorycl' ){ include ('employeedirectory_cancel_application.php'); } if ($view == 'changepassword' ){ include ('changepassword.php'); } if ($view == 'changepasswordi' ){ include ('changepassword_insert.php'); } if ($view == 'branch' ){ include ('setup_branch.php'); } if ($view == 'brancha' ){ include ('setup_branch_add.php'); } if ($view == 'branchi' ){ include ('setup_branch_insert.php'); } if ($view == 'branchd' ){ include ('setup_branch_delete.php'); } if ($view == 'branche' ){ include ('setup_branch_edit.php'); } if ($view == 'branchu' ){ include ('setup_branch_update.php'); } if ($view == 'designation' ){ include ('setup_designation.php'); } if ($view == 'designationa' ){ include ('setup_designation_add.php'); } if ($view == 'designationi' ){ include ('setup_designation_insert.php'); } if ($view == 'designationd' ){ include ('setup_designation_delete.php'); } if ($view == 'designatione' ){ include ('setup_designation_edit.php'); } if ($view == 'designationu' ){ include ('setup_designation_update.php'); } if ($view == 'leavetype' ){ include ('setup_leavetype.php'); } if ($view == 'leavetypea' ){ include ('setup_leavetype_add.php'); } if ($view == 'leavetypei' ){ include ('setup_leavetype_insert.php'); } if ($view == 'leavetyped' ){ include ('setup_leavetype_delete.php'); } if ($view == 'leavetypee' ){ include ('setup_leavetype_edit.php'); } if ($view == 'leavetypeu' ){ include ('setup_leavetype_update.php'); } if ($view == 'publicholiday' ){ include ('setup_publicholiday.php'); } if ($view == 'publicholidayd' ){ include ('setup_publicholiday_delete.php'); } if ($view == 'publicholidaya' ){ include ('setup_publicholiday_add.php'); } if ($view == 'publicholidayi' ){ include ('setup_publicholiday_insert.php'); } if ($view == 'publicholidaye' ){ include ('setup_publicholiday_edit.php'); } if ($view == 'publicholidayu' ){ include ('setup_publicholiday_update.php'); } if ($view == 'report' ){ include ('report.php'); } if ($view == 'report_leave' ){ include ('report_leave.php'); } if ($view == 'print' ){ include ('report_print.php'); } ?> </div> <!-- End Content --> <!-- Sidebar --> <? include ("../header/dashboard_cpanel.php"); ?> <!-- End Sidebar --> <div class="cl"> </div> </div> <!-- Main --> </div> </div> <!-- End Container --> <div id="footer"> <? include ("../footer/footer.php"); ?> </div> </body> </html> -- this is my dashboard panel code Code: [Select] <div id="sidebar"> <!-- Box --> <div class="box"> <!-- Box Head --> <div class="box-head"> <h2><b>Dashboard</b></h2> </div> <!-- End Box Head--> <div class="box-content"> <a href="index.php?view=createaccount"><span> <img src="../images/createaccount.jpg"/> Create Account</span></a> <div class="cl"> </div> <div class="cl"> </div> <a href="index.php?view=employeedirectory"><br><span> <img src="../images/employee.jpg"/> Employee Directory</span></a> <div class="cl"> </div> <a href="index.php?view=report"><br><span> <img src="../images/status-report1.jpg"/> Report</span></a> <div class="cl"> </div> <div class="cl"> </div><a href="index.php?view=changepassword"><br> <span> <img src="../images/key.jpg"/> Change Password</span></a> </div> </div> <div class="box"> <!-- Box Head --> <div class="box-head"> <h2><b>Setup</b></h2> </div> <!-- End Box Head--> <div class="box-content"> <a href="index.php?view=branch"><br><span> <img src="../images/branch.jpg"/> Branch</span></a> <div class="cl"> </div> <div class="cl"> </div><a href="index.php?view=designation"><br> <span> <img src="../images/designation.jpg"/> Designation</span></a> <div class="cl"> </div> <div class="cl"> </div><br> <a href="index.php?view=leavetype"><span> <img src="../images/leave.jpg"/> Leave Type</span></a> <div class="cl"> </div> <div class="cl"> </div><br> <a href="index.php?view=publicholiday"><span> <img src="../images/pb.jpg"/> Public Holiday</span></a> </div> </div> </div> ----- and this is the where the problem page is Code: [Select] <!-- Box --> <div class="box"> <!-- Box Head --> <div class="box-head"> <h2 class="left">Report</h2> </div> <!-- End Box Head --> <!-- Table --> <div class="table"> <div class="right"> <br> </div> <div id="box" valign="top"> <br> <h3><FORM name ="reportbutton" method="post" align="left" action="index.php?view=report"> <strong>Leave Application Listing </strong>| <Input type = "Submit" Name = "Submit1" Class="button" VALUE = "Back To Report"> </h3> </FORM> <br><br> <form name="leavebutton" method="post" action="index.php?view=report_leave"> <? $b=$_GET['b']; $m=$_GET['m']; $y=$_GET['y']; if ($b <> '' && $m <> '' && $y <> '') { $branch=$b; $leavemonth=$m; $leaveyear=$y; } else { $branch=$_POST['branch']; $leavemonth=$_POST['leavemonth']; $leaveyear=$_POST['leaveyear']; } $connection=mysql_connect("$server", "$username", "$password") or die("Could not establish connection"); mysql_select_db($database_name, $connection) or die ("Could not select database"); $query="SELECT * from tblworkgroup"; $result=mysql_query($query);?> Branch <select name="branch" > <option value="all">ALL Branches</option> <? while($row=mysql_fetch_array($result)) { ?> <option value= "<?=$row['WorkGroupID']?>" <? if ($branch==$row['WorkGroupID']){ echo 'selected'; } ?> ><?=$row['WorkGroupName']?></option> <? } ?> </select> </td> </tr> <br><br><br> Month <select name="leavemonth" > <option value = "1" <? if ($leavemonth==1){ echo 'selected'; } ?>>January</option> <option value = "2" <? if ($leavemonth==2){ echo 'selected'; } ?>>February</option> <option value = "3" <? if ($leavemonth==3){ echo 'selected'; } ?>>March</option> <option value = "4" <? if ($leavemonth==4){ echo 'selected'; } ?>>April</option> <option value = "5" <? if ($leavemonth==5){ echo 'selected'; } ?>>May</option> <option value = "6" <? if ($leavemonth==6){ echo 'selected'; } ?>>June</option> <option value = "7" <? if ($leavemonth==7){ echo 'selected'; } ?>>July</option> <option value = "8" <? if ($leavemonth==8){ echo 'selected'; } ?>>August</option> <option value = "9" <? if ($leavemonth==9){ echo 'selected'; } ?>>September</option> <option value = "10" <? if ($leavemonth==10){ echo 'selected'; } ?>>October</option> <option value = "11" <? if ($leavemonth==11){ echo 'selected'; } ?>>November</option> <option value = "12" <? if ($leavemonth==12){ echo 'selected'; } ?>>December</option> </select> Year <select name="leaveyear" > <option value = "2010" <? if ($leaveyear==2010) { echo 'selected';} ?>>2010</option> <option value = "2011" <? if ($leaveyear==2011) { echo 'selected';} ?>>2011</option> <option value = "2012" <? if ($leaveyear==2012) { echo 'selected';} ?>>2012</option> <option value = "2013" <? if ($leaveyear==2013) { echo 'selected';} ?>>2013</option> <option value = "2014" <? if ($leaveyear==2014) { echo 'selected';} ?>>2014</option> <option value = "2015" <? if ($leaveyear==2015) { echo 'selected';} ?>>2015</option> <option value = "2016" <? if ($leaveyear==2016) { echo 'selected';} ?>>2016</option> <option value = "2017" <? if ($leaveyear==2017) { echo 'selected';} ?>>2017</option> </select> <input type='submit' name='submit' value='Preview' Class="button" onclick='return validate()'> </div> </form> <br /><br /> <div id="box" valign="top"> <h3> <strong>Leave Application Details</strong>  </h3> <br><br> <FORM name="printbutton" method="post" align="left" action="report_print.php" target="_blank"> <input type="hidden" name="leavemonth" value="<?php echo $leavemonth; ?>"> <input type="hidden" name="leaveyear" value="<?php echo $leaveyear; ?>"> <input type="hidden" name="branch" value="<?php echo $branch;?>"> <Input type = "Submit" Name = "Submit1" Class="button" VALUE = "Print Leave Details"> </form> <table width="80%" align="center" > <thead> <tr> <th width="700px" align="left">Name</a></th> <th width="500px" align="center"></a>Application Date</th> <th width="500px" align="center"></a> </th> <th width="500x" align="right"></a>Reason</th> </tr> </thead> <tbody> <? /*echo "branch:".$branch.'<br />'; echo "leavemonth:".$leavemonth.'<br />'; echo "leaveyear:".$leaveyear.'<br />';*/ //-------------------------------------------------- if ($leavemonth =='' || $leaveyear =='' || $branch == '') { // one value missing, so don't display } else { // start display data $branchtracker = ''; if ($branch=='all'){ $branch = '%'; } $rs = mysql_query( " call vwleavereport('$leavemonth', '$leaveyear', $branch, 0);"); $query="SELECT *, MONTH(tblleaveapplication.DateFrom) as DFMonth, MONTH(tblleaveapplication.DateTo) as DTMonth, YEAR(tblleaveapplication.DateFrom) as DFYear FROM `tblleaveapplication` LEFT JOIN `tblemployee` ON tblleaveapplication.employeeid = tblemployee.id WHERE WorkGroupID LIKE '".$branch."' AND ( (MONTH(tblleaveapplication.DateFrom)=".$leavemonth." AND YEAR(tblleaveapplication.DateFrom)=".$leaveyear.") OR (MONTH(tblleaveapplication.DateTo)=".$leavemonth." AND YEAR(tblleaveapplication.DateFrom)=".$leaveyear.") ) ORDER BY WorkGroupID "; $result = mysql_query($query); while($row=mysql_fetch_array($result)) { if ($branchtracker<>$row['WorkGroupID']){ echo '<tr><td colspan=4 style="background-color: #e8e8e8; font-weight: bold;">'.$row['WorkGroupID'].'</td></tr>'; $branchtracker = $row['WorkGroupID']; } echo '<tr>'; echo '<td>'.$row['EmployeeName'].'</td>'; echo '<td>'.$row['DateFrom'].'</td>'; echo '<td>'.$row['DateTo'].'</td>'; echo '<td>'.$row['Purpose'].'</td>'; echo '</tr>'; } } ?> </table> The problem is the panel should be out on the RIGHT side..how do i fix it. I can't honestly see whats wrong with this code, it's print'ing correct with the print_r. Code: [Select] Array ( [value1] => 2 [option] => - [value2] => 1 ) however i can't actually echo out the value1,value2 or option? It says the vars are empty yet it can still print_r the values so i know there not empty Code: [Select] <?php if(isset($_POST["submit"])){ $value1=$_POST["value1"]; $value2=$_POST["value2"]; $option=$_POST["option"]; } print_r($_POST); echo"$value1"; ?> <form action="index.php" name="submit" method="post"> <input type="text" name="value1"> <select name="option"> <option>+</option> <option>-</option> <option>*</option> <option>/</option> </select> <input type="text" name="value2"> <input type="submit" value="submit"> </form> I'm fairly new to OOP, could you help me fix this? Thanks! class register{ //Setting up Variables, you can add more, for example EMAIL. private $_username; private $_password; //Giving the variables values function __construct($u_name, $p_word) { $this->_username = $u_name; $this->_password = $p_word; } if(isset($_POST['submit'])) { $reg = new register($_POST['username'], $_POST['password']); echo $reg->u_name; } Notice: Undefined property: register::$u_name in C:\wamp\www\register.php on line 23 I have written an IF statement: Code: [Select] $Townsearch = "" if ($Townsearch != "") { $Townsearch = $_REQUEST['rsTown']; list($Town, $County) = split('[,]', $Townsearch); } and I get the error: Parse error: syntax error, unexpected T_IF in D:\retroandvintage.co.uk\wwwroot\main.php on line 7 I'm getting a unexpected t_if error and not sure where my fix is. Code: [Select] <?php if($templateVar == '') { $templateVar = 'peach'; //defaulting to be safe } else { $templateVar = $templateVar; //passed from controller } ?> <?php $this->load->view($templateVar . '/header'); ?> <?php $this->load->view($templateVar . '/navigation'); ?> <!-- End Navigation --> <?php $this->load->view($templateVar . '/msgbox'); ?> <?php if((empty($bodyType))||(!isset($bodyType))||(trim($bodyType)=="")){$this->load->view($templateVar . '/body_full');} elseif($bodyType == "full"){$this->load->view($templateVar . '/body_full');} /* Commented out for now, as currently we only have one layout dimension, this is $ out various sections that have different layouts, 2 columns, 3 columns, columns$ on and so forth. elseif($bodyType == "2column"){$this->load->view($templateVar . '/body_2column$ elseif($bodyType == "3column"){$this->load->view($templateVar . '/body_3column$ elseif($bodyType == "blog"){$this->load->view($templateVar . '/body_blog');} */ else{$this->load->view($templateVar . '/body_full');} ?> <?php $this->load->view($templateVar . '/footer'); ?> Issue line: Code: [Select] if((empty($bodyType))||(!isset($bodyType))||(trim($bodyType)=="")){$this->load->view($templateVar . '/body_full');} Hello everyone I'm modifying an open source software called phpScheduleIt, I'm trying to change the machid function based on the $type variable and I'm getting this error below: Parse error: syntax error, unexpected T_IF, expecting T_FUNCTION in C:\xampp\htdocs\phpScheduleIt\lib\Reservation.class.php on line 1122 Code: [Select] 1122 if ($type == RES_TYPE_ADD) 1123 function get_machid() { 1124 return $this->resource->get_property('machid'); 1125 } 1126 if ($type == RES_TYPE_MODIFY) 1127 function get_machid() { 1128 return $this->machid; 1129 } I don't understand why this isn't working :\ phpSchedule it is a really great free open source scheduling software if anyone is interested, full credits to Nick Korbel. http://php.brickhost.com I just started coding in PHP and need helping finding the exact location of the parse error. The output tells me: "Parse error: syntax error, unexpected T_IF in ... on line 8" I know it's not an exact location, but still can't find the syntax mistake. <?php #Script6 - register.php require_once('template/config.inc'); $page_title = 'Register; include ('template/header.html') if (isset($_POST['submitted'])) { require_once ('mysql_connect.php'); //First Name if (eregi ("^[[:alpha:].' -]{2,15}$", stripslashes(trim($_POST['first_name'])))) { $fn = escape_data($_POST['first_name']); } else { $fn = FALSE; echo '<p>Please enter your first name</p>'; } //Last Name if (eregi ("^[[:alpha:].' -]{2,30}$", stripslashes(trim($_POST['last_name'])))) { $ln = escape_data($_POST['last_name']); } else { $ln = FALSE; echo '<p>Please enter your last name</p>'; } //Email Address if (eregi ("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", stripslashes(trim($_POST['email'])))) { $e = escape_data($_POST['email']); } else { $e = FALSE; echo '<p>Please enter your email address</p>'; } //Username if (eregi ("^[[:alnum:]_]{4,20}$", stripslashes(trim($_POST['username'])))) { $u = escape_data($_POST['username']); } else { $u = FALSE; echo '<p>Please enter a valid username</p>'; } //Password if (eregi ("^[[:alnum:]]{8,20}$", stripslashes(trim($_POST['password1'])))) { if ($_POST['password1'] == $POST['password2']) { $p = escape_data($_POST['password1']); } else { $p = FALSE; echo '<p>Your password did not match the confirmed password</p>'; } } else { $p = FALSE; echo '<p>Please enter a valid password</p>'; } //EVERYTHING if ($fn && $ln && $e && $u && $p) { //Username availability $query = "SELECT user_id FROM users WHERE username='$u'"; $result = @mysql_query ($query); if (mysql_num_rows($result) == 0) { //Add user to DB $query = "INSERT INTO users (username, first_name, last_name, email, password, registration_date) VALUES ('$u', '$fn', '$ln', '$e', PASSWORD('$p'), NOW() )"; $result = @mysql_query ($query); if ($result){ //Email New User $body = "Dear '{$_POST['first_name']}',\n Thank you for registering"; mail ($_POST['email'], 'Thank you for registering', $body, 'From: someemail@domain.com'); //Output echo 'Thank you for registering'; include ('template/footer.html'); exit (); } else { echo '<p>You could not be registered due to a system error. We apologize for the inconvenience</p>'; } } else { echo '<p>That username is already taken. Please choose another.</p>'; } mysql_close(); } else { //if one of the data tests fail echo '<p>Please try again.</p>'; } } ?> <h1>Register</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <fieldset> <p>First Name: <input type="text" name="first_name" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /></p> <p>Last Name: <input type="text" name="last_name" value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" /></p> <p>Email Address: <input type="text" name="email" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></p> <p>User Name: <input type="text" name="username" value="<?php if (isset($_POST['username'])) echo $_POST['first_name']; ?>" /><span>Use only letters, numbers, and underscore. Must be between 4 and 20 characters long.</span></p> <p>Password: <input type="password" name="password1" /><span>Use only letters and numbers. Must be between 8 and 20 characters long.</span></p> <p>Confirm Password: <input type="password" name="password2" /></p> </fieldset> <div align="center"><input type="submit" name="submit" value="Register" /> </div> </form> <?php include_once('template/footer.html'); ?> HI, I'm writing a auction website .in auction website we need to check for new information every second so it needs to be ajax. we have a timer which calculate the end time of every auction and it needs to be updated every second.Do you have any idea for reducing the process of calculating maybe a client side but something that is updated by server? I mean , the timer works with client side and when the users BID , the timer needs to be refresh.So every time that Bid button hilted the time should be refresh. What's you idea?How can do something like that? Thanks I have a dropdown list where the values are retrieved form the mysql the dropdownlist is coded in php as below: $data = mysql_query("Select * From Project"); echo "<select name = 'Project' onchange = 'showUser(this.value)'>n"; while ($row = mysql_fetch_assoc($data)) { $id = $row['Project_Id']; $ProjectName = $row['ProjectName']; echo "<option value = $id>$ProjectName"; } echo"</select>"; echo "<br/>"; echo "<br/><div id='txtHint' style='width:30em; margin:0 auto;'></div><br/>"; this dropdownlist will retrieved the names of PROJECTS available in the database. when the user click any of the rpojects, it will displayed the engagements that belong to the selected PROJECT. This is also retrieved and display in a dynamic table using ajax. i have created a javascript function as below: <script type="text/javascript"> function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","try.php?q="+str,true); xmlhttp.send(); } </script> function showUser is placed in the "<select name = 'Project' onchange = 'showUser(this.value)'> my question is, is it possible that i display the data retrieved in the tables as hyperlinks? I want the user to be able to view the informations of the displayed engagements in another php page. the user can view the informations when they clicked on the hyperlinks of the engagement name that is displayed. the sample of table can be seen in the attachment. any idea on how to do this. Let me know cause im stuck So if I wanted to make sure my users were logged in, and had cookies & JavaScript enabled would this work...? Users enter site at index.php which sets a test cookie and calls itself (header location self in other words) if the test passed the user is redirected to the main page, if not then redirected to a page that has a we need cookies enabled page. Once in the main pages the cookie is checked and if present all good if not send back to index. Then I use session variables to track user data. I see this in my head but I'm not sure it works like I think and I am not sure how to code it. Your feedback would be greatly appreciated, and any pointers in how to code it would be prized as it would help me learn more so I don't have to ask next time. Hi I know my title doesn't give any information but I really have no idea what my problem is. The problem I have is that for some reason my code just stopped working, it was working fine in the beginning and then all of a sudden I'm getting undifined index: item, and I'm not sure what it was that I did wrong since it was working fine in the beginning. Can someone please help because this has me confused Thank you I'm building a game and I'm wanting to create mobile monsters for people to click on and fight. I have an arena that works fine, but I would love to have this additional feature. Here's what it would entail: Clicking on the name of the monster. Starting the fight (which is already designed and implemented) I need help with: Is there a way to make a mobile link, essentially. The monsters themselves are identified in a mySQL database with a specific ID. In the arena, the players click on a monster, and the battle begins. So, I need a way to make this "link" mobile. Thoughts? Ideas? Suggestions? Thanks! A few friends of mine run a little competition between ourselves for a bit of fun. This has been in the past, a sports prediction spreadsheet where we predict the outcomes of champions in various football leagues around the world.
Up to now its always been a very laborious spreadsheet with that my friend can no longer be bothered to do.
is there any way I can do this in php / html?
There would be 8 players predicting the outcome of 6 leagues. We award points for who gets the most, half points for coming close etc.
Any ideas as to what way to approach this would be appreciated. I amvery proficient in HTML and CSS, but a bit of a novice in PHP......but if there is a script or some idea to get this up and running I would be very appreciative.
Thanks
I was wondering if this is faster or better performance. Each time a user submit's a post on my forum I will make it +1 the .txt file on my main server directory called test.txt, then I can just call that on my main forum index to show the amount of total posts our board has, instead of using mysql queries to sum all of it from the tables... good idea? or am i retarded? OMFG! I have no idea what is going on! Code: [Select] <?php if (isset($user_log)) { //************************************************************************************************************************************************ $user = $_SESSION['user']; $query = " SELECT title, sum, story_id FROM draft WHERE user='$user' "; $select = mysql_query($query); while($rows = mysql_fetch_assoc($select)); { $titledb = $rows['title']; $sumdb = $rows['sum']; $id_db = $rows['story_id']; echo "$titledb"; } } //************************************************************************************************************************************************* ?> I have no idea whats going on I have tried: 1. Using mysql_num_rows I get a number (1) 2.Trying to use the mysql_fetch_assoc outside of the while loop. The values are getting echo'ed out, but when I put the code in the while loop and the Code: [Select] $rows=mysql_fetch_assoc in the while peramiters, nothing happening. I have also tried putting other code in the while loop and it works. Its just the mysql values. also I tried using or die(mysql_errror()), It dies but no mysql error Hi all, i want to write seating plan page, i want it to work by having the logged in user click on a link or image and the system will mark that users username into that seat. I have everything working in terms of the log in but as far as this page goes i really have no idea how i would start with it. If your not sure what i mean i can put it this way to make it much more understandable. If my page had the numbers 1 through to 49 listed down the side and next to each number it says as default "availible", but if the user click on that number the text next to that number changes from "availible" to the users username and no one others can click on that number as its "seat" or "number" has been taken. My users are stored within a mysql database and my site uses sessions like so: $_SESSION[username] = $row[username]; Many thanks for your help
Hi guys, thanks This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=313729.0 Hi guys, I have a little issue, I have already got a quiz, here is some of the code from the quiz. Code: [Select] <?php session_start(); session_name("Question_Test"); require_once('questionsandanswers.php'); require_once('functions.php'); if (!isset($_SESSION['questions'])) $_SESSION['questions'] = array(); $id = which_question($_POST['some_field']); $score = 0; if (!isset($_POST['submit'])) { $_SESSION['dclty'] = $_POST['dclty']; if ($_SESSION['dclty'] == "beg") { ?> <script> window.open("extrahelp.php", height=300,width=300); </script> <?php } if ($_SESSION['dclty'] == "int") { ?> <script> window.open("pointers.php", height=300,width=300); </script> <?php } } if (!isset($_POST['submit'])) { $_SESSION['correct'] = array(); $_SESSION['wrong'] = array(); $_SESSION['finished'] = 'no'; if (isset($_SESSION['error'])) { unset($_SESSION['error']); $_SESSION['$num'] = 0; } else { $_SESSION['score'] = $score; $_SESSION['correct'] = array(); $_SESSION['wrong'] = array(); $_SESSION['finished'] = 'no'; $_SESSION['$num'] = 0; } } else { $_SESSION['$num'] = (int) $_POST['num']; $postedanswers = str_replace("_"," ",$_POST['answers']); if ($postedanswers == $answers[$_SESSION['$num']]['0']) { $_SESSION['score'] ++; $_SESSION['correct'][] = $postedanswers; } else { $_SESSION['wrong'][] = $postedanswers; } if ($_SESSION['$num'] < count($questions)-1) { $_SESSION['$num']++; } else { $last = true; $_SESSION['finished'] = 'yes'; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Forensics E-learning Package</title> <?php echo $_SESSION['score']; if (!isset($last)) { echo "<script type=\"text/javascript\" src=\"form.js\"></script>"; } ?> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <div id="wrapper"> <div id="header"> <div id="toplinks"> </div> </div> <div id="menu"> <ul> <li><a class="selected" href="home.html">Home</a></li> <li><a href="initialquiz.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> </ul> </div> <div id="content"> <div id="main"> <h1>Initial Quiz</h1><BR /><BR /> <h1>Protection Section</h1><BR /><BR /> <?php if (!isset($last)){?> <h2>Questions <?php echo $_SESSION['$num']+1; ?>:</h2> <p><strong><?php echo $questions[$_SESSION['$num']]; ?></strong></p> <form id="questionBox" method="post" action="initialquiz.php"> <?php $pattern = ' '; $replace = '_'; $shuffledAnswers = shuffle_assoc($answers[$_SESSION['$num']]); #var_dump($newanswers); foreach ($shuffledAnswers as $answer) { $answer2 = str_replace($pattern,$replace,$answer); echo "<li><input type=\"radio\" id=\"$answer2\" value=\"$answer2\" name=\"answers\" />\n"; echo "<label for=\"$answer2\">$answer</label></li>\n"; } ?> <input type="hidden" name="num" value="<?php echo $_SESSION['$num']; ?>" /> <input type="submit" id="submit" name="submit" value="Submit Answer" /></p> </form><BR /><BR /><b> <?php } else { echo "<p id=\"compare\"><a href=\"detection.php\">Next Section! <img src=\"images/arrow.png\" /></a></p>"; } ?> <?php $_SESSION['$ProtectionPercent'] = number_format(($_SESSION['score'] * 100) / 5); ?> </b> </div> <div id="right"> <h2>Right Menu</h2> <div class="rightitem"> <ul> <li><a class="selected" href="home.html">Home</a></li> <li><a href="initialquiz.php">Initial Quiz</a></li> <li><a href="about.php">About</a></li> </ul> </div> </div> </div> <div class="clearbottom"></div> <div id="footer"> <p id="legal"> </p> </div> </div> </div> </body> </html> The problem is, is that everytime i refresh my page the score counter increments. I have been chatting to a friend and they recommended some coding ideas that may work to stop this, however can any1 help me with a little more on implementing it to my systems? here is the recommended code Code: [Select] session_start(); if (!isset($_SESSION['questions'])) $_SESSION['questions'] = array(); # assuming which_question gives the proper id for the question $id = which_question($_POST['some_field']); # Only handle post data if questions hasn't allready been answered if (!isset($_SESSION['questions'][$id])) { # remove anything other than a-z, A-Z and regular whitespace from answer $answer = preg_replace('#[^a-zA-Z ]#', '', $_POST['answer']); $_SESSION['questions'][$id]['answer'] = $answer; $_SESSION['questions'][$id]['points'] = grade_answer($answer); # ... } Any help would be hugely Appreciated. Thanks Labce i have a drop-down list of coures from course table. then i have two text field to enter No of Ques: Allocated Marks: for example: if i select PHP course and enter 4 for No of Ques , 25 for Allocated marks then it should srote in anothe database table like this Course | QuesNo | Marks PHP 1 25 PHP 2 25 PHP 3 25 PHP 4 25 Can anyone help for this code.hope this will not too dificult for you guys. i will really apriciate. Thanks |