PHP - Returning Variables As Variables To Be Used Later
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()); ?> Similar TutorialsHi, I have a user sign up form. When some data is incorrect or missing it reloads the form, saving the info the user has already entered and displaying an error message for the parts that are invalid. For example: Code: [Select] <tr><td width = "300"> <label for="email">Email Address:</label></td> <td><input type="text" id="email" name="email" value="<?php if (!empty($email)) echo $email; ?>" /><br /> </td></tr> How can I return the submitted info for a checkbox and a birthdate? Sorry, the birthdate code is kind of huge. Code: [Select] <tr><td width = "300"> <label for="terms">I agree to the <a href = "/TOS.php">Terms of Service</a>.</label></td> <td><input type="checkbox" id="terms" name="terms" value = "checked"/><br /> </td></tr> <td> <select id = "DateOfBirth_Month" name="DateOfBirth_Month"> <option>Month</option> <option value="1">January</option> <option value="2">Febuary</option> <option value="3">March</option> <option value="4">April</option> <option value="5">May</option> <option value="6">June</option> <option value="7">July</option> <option value="8">August</option> <option value="9">September</option> <option value="10">October</option> <option value="11">November</option> <option value="12">December</option> </select> <select id = "DateOfBirth_Day" name="DateOfBirth_Day"> <option>Day</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option> <option value="16">16</option> <option value="17">17</option> <option value="18">18</option> <option value="19">19</option> <option value="20">20</option> <option value="21">21</option> <option value="22">22</option> <option value="23">23</option> <option value="24">24</option> <option value="25">25</option> <option value="26">26</option> <option value="27">27</option> <option value="28">28</option> <option value="29">29</option> <option value="30">30</option> <option value="31">31</option> </select> <select id = "DateOfBirth_Year" name="DateOfBirth_Year"> <option>Year</option> <option value="2010">2010</option> <option value="2009">2004</option> <option value="2008">2003</option> <option value="2007">2002</option> <option value="2006">2001</option> <option value="2005">2000</option> <option value="2004">2004</option> <option value="2003">2003</option> <option value="2002">2002</option> <option value="2001">2001</option> <option value="2000">2000</option> <option value="1999">1999</option> <option value="1998">1998</option> <option value="1997">1997</option> <option value="1996">1996</option> <option value="1995">1995</option> <option value="1994">1994</option> <option value="1993">1993</option> <option value="1992">1992</option> <option value="1991">1991</option> <option value="1990">1990</option> <option value="1989">1989</option> <option value="1988">1988</option> <option value="1987">1987</option> <option value="1986">1986</option> <option value="1985">1985</option> <option value="1984">1984</option> <option value="1983">1983</option> <option value="1982">1982</option> <option value="1981">1981</option> <option value="1980">1980</option> <option value="1979">1979</option> <option value="1978">1978</option> <option value="1977">1977</option> <option value="1976">1976</option> <option value="1975">1975</option> <option value="1974">1974</option> <option value="1973">1973</option> <option value="1972">1972</option> <option value="1971">1971</option> <option value="1970">1970</option> <option value="1969">1969</option> <option value="1968">1968</option> <option value="1967">1967</option> <option value="1966">1966</option> <option value="1965">1965</option> <option value="1964">1964</option> <option value="1963">1963</option> <option value="1962">1962</option> <option value="1961">1961</option> <option value="1960">1960</option> <option value="1959">1959</option> <option value="1958">1958</option> <option value="1957">1957</option> <option value="1956">1956</option> <option value="1955">1955</option> <option value="1954">1954</option> <option value="1953">1953</option> <option value="1952">1952</option> <option value="1951">1951</option> <option value="1950">1950</option> <option value="1949">1949</option> <option value="1948">1948</option> <option value="1947">1947</option> <option value="1946">1946</option> <option value="1945">1945</option> <option value="1944">1944</option> <option value="1943">1943</option> <option value="1942">1942</option> <option value="1941">1941</option> <option value="1940">1940</option> <option value="1939">1939</option> <option value="1938">1938</option> <option value="1937">1937</option> <option value="1936">1936</option> <option value="1935">1935</option> <option value="1934">1934</option> <option value="1933">1933</option> <option value="1932">1932</option> <option value="1931">1931</option> <option value="1930">1930</option> <option value="1929">1929</option> <option value="1928">1928</option> <option value="1927">1927</option> <option value="1926">1926</option> <option value="1925">1925</option> <option value="1924">1924</option> <option value="1923">1923</option> <option value="1922">1922</option> <option value="1921">1921</option> <option value="1920">1920</option> <option value="1919">1919</option> <option value="1918">1918</option> <option value="1917">1917</option> <option value="1916">1916</option> <option value="1915">1915</option> <option value="1914">1914</option> <option value="1913">1913</option> <option value="1912">1912</option> <option value="1911">1911</option> <option value="1910">1910</option> <option value="1909">1909</option> <option value="1908">1908</option> <option value="1907">1907</option> <option value="1906">1906</option> <option value="1905">1905</option> <option value="1904">1904</option> <option value="1903">1903</option> <option value="1902">1902</option> <option value="1901">1901</option> <option value="1900">1900</option> </select> </td></tr> Thanks if you can help, Craig Hi all, I am having some trouble with a script.. all works fine except for the calculation part. It isn't adding up, but the reason for this is because when I echoed all the variable it seems that they are blank, the problem is I can't figure out why? <?php # you don't display errors on in-use scripts, do you? ini_set('display_errors',0); error_reporting(E_ALL|E_STRICT); class webPoll { # makes some things more readable later const POLL = true; const VOTES = false; # number of pixels for 1% on display bars public $scale = 2; public $question = ''; public $answers = array(); private $header = '<form class="webPoll" method="post" action="%src%"> <input type="hidden" name="QID" value="%qid%" /> <h4>%question%</h4> <br /> <ul>'; private $center = ''; private $footer = "\n</ul>%button%\n</form>\n"; private $button = '<p class="buttons"><button type="submit">Vote!</button></p>'; private $md5 = ''; /** * --- * Takes an array containing the question and list of answers as an * argument. Creates the HTML for either the poll or the results depending * on if the user has already voted */ public function __construct($params) { $this->question = array_shift($params); $this->answers = $params; $this->md5 = md5($this->question); $this->header = str_replace('%src%', $_SERVER['SCRIPT_NAME'], $this->header); $this->header = str_replace('%qid%', $this->md5, $this->header); $this->header = str_replace('%question%', $this->question, $this->header); # seperate cookie for each individual poll isset($_COOKIE[$this->md5]) ? $this->poll(self::VOTES) : $this->poll(self::POLL); } private function poll($show_poll) { $replace = $show_poll ? $this->button : ''; $this->footer = str_replace('%button%', $replace, $this->footer); # static function doesn't have access to instance variable if(!$show_poll) { $results = webPoll::getData($this->md5); $votes = array_sum($results); } for( $x=0; $x<count($this->answers); $x++ ) { $this->center .= $show_poll ? $this->pollLine($x) : $this->voteLine($this->answers[$x],$results[$x],$votes); } echo $this->header, $this->center, $this->footer; } private function pollLine($x) { isset($this->answers[$x+1]) ? $class = 'bordered' : $class = ''; return " <li class='$class'> <label class='poll_active'> <input type='radio' name='AID' value='$x' /> {$this->answers[$x]} </label> </li> "; } private function voteLine($answer,$result,$votes) { echo "Answer: $answer"; echo "<br />"; echo "Result: $result"; echo "<br />"; echo "Votes: $votes"; echo "<br />"; echo "<br />"; $result = isset($result) ? $result : 0; $percent = round(($result/$votes)*100); $width = $percent * $this->scale; return " <li> <div class='result' style='width:{$width}px;'> </div>{$percent}% <label class='poll_results'> $answer </label> </li> "; } // remainder of script here ?> The ones that are returning blank a $result and $votes $results should be the number of votes a specific option has received while $votes is the total number of votes in the whole poll. My database contains the following data... QID AID votes 685b9628ca340529fa54208c65721dd7 2 205 685b9628ca340529fa54208c65721dd7 0 5 685b9628ca340529fa54208c65721dd7 1 2 It's from the following tutorial - http://net.tutsplus.com/tutorials/ph...poll-with-php/ Can anyone advise me here? Many thanks, Greens85 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 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? 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> 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'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
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[] = ""; 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 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. Hello, Is it possible to use variables that are declared outside or plainly within a class, and if its possible, how? thanks in advance Hi guys, i have a ipn paypal setup where users can buy items from my custom made shop, however in original ipn code, the logged in users should have the same email with paypal to call on ipn which user has bought what, so I have decided to pass a custome variable as <input type="hidden" name="custom" value="<?php echo "$username";"> the hard part is in my ipn how im i going to recieve the username variable? what should i put in my ipn. In ipn code I have example code: $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $payment_status = $_POST['payment_status']; $payment_amount = $_POST['mc_gross']; $payment_currency = $_POST['mc_currency']; $txn_id = $_POST['txn_id']; $receiver_email = $_POST['receiver_email']; $payer_email = $_POST['payer_email']; but now, can u help me to recieve the username so i can match my mysql query which user has bought what? thanks in advance I am not sure how to do the below, would variable variables be the way -- those are a new and confusing thing for me :-/ i have an array: $contactData = array('admin_firstName' => 'John', 'admin_lastName' => 'Smith', 'user_firstName' => 'Betty', user_lastName => 'Jones'); I have a function that little function that looks like this: function compare($contactSet, $var, $value){ global $contactData; $key = $contactData . "['" . $contactSet . "_" . $var ."']"; //above doesnt work, but you can see how the array key is constructed if ($key == $value) { // So, if the array key varied it would look like: // if ($contactData['admin_firstName'] == $value echo "same"; } else { echo "different"; } } and then I want to call it like this: compare('admin', 'firstName', 'John'); //would echo "same"; Any help is greatly appreciated. I have often wanted to use variable variables, or whatever this would be called, but don't know to pull it off. I can add another example if this wasnt clear enough. I am getting the following error: Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /Library/WebServer/Dev/classtest/lib/class_userdata.php on line 5 on this class code: Code: [Select] class userdata { public $name = ""; public $city = ""; public $phone = ""; function setData($n, $c, $p) { $name = $n; $city = $c; $phone = $p; } function getData() { $userdata=array('name'=>$name, 'city'=>$city, 'phone'=>$phone); return $userdata; } } I thought that was a proper way to set up some class variables. (http://www.victorchen.info/accessing-php-class-variables-and-functions/). Thanks. Hello I have a table with four variables. By choosing each of the variables we obtain a numerical value. I have a form with each of the variables to be selected and what I meant was that it appeared the value without having to place the table on page. step I (VAR 1) VAR2 VAR3 8h 10h 12h 14h 16h 18h(VAR4) A 0-30 4 2 1 1 2 4 A >30 1 3 2 4 5 3 B 0-30 7 6 4 6 4 3 B >30 4 5 3 6 3 5 C 0-30 2 2 2 2 1 8 C >30 8 8 5 6 2 2 D 0-30 6 9 8 2 8 8 D >30 5 5 6 8 6 8 step II (VAR1) VAR2 VAR3 8h 10h 12h 14h 16h 18h(VAR4) A >30 2 3 5 8 2 6 B >30 2 8 2 9 8 8 C >30 8 9 2 8 5 2 D >30 8 2 1 8 2 9 step I and step II is the first variable, then we have to see if it was A, B or C (second variable) and perhaps more complicated if the input value is between 0 - 30 or >30 (third variable) in stage I or greater than zero (third variable) in step II. The four variable was the hours. Have any suggestions on how I do this? Thanks I have a beginners script with html form that captures random words entered by users. This form should be sent to the story.php which displays the full story using the variables entered by users. Why isn't this working? story.html <html> <head> <title>Story</title> </head> <body> <h1>Story</h1> <h3>Please fill in the blanks below, and I'll tell you a story</h3> <form method = "post" action = "story.php"> <table border = 1> <tr> <th>Color:</th> <th> <input type = "text" name = "color" value = ""> </th> </tr> <tr> <th>Musical Instrument</th> <th> <input type = "text" name = "instrument" value = ""> </th> </tr> <tr> <th>Animal</th> <th> <input type = "text" name = "anim1" value = ""> </th> </tr> <tr> <th>Another animal</th> <th> <input type = "text" name = "anim2" value = ""> </th> </tr> <tr> <th>Yet another animal!</th> <th> <input type = "text" name = "anim3" value = ""> </th> </tr> <tr> <th>Place</th> <th> <input type = "text" name = "place" value = ""> </th> </tr> <tr> <th>Vegetable</th> <th> <input type = "text" name = "vegetable" value = ""> </th> </tr> <tr> <th>A structure</th> <th> <input type = "text" name = "structure" value = ""> </th> </tr> <tr> <th>An action</th> <th> <select name = "action"> <option value = "fast asleep">fast asleep</option> <option value = "drinking cappucino">drinking cappucino</option> <option value = "wandering around aimlessly">wandering around aimlessly</option> <option value = "doing nothing in particular">doing nothing in particular</option> </select> </th> </tr> <tr> <td colspan = 2> <center> <input type = "submit" value = "tell me the story"> </center> </td> </tr> </table> </form> </body> </html> storySimple.php <html> <head> <title>Little Boy Who?</title> </head> <body> <h1>Little Boy Who?</h1> <h3>Values from the story page</h3> <table border = 1> <tr> <th>Variable</th> <th>Value</th> </tr> <tr> <th>color</th> <td><? print $color ?></td> </tr> <tr> <th>instrument</th> <td><? print $instrument ?></td> </tr> <tr> <th>anim1</th> <td><? print $anim1 ?></td> </tr> <tr> <th>anim2</th> <td><? print $anim2 ?></td> </tr> <tr> <th>anim3</th> <td><? print $anim3 ?></td> </tr> <tr> <th>place</th> <td><? print $place ?></td> </tr> <tr> <th>vegetable</th> <td><? print $vegetable ?></td> </tr> <tr> <th>structure</th> <td><? print $structure ?></td> </tr> <tr> <th>action</th> <td><? print $action ?></td> </tr> </table> <form> </html> story.php <html> <head> <title>Little Boy Who?</title> </head> <body> <center> <h1>Little Boy Who?</h1> <? print <<<HERE <h3> Little Boy $color, come blow your $instrument!<br> The $anim1's in the $place, the $anim2's in the $vegetable.<br> Where's the boy that looks after the $anim3?<br> He's under the $structure, $action. </h3> HERE; ?> </center> </body> </html> PLEASE HELP! I am trying to tidy up the code for my site, and I have a ton of MySQL queries and variables that have not been unset/freed. Is there any way to view stored variables, other than session variables??? (because I know how to do that already) how do i insert two same values bearing variable into the same row though different column into a database? Insertion was successful but at the end I always end up getin an error for which I was not allowed a redirection...thanx error: Code: [Select] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') VALUES('spaceman12', 'ja')' at line 1 I have a form page (referred to as form.php) which is then processed via a submit button, the script then processes the data from the form.php and if it discovers an error it then sets a variable containing the error message my process page contains Code: [Select] if (empty($b_addr)) { $b_addr_error = "Address is required"; $check_failed = TRUE;} header("Location: form.php"); then my form.php contains Code: [Select] $b_addr_error = safe($_GET['b_addr_error']); if (isset($_POST['$b_addr_error'])) { echo "<div class='errorfont' align='center'>'".$b_addr_error."';</div>"; } but the variables do not get passed back to form.php from the process page, any ideas? Thank you. |