PHP - Not Recognizing Variables
Hi, My results were fine when displaying them on the browser but then want to output student's grades depending on what mark they have got. I have put an if statement for this:
Code: [Select] if ($markGrade >= 70){ $grade = "A";} But when I put the above if statement in the code then the browser outputs this: Your Search: Student Username: 'u0867587' Notice: Undefined variable: sessionData in /web/stud/u0867587/Mobile_app/student_overall_grade.php on line 79 Notice: Undefined variable: moduleID in /web/stud/u0867587/Mobile_app/student_overall_grade.php on line 91 Notice: Undefined variable: moduleName in /web/stud/u0867587/Mobile_app/student_overall_grade.php on line 91 Notice: Undefined variable: markTotal in /web/stud/u0867587/Mobile_app/student_overall_grade.php on line 91 Notice: Undefined variable: markGrade in /web/stud/u0867587/Mobile_app/student_overall_grade.php on line 91 Notice: Undefined variable: grade in /web/stud/u0867587/Mobile_app/student_overall_grade.php on line 91 Notice: Undefined variable: sessionsHTML in /web/stud/u0867587/Mobile_app/student_overall_grade.php on line 93 Why is it not recognisiong any variables? The code is below and in the attached file. Code: [Select] <?php if (isset($_POST['submit'])) { $query = " SELECT st.CourseId, c.CourseName, st.Year, st.StudentUsername, st.StudentForename, st.StudentSurname, s.ModuleId, m.ModuleName, m.Credits, s.SessionId, s.SessionWeight, gr.Mark, gr.Grade FROM Course c INNER JOIN Student st ON c.CourseId = st.CourseId JOIN Grade_Report gr ON st.StudentId = gr.StudentId JOIN Session s ON gr.SessionId = s.SessionId JOIN Module m ON s.ModuleId = m.ModuleId WHERE (st.StudentUsername = '".mysql_real_escape_string($studentid)."') ORDER BY c.CourseName, st.StudentUsername, m.ModuleName, s.SessionId "; $num = mysql_num_rows($result = mysql_query($query)); mysql_close(); ?> <p> Your Search: </p> <p> <strong>Student Username:</strong> <?php echo "'$studentid'"; ?><br/> </p> <?php if($num ==0){ echo "<p>Sorry, No Records were found from this Search</p>";} else{ function outputModule($moduleID, $moduleName, $sessionData) { if(!count($sessionData)) { return false; } $markTotal = 0; $markGrade = 0; $weightSession = 0; $grade = ""; $sessionsHTML = ''; }; foreach($sessionData as $session) { $sessionsHTML .= "<p><strong>Session:</strong> {$session['SessionId']} {$session['Mark']} {$session['SessionWeight']}%</p>\n"; $markTotal += ($session['Mark'] / 100 * $session['SessionWeight']); $weightSession += ($session['SessionWeight']); $markGrade = ($markTotal / $weightSession * 100); if ($markGrade >= 70){ $grade = "A";} } $moduleHTML = "<p><br><strong>Module:</strong> {$moduleID} - {$moduleName} {$markTotal} {$markGrade} {$grade}</p>\n"; return $moduleHTML . $sessionsHTML; } $output = ""; $studentId = false; $courseId = false; $moduleId = false; while ($row = mysql_fetch_array($result)) { if($studentId != $row['StudentUsername']) { //Student has changed $studentId = $row['StudentUsername']; $output .= "<p><strong>Student:</strong> {$row['StudentForename']} {$row['StudentSurname']} ({$row['StudentUsername']})\n"; } if($courseId != $row['CourseId']) { //Course has changed $courseId = $row['CourseId']; $output .= "<br><strong>Course:</strong> {$row['CourseId']} - {$row['CourseName']} <br><strong>Year:</strong> {$row['Year']}</p>\n"; } if($moduleId != $row['ModuleId']) { //Module has changed if(isset($sessionsAry)) //Don't run function for first record { //Get output for last module and sessions $output .= outputModule($moduleId, $moduleName, $sessionsAry); } //Reset sessions data array and Set values for new module $sessionsAry = array(); $moduleId = $row['ModuleId']; $moduleName = $row['ModuleName']; } //Add session data to array for current module $sessionsAry[] = array('SessionId'=>$row['SessionId'], 'Mark'=>$row['Mark'], 'SessionWeight'=>$row['SessionWeight']); } //Get output for last module $output .= outputModule($moduleId, $moduleName, $sessionsAry); //Display the output echo $output; } ?> [attachment deleted by admin] Similar TutorialsHi, I want to recognize let s say "..." in a text. How can that be accomplished in php? And maybe put all "..." into an array. Anybody have any idea how this can be done? Thank you Can someone help me understand what this type of php is... classes etc..
<?php // item 1 ***** get the excerpt ***** $excerpt = IDX_Plus::get_data('excerpt'); echo "echo-1 excerpt = $excerpt<br><br>"; // item 2 ***** set the excerpt *********** IDX_Plus::set_data( 'excerpt', $excerpt); // item 3 ***** get the excerpt again ******* $excerpt = IDX_Plus::get_data('excerpt'); echo "echo-2 excerpt = $excerpt<br><br>"; // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // item 4 now shorten the excerpt // ***** shorten the excerpt *********** $short_excerpt = wp_trim_words($excerpt,10); echo "echo-3 short_excerpt = $short_excerpt<br><br>"; // item 5 ***** set short_excerpt *********** IDX_Plus::set_data( 'short_excerpt', $short_excerpt); // item 6 ***** get short_excerpt again ******* $short_excerpt = IDX_Plus::get_data('short_excerpt'); echo "echo-4 short_excerpt = $short_excerpt<br><br>"; ?>I can't get it to work so if someone can point me to where I can find info on how this type of php works I will be forever grateful...it pulls data form a cache storage on the web and tries to shorten the output and write the short line back to a new variable..The results look like below: Resulting output: ***************** echo-1 excerpt = Wonderful family home in desirable South Torrance neighborhood. Light and bright, this 'one owner' home boasts original hardwood floors and 'classic' 1953 tile in kitchen and bath. The freshly painted interior, new kitchen and bathroom faucets, new vinyl floor in bath, and new water heater, make this home move-in ready. Large 'pool size' fenced yard for the kids. Perfect for your buyers who love the classic look of the 50's, or for those looking to remodel and expand. echo-2 excerpt = Wonderful family home in desirable South Torrance neighborhood. Light and bright, this 'one owner' home boasts original hardwood floors and 'classic' 1953 tile in kitchen and bath. The freshly painted interior, new kitchen and bathroom faucets, new vinyl floor in bath, and new water heater, make this home move-in ready. Large 'pool size' fenced yard for the kids. Perfect for your buyers who love the classic look of the 50's, or for those looking to remodel and expand. echo-3 short_excerpt = Wonderful family home in desirable South Torrance neighborhood. Light and… echo-4 short_excerpt = the short line does not appear so it must not have saved... Hello everyone, I have a website where users are able to send and receive messages. I am trying to devise a way that I can prevent abusive messages from being sent. The best way that I can think of to do this is to use a few key words that would likely be used in an abusive message (basically, any curse word). Does anyone have any ideas on how I can check the text before it is sent for certain key words? Thanks in advance for any help or ideas. I have a strange problem. When a guest visits my contact-user.php page, they get a message telling them the must login before viewing the page. After the guest logs in, they view the same page and it tells them they have to login again (keeps on looping). But if they manually refresh that page with the "you must be logged in" message, it recognizes the login and lets them in. How can I get this page to immediately recognize that the user is logged in and not require them to refresh the page manually? Here is my code for contact-user.php <?php session_start(); header("Cache-Control: private, max-age=10800, pre-check=10800"); header("Pragma: private"); header("Expires: " . date(DATE_RFC822,strtotime("+2 day"))); include("connection.php"); mysql_select_db("database"); if (isset($_SESSION['username'])) { ******** MY HTML PAGE CONTENT ******** } else { echo "<meta http-equiv='REFRESH' content='2;url=http://www.mysite.com/login.php'> <center><font color='#EE0000'><p>You must be logged in before negotiating. You will now be redirect to the login page.</p></font></center>"; } ?> Here is my code for login.php script: <?php include("connection.php"); mysql_select_db("database"); session_start(); if(isset($_POST['login'])){ $username = mysql_real_escape_string($_POST['username']); $password = mysql_real_escape_string($_POST['password']); $tUnixTime = time(); $sGMTMySqlString = gmdate("Y-m-d H:i:s", $tUnixTime); if (!$username || !$password) { print "Please fill out all fields."; exit; } $logres = mysql_num_rows(mysql_query("SELECT * FROM members WHERE username = '$username' and password = '$password'")); if ($logres <= 0) { print "Login failed. If you have not already, please signup. Otherwise, check your spelling and login again."; exit; } else { $_SESSION['username'] = $username; if (isset($_SESSION)) { echo'You are now logging in'; mysql_query("UPDATE members SET activity = '$sGMTMySqlString' WHERE username = '$username'"); } else { echo "You are not logged in!"; } echo'<html><head><meta http-equiv="REFRESH" content="1;url=http://www.mysite.com/members/' . $_SESSION['username'] . '/"></head><body></body></html>'; exit; } } ?> does anyone know how to decode this XML variable value into string values? I also need to know the oposite way: creating variable values into xml. I've tried several code examples but they did filter the requested data. Code: [Select] $xml='<?xml version="1.0" encoding="utf-8"?> <elements> <text identifier="ed9cdd4c-ae8b-4ecb-bca7-e12a5153bc02"> <value/> </text> <textarea identifier="a77f06fc-1561-453c-a429-8dd05cdc29f5"> <value><![CDATA[<p style="text-align: justify;">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>]]></value> </textarea> <textarea identifier="1a85a7a6-2aba-4480-925b-6b97d311ee6c"> <value><![CDATA[<p style="text-align: justify;">Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>]]></value> </textarea> <image identifier="ffcc1c50-8dbd-4115-b463-b43bdcd44a57"> <file><![CDATA[images/stories/red/cars/autobedrijf.png]]></file> <title/> <link/> <target/> <rel/> <lightbox_image/> <width><![CDATA[250]]></width> <height><![CDATA[187]]></height> </image> <text identifier="4339a108-f907-4661-9aab-d6f3f00e736e"> <value><![CDATA[Kramer 5]]></value> </text> <text identifier="ea0666d7-51e3-4e52-8617-25e3ad61f8b8"> <value><![CDATA[6000 RS]]></value> </text> <text identifier="90a18889-884b-4d53-a302-4e6e4595efa0"> <value><![CDATA[Eindhoven]]></value> </text> <text identifier="410d72e0-29b3-4a92-b7d7-f01e828b1586"> <value><![CDATA[APK Pick up and return]]></value> </text> <text identifier="45b86f23-e656-4a81-bb8f-84e5ea76f71f"> <value><![CDATA[15% korting op grote beurt]]></value> </text> <text identifier="3dbbe1c6-15d6-4375-9f2f-f0e7287e29f3"> <value><![CDATA[Gratis opslag zomerbanden]]></value> </text> <text identifier="2e878db0-605d-4d58-9806-8e75bced67a4"> <value><![CDATA[Gratis abonnement of grote beurt]]></value> </text> <text identifier="94e3e08f-e008-487b-9cbd-25d108a9705e"> <value/> </text> <text identifier="73e74b73-f509-4de7-91cf-e919d14bdb0b"> <value/> </text> <text identifier="b870164b-fe78-45b0-b840-8ebceb9b9cb6"> <value><![CDATA[040 123 45 67]]></value> </text> <text identifier="8a91aab2-7862-4a04-bd28-07f1ff4acce5"> <value/> </text> <email identifier="3f15b5e4-0dea-4114-a870-1106b85248de"> <value/> <text/> <subject/> <body/> </email> <link identifier="0b3d983e-b2fa-4728-afa0-a0b640fa34dc"> <value/> <text/> <target/> <custom_title/> <rel/> </link> <relateditems identifier="7056f1d2-5253-40b6-8efd-d289b10a8c69"/> <rating identifier="cf6dd846-5774-47aa-8ca7-c1623c06e130"> <votes><![CDATA[1]]></votes> <value><![CDATA[1.0000]]></value> </rating> <googlemaps identifier="160bd40a-3e0e-48de-b6cd-56cdcc9db892"> <location><![CDATA[50.895711,5.955427]]></location> </googlemaps> </elements>'; Hi. I have some code which needs to return a single variable from the function and stored as a variable within this page, so it can be echoed later on in the page. I couldn't get it to return as a variable, so i used "return compact();" to return the variable and "extract (myFunction());" to extract it to variables. However, when I turned on php's display errors and error reporting function, I got an error message saying "Warning: extract() [function.extract]: First argument should be an array in /my/web/site/index.php on line 6" (which is where my extract function is). This works fine with passing more than one variables through, is there another way pass one variable from a function to be stored as a variable on the page which called the function? Here is the function: Code: [Select] <?php //This is a list of numeric error codes against their text. this will return the error code as the variable $issue function checkLoginIssue() { //If there is an error code if (isset($_GET["issue"])) { //cycle through the list until the code is reached, return the text and break the switch switch ($_GET["issue"]) { case "1": $issue = '<p class="warning">Please log in to view this page</p>'; break; case "2": $issue = '<p class="warning">Wrong Username or Password</p>'; break; case "3": $issue = '<p class="warning">No user found with those details</p>'; break; } //return the variable in an array with a single value return compact('issue'); } } ?> And here is the code which calls the function: Code: [Select] <?php extract(checkLoginIssue()); ?> Hi guys I have two variables but $no1=$row[no1]; $no2=$row[no2]; I need to have another variable where i can merge these two as i need to insert them to database with sapce in between each variable like: $numbers= $no1 $no2; by doing this i get syntax error, do u know whats the best way to do this? Hi guys, I've a developer for a pretty large website and forum, the database is exploding in size and we are now seeing a grow in the slow log. We want to be able to fix this by optimizing query's but the site is so big, we can't locate the query's themselfs as they are dynamically generated. I want to be able to tail onto the end of the query a comment containing where a function was last called. In the example below, I want the file name and line-number of where add_together() was called. Here is an example for index.php: Code: [Select] $a = 1; $b = 2; $c = add_together($a, $b); function add_together($a, $b) { return $a + $b; } Look forward to your assistance with this! Joe Hello I am stuck at a point where I need to call multiple numbers for a given API
This is the code provided by the API company
// Send Message
Now My html code would be
<div class="card-header ch-alt">
<div class="card-body card-padding">
<option value='APIKEY'>APIKEY Value </option> </select><br> <br><br>
Text: * <br>
Now how do I insert multiple numbers on the Destination number...when i give commas, it gives errors but the message goes with single number
Need hlp It echos that there are to many.. how would I do this Saying like if I had 100 $Variable[] it would echo that there are to many? $Variable[] = ""; $Variable[] = ""; $Variable[] = ""; $Variable[] = ""; $Variable[] = ""; $Variable[] = ""; Hello I need some help please, I've started to teach myself PHP and I'm attempting to set up some matches for a league I run. I've included the link I'm working on and just cannot seem to fix my problem. I'm trying to get it so that you can put the team members and have their names come up in the match section. Any help would be wonderful cause I have to be doing something wrong I've also now included my PHP that I have...sorry should have put it first time http://www.4funmembers.com/Pairings.php Code: [Select] <?php if ( !$_POST['submit'] ) { echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n"; echo "<form method=\"post\" action=\"singles1.php\" target=\"_blank\">\n"; echo "<tr><td>Team 1 Name: <input type=\"text\" name=\"teamone\"/></td></tr>\n"; echo "<tr><td>Player 1: <input type=\"text\" name=\"plyr1a\"/></td></tr>\n"; echo "<tr><td>Player 2: <input type=\"text\" name=\"plyr2a\"/></td></tr>\n"; echo "<tr><td>Player 3: <input type=\"text\" name=\"plyr3a\"/></td></tr>\n"; echo "<tr><td>Player 4: <input type=\"text\" name=\"plyr4a\"/></td></tr>\n"; echo "<tr><td>Team 2 Name: <input type=\"text\" name=\"teamtwo\"/></td></tr>\n"; echo "<tr><td>Player 1: <input type=\"text\" name=\"plyr1b\"/></td></tr>\n"; echo "<tr><td>Player 2: <input type=\"text\" name=\"plyr2b\"/></td></tr>\n"; echo "<tr><td>Player 3: <input type=\"text\" name=\"plyr3b\"/></td></tr>\n"; echo "<tr><td>Player 4: <input type=\"text\" name=\"plyr4b\"/></td></tr>\n"; echo "<tr><td>Team 3 Name: <input type=\"text\" name=\"teamthree\"/></td></tr>\n"; echo "<tr><td>Player 1: <input type=\"text\" name=\"plyr1c\"/></td></tr>\n"; echo "<tr><td>Player 2: <input type=\"text\" name=\"plyr2c\"/></td></tr>\n"; echo "<tr><td>Player 3: <input type=\"text\" name=\"plyr3c\"/></td></tr>\n"; echo "<tr><td>Player 4: <input type=\"text\" name=\"plyr4c\"/></td></tr>\n"; echo "<tr><td>Team 4 Name: <input type=\"text\" name=\"teamfour\"/></td></tr>\n"; echo "<tr><td>Player 1: <input type=\"text\" name=\"plyr1d\"/></td></tr>\n"; echo "<tr><td>Player 2: <input type=\"text\" name=\"plyr2d\"/></td></tr>\n"; echo "<tr><td>Player 3: <input type=\"text\" name=\"plyr3d\"/></td></tr>\n"; echo "<tr><td>Player 4: <input type=\"text\" name=\"plyr4d\"/></td></tr>\n"; echo "<tr><td>Team 5 Name: <input type=\"text\" name=\"teamfive\"/></td></tr>\n"; echo "<tr><td>Player 1: <input type=\"text\" name=\"plyr1e\"/></td></tr>\n"; echo "<tr><td>Player 2: <input type=\"text\" name=\"plyr2e\"/></td></tr>\n"; echo "<tr><td>Player 3: <input type=\"text\" name=\"plyr3e\"/></td></tr>\n"; echo "<tr><td>Player 4: <input type=\"text\" name=\"plyr4e\"/></td></tr>\n"; echo "<tr><td>Team 6 Name: <input type=\"text\" name=\"teamsix\"/></td></tr>\n"; echo "<tr><td>Player 1: <input type=\"text\" name=\"plyr1f\"/></td></tr>\n"; echo "<tr><td>Player 2: <input type=\"text\" name=\"plyr2f\"/></td></tr>\n"; echo "<tr><td>Player 3: <input type=\"text\" name=\"plyr3f\"/></td></tr>\n"; echo "<tr><td>Player 4: <input type=\"text\" name=\"plyr4f\"/></td></tr>\n"; echo "<tr><td>Team 7 Name: <input type=\"text\" name=\"teamseven\"/></td></tr>\n"; echo "<tr><td>Player 1: <input type=\"text\" name=\"plyr1g\"/></td></tr>\n"; echo "<tr><td>Player 2: <input type=\"text\" name=\"plyr2g\"/></td></tr>\n"; echo "<tr><td>Player 3: <input type=\"text\" name=\"plyr3g\"/></td></tr>\n"; echo "<tr><td>Player 4: <input type=\"text\" name=\"plyr4g\"/></td></tr>\n"; echo "<tr><td>Team 8 Name: <input type=\"text\" name=\"teameight\"/></td></tr>\n"; echo "<tr><td>Player 1: <input type=\"text\" name=\"plyr1h\"/></td></tr>\n"; echo "<tr><td>Player 2: <input type=\"text\" name=\"plyr2h\"/></td></tr>\n"; echo "<tr><td>Player 3: <input type=\"text\" name=\"plyr3h\"/></td></tr>\n"; echo "<tr><td>Player 4: <input type=\"text\" name=\"plyr4h\"/></td></tr>\n"; echo "<tr><td>Match #1 <select name=\"teama\"><option value=\"t1\">Team 1</option>\n<option value=\"t2\">Team 2</option>\n<option value=\"t3\">Team 3</option>\n<option value=\"t4\">Team 4</option>\n<option value=\"t5\">Team 5</option>\n<option value=\"t6\">Team 6</option>\n<option value=\"t7\">Team 7</option>\n<option value=\"t8\">Team 8</option></select> vs <select name=\"teamb\"><option value=\"t1\">Team 1</option>\n<option value=\"t2\">Team 2</option>\n<option value=\"t3\">Team 3</option>\n<option value=\"t4\">Team 4</option>\n<option value=\"t5\">Team 5</option>\n<option value=\"t6\">Team 6</option>\n<option value=\"t7\">Team 7</option>\n<option value=\"t8\">Team 8</option></select></td></tr>\n"; echo "<tr><td>Match #2 <select name=\"teamc\"><option value=\"1\">Team 1</option>\n<option value=\"2\">Team 2</option>\n<option value=\"3\">Team 3</option>\n<option value=\"4\">Team 4</option>\n<option value=\"5\">Team 5</option>\n<option value=\"6\">Team 6</option>\n<option value=\"7\">Team 7</option>\n<option value=\"8\">Team 8</option></select> vs <select name=\"teamd\"><option value=\"1\">Team 1</option>\n<option value=\"2\">Team 2</option>\n<option value=\"3\">Team 3</option>\n<option value=\"4\">Team 4</option>\n<option value=\"5\">Team 5</option>\n<option value=\"6\">Team 6</option>\n<option value=\"7\">Team 7</option>\n<option value=\"8\">Team 8</option></select></td></tr>\n"; echo "<tr><td>Match #3 <select name=\"teame\"><option value=\"1\">Team 1</option>\n<option value=\"2\">Team 2</option>\n<option value=\"3\">Team 3</option>\n<option value=\"4\">Team 4</option>\n<option value=\"5\">Team 5</option>\n<option value=\"6\">Team 6</option>\n<option value=\"7\">Team 7</option>\n<option value=\"8\">Team 8</option></select> vs <select name=\"teamf\"><option value=\"1\">Team 1</option>\n<option value=\"2\">Team 2</option>\n<option value=\"3\">Team 3</option>\n<option value=\"4\">Team 4</option>\n<option value=\"5\">Team 5</option>\n<option value=\"6\">Team 6</option>\n<option value=\"7\">Team 7</option>\n<option value=\"8\">Team 8</option></select></td></tr>\n"; echo "<tr><td>Match #4 <select name=\"teamg\"><option value=\"1\">Team 1</option>\n<option value=\"2\">Team 2</option>\n<option value=\"3\">Team 3</option>\n<option value=\"4\">Team 4</option>\n<option value=\"5\">Team 5</option>\n<option value=\"6\">Team 6</option>\n<option value=\"7\">Team 7</option>\n<option value=\"8\">Team 8</option></select> vs <select name=\"teamh\"><option value=\"1\">Team 1</option>\n<option value=\"2\">Team 2</option>\n<option value=\"3\">Team 3</option>\n<option value=\"4\">Team 4</option>\n<option value=\"5\">Team 5</option>\n<option value=\"6\">Team 6</option>\n<option value=\"7\">Team 7</option>\n<option value=\"8\">Team 8</option></select></td></tr>\n"; echo "<tr><td><input type=\"submit\" name=\"submit\" value=\"Get Pairs\"/></td></tr>\n"; echo "</form></table>\n"; } else { $t1 = $_POST['plyr1a']; $t2 = $_POST['plyr1b']; $t3 = $_POST['plyr1c']; $t3 = $_POST['plyr1d']; $t4 = $_POST['plyr1e']; $t5 = $_POST['plyr1f']; $t6 = $_POST['plyr1g']; $t7 = $_POST['plyr1h']; $teama = array('1', '2', '3', '4', '5', '6', '7', '8'); $teamb = array('1', '2', '3', '4', '5', '6', '7', '8'); $teamc = array('1', '2', '3', '4', '5', '6', '7', '8'); $teamd = array('1', '2', '3', '4', '5', '6', '7', '8'); $teame = array('1', '2', '3', '4', '5', '6', '7', '8'); $teamf = array('1', '2', '3', '4', '5', '6', '7', '8'); $teamg = array('1', '2', '3', '4', '5', '6', '7', '8'); $teamh = array('1', '2', '3', '4', '5', '6', '7', '8'); if (!$plyr1a) { $errors[] = "You did not supply a team member"; } else { if (!$plyr1b) { $errors[] = "You did not supply a team member"; } else { if (!$plyr1c) { $errors[] = "You did not supply a team member"; } else { if (!$plyr1d) { $errors[] = "You did not supply a team member"; } else { if (!$plyr1e) { $errors[] = "You did not supply a team member"; if (!$plyr1f) { $errors[] = "You did not supply a team member"; } else { if (!$plyr1g) { $errors[] = "You did not supply a team member"; } else { if (!$plyr1h) { $errors[] = "You did not supply a team member"; } else { switch ($teama) { case '1': echo $_POST['plyr1a']; break; case '2': $written = $plyr1b; break; case '3': $written = $plyr1c; break; case '4': $written = $plyr1d; break; case '5': $written = $plyr1e; break; case '6': $written = $plyr1f; break; case '7': $written = $plyr1g; break; case '8': $written = $plyr1h; break; default : $written = ""; break; } echo $written; switch ($teamb) { case '1': $written = $plyr1a; break; case '2': $written = $plyr1b; break; case '3': $written = $plyr1c; break; case '4': $written = $plyr1d; break; case '5': $written = $plyr1e; break; case '6': $written = $plyr1f; break; case '7': $written = $plyr1g; break; case '8': $written = $plyr1h; break; default : $written = ""; break; } echo $written; switch ($teamc) { case '1': $written = $plyr1a; break; case '2': $written = $plyr1b; break; case '3': $written = $plyr1c; break; case '4': $written = $plyr1d; break; case '5': $written = $plyr1e; break; case '6': $written = $plyr1f; break; case '7': $written = $plyr1g; break; case '8': $written = $plyr1h; break; default : $written = ""; break; } echo $written; switch ($teamd) { case '1': $written = $plyr1a; break; case '2': $written = $plyr1b; break; case '3': $written = $plyr1c; break; case '4': $written = $plyr1d; break; case '5': $written = $plyr1e; break; case '6': $written = $plyr1f; break; case '7': $written = $plyr1g; break; case '8': $written = $plyr1h; break; default : $written = ""; break; } echo $written; switch ($teame) { case '1': $written = $plyr1a; break; case '2': $written = $plyr1b; break; case '3': $written = $plyr1c; break; case '4': $written = $plyr1d; break; case '5': $written = $plyr1e; break; case '6': $written = $plyr1f; break; case '7': $written = $plyr1g; break; case '8': $written = $plyr1h; break; default : $written = ""; break; } echo $written; switch ($teamf) { case '1': $written = $plyr1a; break; case '2': $written = $plyr1b; break; case '3': $written = $plyr1c; break; case '4': $written = $plyr1d; break; case '5': $written = $plyr1e; break; case '6': $written = $plyr1f; break; case '7': $written = $plyr1g; break; case '8': $written = $plyr1h; break; default : $written = ""; break; } echo $written; switch ($teamg) { case '1': $written = $plyr1a; break; case '2': $written = $plyr1b; break; case '3': $written = $plyr1c; break; case '4': $written = $plyr1d; break; case '5': $written = $plyr1e; break; case '6': $written = $plyr1f; break; case '7': $written = $plyr1g; break; case '8': $written = $plyr1h; break; default : $written = ""; break; } echo $written; switch ($teamh) { case '1': $written = $plyr1a; break; case '2': $written = $plyr1b; break; case '3': $written = $plyr1c; break; case '4': $written = $plyr1d; break; case '5': $written = $plyr1e; break; case '6': $written = $plyr1f; break; case '7': $written = $plyr1g; break; case '8': $written = $plyr1h; break; default : $written = ""; break; } echo $written; } } } } } } } } } ?><br> Match #1: <?php echo $_POST["teama"]; ?> vs <?php echo $_POST["teamb"]; ?> <br> Match #2: <?php echo $_POST["teamc"]; ?> vs <?php echo $_POST["teamd"]; ?> <br> Match #3: <?php echo $_POST["teame"]; ?> vs <?php echo $_POST["teamf"]; ?> <br> Match #4: <?php echo $_POST["teamg"]; ?> vs <?php echo $_POST["teamh"]; ?> <br> <br> Hello, Is it possible to use variables that are declared outside or plainly within a class, and if its possible, how? thanks in advance I'm running the latest version of MySQL on Windows 7 64-bit.
It working fine and set up correctly.
I'd like to use ENVIRONMENT VARIABLES or a variable like "%current_directory%" or "..\%current_directory%" in the configuration files for MySQL, my.ini.
Is this possible? Is my.ini a parsed file, can variables be define and used in it? Help would be much appreciated
I'm running the latest stable version of PHP in Apache Server on Windows 7 64-bit.
It working fine and set up correctly.
I'd like to use ENVIRONMENT VARIABLES or a variable like "%current_directory%" or "..\%current_directory%" in the configuration files for PHP, php.ini.
Is this possible? Is php.ini a parsed file, can variables be define and used in it? Help would be much appreciated
I've got a select statement that looks like this in php. Code: [Select] $sql = "Select * from inventory where ".$fields."".$operator."".$criteria; Everything posts correctly, everything is dereferenced correctly. My only question is how do I get $criteria have single quotes around it? So that when I actually run the query it says select * from inventory where field = 'value'; I've tried Code: [Select] $sql = "Select * from inventory where ".$fields."".$operator.""'.$criteria'; $sql = "Select * from inventory where ".$fields."".$operator.""'$criteria'; and a bunch of variations like that. Thanks for you help. Is it possible to pass variables through #anchors for example <a href="#edit?id=xxx"> and if so how? Hi i got an error. I cant get $new_score and $new_played variables. $name = $_POST["name"]; $score = $_POST["score"]; $result = mysql_query("SELECT * FROM taure_lentele WHERE name='$name'"); $row = mysql_fetch_array($result); if(mysql_num_rows(mysql_query("SELECT name FROM taure_lentele WHERE name='$name'") ) == 1 ) { $old_score = $row['score']; $score + $old_score = $new_score; $old_played = $row['played']; $new_played = $old_played++; mysql_query("DELETE FROM taure_lentele WHERE name='$name'"); mysql_query("insert into `taure_lentele` set `name` = '$name', `score` = '$new_score', `played` = '$new_played"); } Hai thar all you smexy things... I has a problem, and I have come to the lovely folk here for help and/or advice... Basically when making a set of scripts I usually have some files dedicated to JUST variables (usually in the form of a associtive array) and now I feel that I don't like including EVERY variable file into my scripts because I use less than half of the files at any one time in most cases and I feel it's inefficient, so I've been trying to look into a way to call variables into a class as I need them... Basically what I've tried to do is make a class that I can call by doing something like "$_VAR->var_name['key'];" but when I use OOP5s __get method it only takes the "var_name" and leaves out the rest from what I've done, so I then tried to do something like "$_VAR->var_name('key');" and used the __call, but that didn't work out too well either, it would only return a NULL value. Here is the class I've got just now. <? class Vars{ private $var_path; function __construct($path=NULL){ if(isset($path)): $this->var_path = $path; else: $this->var_path = DOC_ROOT.'/vars'; endif; } function __call($name,$arguments){ if(isset($this->$name)): // Do nothing. elseif(is_dir($this->var_path.'/'.$name)): include $this->var_path.'/'.$name.'/'.$arguments[0].'.php'; if(isset($this->$name)): $this->{$name}[$arguments[0]] = $var; else: $this->$name = array(); $this->{$name}[$arguments[0]] = $var; endif; elseif(is_file($this->var_path.'/'.$name.'.php')): include $this->var_path.'/'.$name.'.php'; $this->$name = $var; else: //Return NULL return NULL; endif; unset($var); $return = $this->$name; for($x=0;$x<$y=count($arguments);$x++): $return = $return[$arguments[$y]]; endfor; return $return; } } ?> And this is how I would want to call the "title" feild from the layout.php file. <? $_ = new Vars('C:/xampp/htdocs/inc/vars'); echo $_->layout('title'); ?> I hope you can understand that, if not, tell me what you don't understand and I'll explain. But what I'm here for is either help to do what I'm wanting to do right now, or some advice to point me in the right direction. Thanks in advance, Alan. I am trying to get a JavaScript variable into a PHP variable, I can do this the other way around using the hidden input method and using something like var phpvar = document.getElementById('qwerty').value; to grab the PHP variable from within it. My problem is getting a JavaScript variable into a PHP variable, what methods are out there? Thanks |