Jump to content

Search the Community

Showing results for tags 'variable'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

  1. This is the function I am currently working with... /** * Retrieve search query text * * @return string */ public function getQueryText() { if (!isset($this->_queryText)) { $this->_queryText = $this->_getRequest()->getParam($this->getQueryParamName()); $noescape = preg_replace("/%u([0-9a-f]{3,4})/i","\\1;",urldecode($this->_queryText)); if ($this->_queryText === null) { $this->_queryText = ''; } else { /* @var $stringHelper Mage_Core_Helper_String */ $stringHelper = Mage::helper('core/string'); $this->_queryText = is_array($this->_queryText) ? '' : $stringHelper->cleanString(trim($this->_queryText)); echo '<span style="display: none;">'; echo '<pre>'; var_dump ( $noescape ); echo '</pre>'; echo '</span>'; $maxQueryLength = $this->getMaxQueryLength(); if ($maxQueryLength !== '' && $stringHelper->strlen($this->_queryText) > $maxQueryLength) { $this->_queryText = $stringHelper->substr($this->_queryText, 0, $maxQueryLength); $this->_isMaxLength = true; } } } return $this->_queryText; } I can echo what I need to output in this function with $noescape however I need to modify return $this->_queryText; to include the preg_replace and rawurldecode from $noescape. Please could someone be kind enough to advise of the correct syntax/way of handling this? I did post this on StackOverflow but had no response as of yet. Thanks in advance.
  2. so i found a pdo class to connect to mysql with pdo and looks easy to customize however i have an error that i can't figure it out class <?php class ApplicationResourcePool { static var $_dbHandle; // line 5 private static $_dbConfig = array( 'dsn' => 'mysql:dbname=vax', 'username' => 'vax', 'password' => 'veryrandpasswd', ); public static getDbHandle(){ if(self::$_dbHandle == null){ self::$_dbHandle = new PDO( self::$_dbConfig['dsn'] , self::$_dbConfig['username'], self::$_dbConfig['password'] ); } return self::$_dbHandle; } } class StockMapper { protected $_dbh; public __construct($dbh = null) { if($dbh == null){ $this->_dbh = ApplicationResourcePool::getDbHandle(); } else { $this->_dbh = $dbh; } } public getStockById($stockId){ $sth=$this->_dbh->prepare("SELECT * from stock WHERE id = :stockId"); $sth->bindParam(":stockId", $stockId); $sth->execute(); $result = $sth->fetch(PDO::FETCH_ASSOC); return $result[0]; } } $stockMapper = new StockMapper(); $stockData = $stockMapper->getStockById('302'); ?> Parse error: syntax error, unexpected 'var' (T_VAR), expecting variable (T_VARIABLE) in /path/index.php on line 5 i really don't know what to do
  3. Hey guys, I am learning some basic OOP rules and application right now. I was trying to understand setting a property inside of an object. $name = $_GET['user']; if(isset($name)){ class BankAccount{ public $balance = 3500; public function DisplayBalance(){ return $name . ' your Balance Currently is: ' .$this->balance; } public function Withdraw($amount){ $balance = $this->balance; if($balance < $amount){ $this->balance = 'Sorry you can\'t withdraw any funds right now, not enough to cover amount request of: $' .$amount . '. '; } else{ $this->balance = $this->balance-$amount; } } } So here i am trying to add an extra property into this class by grabbing the variable of $name, which is a dynamic string given from a user submit form. When i add public $user = $name; || $user = $name; I get an error, so my syntax is wrong So ultimately my question is, how do i correctly add the variable of $name into my class ? thanks guys,
  4. Hi, I'm trying to pass a variable from my php script on the page into the og;metadata, but on the timeline all that is shown is the standard html metadata, am I using the correct php code to call the variable so that it shows up on the timeline? <meta property="og:title" content="<?php $_GET['$title']; ?>"/> the title variable comes from here; $title = urlencode("Take The Test!"); Any help on this is much appreciated, Gareth
  5. Howdy folks, I am trying to get sessions to cooperate, but am at a loss. I am trying to copy the variable of userlevel in a session. The array displays correctly on pointerface.php. For some reason, the session doesn't seem to carry over to other pages, and the session ID's are different. I'd appreciate some input as to where I may be going wrong. pointerface.php: session_start(); { include('../htconfig/dbConfig.php'); mysql_connect("$hostname","$username","$password"); mysql_select_db("$database")or die("cannot select DB"); $tbl_name="members"; $sql2="SELECT * FROM members WHERE username='$myusername' and password='$mypassword'"; $result2=mysql_query($sql2); $userlevel=mysql_result($result2,$i,"userlevel"); $_SESSION["userlevel"] = "$userlevel" ; echo session_id(); echo "<br>"; Print_r ($_SESSION); adminnotes.php: session_start(); print_r ($_SESSION); echo session_id(); if($_SESSION['userlevel']=='Admin'){
  6. Hello! Second post here. I'm new to PHP and have an idea of what needs to be done, but im not sure the best way to impliment it. Basically im looking for direction on whether I should use JS, AJAX, Jquery, or something else. from browsing around im guessing its going to be a combination of AJAX and Jquery to get this accomplished. Please advise on the best method to acomplish this. Thanks =) The user needs to populate txtAddr and hit btnGen. The function will then confirm txtAddr is equal to a variable. If it is equal, populate other 2 text fields (txtKey & txtDest) with predefined variables. <form action="frmGen" method="post"> <input name="txtAddr" type="text"> <!-- User enters text here -- Confirm txtAddr.text = $VarAddr -- If True, continue. If False, display DIV message --> <input name="txtDest" type="text"> <!-- Text field is filled with value from server/SQL when btnGen is pressed--> <input name="txtKey" type="text"> <!-- Text field is filled with value from server/SQL when btnGen is pressed--> <input name="btnGen" type="button"> <!-- assuming txtAddr is True, display strings in 2 text fields above & store all values from 3 text boxes in SQL --> </form>
  7. Sorry if my wording/terminalogy on the discription is wrong. I'm new to PHP, so i'll do my best to detail what im trying to do. The PHP is doing what i need it to do. But i do not need to print the whole response. I only need the [address] and [pubkey] values as variables. I have read a few tutorials, but they assume i already know the strings to be converted to variables. Please help Code... <?php require_once 'jsonClient.php'; $service = new jsonClient('http://ooples:booples@'); $apple = array ($service->validateaddress("1234567890")); print_r ($apple); ?> Response... Array ( [0] => Array ( [isvalid] => 1 [address] => 1234567890 [ismine] => 1 [isscript] => [pubkey] => hqwiuehf9 [iscompressed] => 1 [account] => foo ) )
  8. Hi Guys, I have a very basic question that I cannot seem to answer ... so would appreciate any help / advise. Code snippet: $Text1="Hi, how are you"; $Text2="Hey there stranger"; $Text3="Its about time!"; $random_number = rand(1,3); $WelcomeText = "$"."Text".$random_number; echo $WelcomeText; The above script generates the output as $Text3 but what I am trying to achieve is this output: Its about time! I know I can use an array and output the value ... but I wanted to know -- why the above code would not work. Any help / explaination would be great! Thanks
  9. I have a simple web page with 2 buttons that change an icon to red or green based on which button is pressed. When the button is pressed, the variable is stored in a text file, and then recalled to display the proper color icon. (When "Power On" is pressed, the icon turns red, and when "Power Off" is pressed, it turns green.) The problem I have is this: When the page is first loaded, the graphic is blank, until a button is pressed, and then the icon displays properly. The text file with the stored variable is always available on the server, but I cant figure out why the page isnt working properly. I know my webpage is probably full of other problems, but I am a real noob, trying to create my home automation webpage... If you are wondering why I am storing the variable in a text file, it was my way of saving this variable, so that another user could open the same webpage at another time, on another computer, and be able to see the correct status icon. if there is a better way (without Java), please let me know! Here is my code: <!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"> <?php ///////////////////////////////////////////////////////////////////////////////////////////// // Check of LED2 is set. If it is, then use it if (isset($_POST["LED2"])) { $LED2= $_POST["LED2"]; //echo "<b>$LED2</b>"; } else { $LED2 =""; } if ($LED2 == "ON") { // Set led2 ON by calling the Arduino using fopen $h = @fopen("", "rb"); $image = "/Graphics/LED_red.bmp"; } else if ($LED2 == "OFF") { // Set led2 OFF by calling the Arduino using fopen $h= @fopen("", "rb"); $image = "/Graphics/LED_green.bmp"; } ///////////////////////////////////////////////////////////////////////////////////////////// // set and write data to text file { $fp = fopen('graphic.txt','w'); fwrite($fp,$image); } ///////////////////////////////////////////////////////////////////////////////////////////// // Reading the data from text file $graphictemp = file_get_contents('graphic.txt'); $graphic = ($graphictemp); ?> <head> <style type="text/css"> body { font: 100% Verdana, Arial, Helvetica, sans-serif; background: #666666; margin: 0; padding: 0; text-align: center; color: #000000; } .newStyle1 { float: left; } .auto-style1 { color: #FFFFFF; font-size: 20px; } </style> <title>Audio Control</title> </head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <body> <form action="" method="post" > <fieldset style="display:inline; border:none; padding:0px; margin:0px; vertical-align:top; class="newStyle1" style="height: 450px" > <legend align="center" class="auto-style1">Amplifier <img name="LED" src="<?=$graphic?>" width="12" height="12" alt="" style="background-color: #FFFFFF" /></legend> <br/> <button name="LED2" style="height: 1.8em; width: 10em; font-size: 16px;" value="ON" type="submit">Power On</button> <br /> <br /> <button name="LED2" style="height: 1.8em; width: 10em; font-size: 16px;" value="OFF" type="submit">Power Off</button> <br /> <br /> </fieldset> </form> </body> </html>
  10. Hi there, I'm struggling a bit with this. This works fine: line 99: preg_match('^\s', $xmlElem) However, I shouldn't be writing the pattern there directly, because the pattern is in a tab-separated file. If I get it with fgetcsv and put it in another variable $pattern = $data[0]; echo $pattern; // outputs ^\s and then use that variable in the above match line 99: preg_match('/'. $pattern .'/', $xmlElem) then I get an error like: and there's no match. Could anyone help me out? Thank you so much! Cheers, Manuel
  11. Good afternoon! I will apologize upfront, because I am a complete novice when it comes to PHP. I know enough to really mess things up. So, I have inherited a PHP form that writes to MySQL table, then submits to Marketo and gets passed along to Salesforce. The programmer who wrote it, is no longer available and I need to change some of the code. In a nutshell, I have a hidden field (Primary Interest) that populates it's value based on a variable ($serviceLine) that gets entered when a new record is inserted into the table. I need to create a dropdown select that writes to a variable ($interest) for my form, then use that variable to populate Primary Interest, or default to $serviceLine if $interest is not present or NULL. Thanks in advance.
  12. Is it considered incorrect practice to declare privacy modifiers on variable/properties of subclasses? for example: class SubClass { var $property = 'notice there is no private, public, or protected keyword here'; }
  13. Hello everyone, I am having a pretty basic problem. Below is a piece of my code, the first few lines of "Get Value for Bodyfitting" basically gets a value and assigns it to some variables through a select statement (this later on you will see that the values are being shown through echo on the screen in a form of a javascript dropdown for "Style Selection"), now the second few lines is where I have some issues in the "Value for Field 1", I want to get back a value by getting the answer from the first sql but I can't get the value for "$newBodyfitting" because it is only assigned later on, this will allow me to get a dropdown for a "Select Front", this is dependent on the "Select Style" if you see below, I know it might sound confusing. Thanks in advance. //Get Division $div_query = "SELECT distinct DIVISION, CLOTHDB FROM MTM_DIVISIONS_S ORDER BY CLOTHDB"; $div_result = oci_parse($connect,$div_query); oci_execute($div_result); while ($div_row = oci_fetch_array($div_result, OCI_ASSOC)) { $divArray[] = "{$div_row['CLOTHDB']}"; $divDivArray[] = "{$div_row['DIVISION']}"; } oci_free_statement($div_result); //Get Value for Bodyfitting $bodyfitting_query="SELECT BODYFITTING, BFCODE FROM MTM_STYLES_S WHERE DIVISION= '".$divDivArray[$i]."' AND STYLE_TYPE='BODY' GROUP BY BODYFITTING, BFCODE ORDER BY BODYFITTING"; $bodyfitting_result = oci_parse($connect,$bodyfitting_query); oci_execute($bodyfitting_result); //Get Value for Field1 $field1_query="SELECT MTM_STYLES_S.CODE,MTM_SUFFEX_S.TEXT FROM MTM_STYLES_S,MTM_SUFFEX_S WHERE MTM_SUFFEX_S.DIVISION='".$divDivArray[$i]."' AND (MTM_STYLES_S.FIELD=MTM_SUFFEX_S.FIELD AND MTM_STYLES_S.CODE=MTM_SUFFEX_S.CODE) AND MTM_STYLES_S.STYLE_TYPE='BODY' AND MTM_STYLES_S.BODYFITTING='".$newBodyfitting."' AND MTM_STYLES_S.FIELD=1 ORDER BY MTM_STYLES_S.FIELD,MTM_STYLES_S.CODE"; $field1_result = oci_parse($connect,$field1_query); oci_execute($field1_result); //Setup new dropdown for Style Selection echo "\tClearOptionsFastAlt('bodyfitting');\n"; echo "\t\tdocument.pickDivision.textInput.value='';\n"; echo "var divcomp = division.replace(/^\s+|\s+$/g, '');"; echo "var selectObj = document.pickDivision.bodyfitting;\n"; echo "var numShown = selectObj.options.length;\n"; echo "selectObj.selectedIndex = -1;\n"; echo "\t\t\tselectObj.options[numShown] = new Option('- Select Style -', '');\n"; echo "\t\t\tnumShown++;\n"; while ($bodyfitting_row = oci_fetch_array($bodyfitting_result, OCI_ASSOC)) { $newBodyfitting=$bodyfitting_row['BODYFITTING']; $newBfcode=$bodyfitting_row['BFCODE']; echo "\t\t\tselectObj.options[numShown] = new Option('".$newBfcode.' '.$newBodyfitting."', '".$newBfcode."');\n"; echo "\t\t\tnumShown++;\n"; $y++; } //Setup dropdown new Front dependent on Style above echo "\t\t\tdocument.pickDivision.bodyfitting.options[0].selected = true;\n\n"; echo "\t\tdocument.pickDivision.field1;\n"; echo "\tClearOptionsFastAlt('field1');\n"; echo "\t\tdocument.pickDivision.textInput.value='';\n"; echo "var divcomp = division.replace(/^\s+|\s+$/g, '');"; echo "var selectObj = document.pickDivision.field1;\n"; echo "var numShown = selectObj.options.length;\n"; echo "selectObj.selectedIndex = -1;\n"; echo "\t\t\tselectObj.options[numShown] = new Option('- Select Front -', '');\n"; echo "\t\t\tnumShown++;\n"; while ($field1_row = oci_fetch_array($field1_result, OCI_ASSOC)) { $newField1=$field1_row['TEXT']; $newField2=$field2_row['CODE']; echo "\t\t\tselectObj.options[numShown] = new Option('".$newField1.''.$newField2."');\n"; echo "\t\t\tnumShown++;\n"; $y++; } echo "\t\t\tdocument.pickDivision.field1.options[0].selected=true;\n\n"; oci_free_statement($field1_result); oci_free_statement($bodyfitting_result);
  14. Hi folks, I have a project that im working on right now, I have developed it in joomla, on the index page, I have a menu which shows the year , I need to know how to code a php variable to get the active item name of this menu so I can show (echo) it where I want. I have attached a screenshot for better understanding, Any help would be much appreciated. thanks.
  15. when i click on image1 with id=1, it stores in session and when i click on image2 with id=2, it stores in session too next to the first one, and when i click on image3 with id=3, it stores in session next to id=2. and so on.... i hope you understand what i am asking .... need help. i know how to get value from array.... like <?php// begin the sessionsession_start(); // create an array$my_array=array('cat', 'dog', 'mouse', 'bird', 'crocodile', 'wombat', 'koala', 'kangaroo'); // put the array in a session variable$_SESSION['animals']=$my_array; // a little message to say we have done itecho 'Putting array into a session variable';// loop through the session array with foreachforeach($_SESSION['animals'] as $key=>$value) { // and print out the values echo 'The value of $_SESSION['."'".$key."'".'] is '."'".$value."'".' <br />'; }?> /*************************************************************************************************************************************/ but wat i want is, cat ,dog,mouse,bird,crocodile,wombat,koala,kangaroo ... stored in array when i click on them.... i hope you understand.. please help!!! thanks and regards, jazz..
  16. I have the following query that gives me the result i want. In a nutshell it searches two columns to find the max value in each of these two columns and returns the sum of these two values. When i try to pass it to a variable in php it doesn't seem to work. I want to be able to pass the sum in a variable so i can use the variable later into an IF Condition. For example: if ($scoremax >= '160') { code here } Here is my query: select (max(scoreioa) + max(scoreioa2)) from result where username='username' and here is the php code: $maxscore = mysql_query("select (max(scoreioa) + max(scoreioa2)) from result where username='username'"); mysql_data_seek($maxscore, $scoremax); $row = mysql_fetch_row($maxscore); $scoremax = $row[0];
  17. Hello my name is Erison. I'm new here and I'm sure that is not sleep for days. I want that number in the variable $parcelaX be displayed only when equal to $i of loop "for". can someone help me? Please ... below my code: <?php for($i = 1; $i <= $parcelas; $i++){ ?> <div><?php echo $i ?></div> <div> <?php while($arrParcelas = mysql_fetch_array($sqlParcelas)){ $dataX = $arrParcelas['dataPagamento']; $parcelasX = $arrParcelas['parcelaPaga']; $valorX = $arrParcelas['valorPago']; if($i == $parcelasX) { echo $parcelasX . " - " . $valorX . " <br /> "; } ?> </div> <?php } ?>
  18. Hey, i want the '***' to change depending on the length of the persons password. any way to echo a variable like this?
  19. I have created a PHP web page that allows me to control a serial device (a speaker selector matrix), and an Arduino (to switch an amplifier off and on) over my network. I am trying to make it so the text color changes on what ever button is pressed. The button presses are stored as a variable and then POSTed. I would like the text on the current button selected to turn red. There are 5 separate sets of buttons, so each set could have a button with red text at any time. Eventually, I would like to have a graphic next to the button which would change based on a button press. (baby steps!) Attached is the web page. Please keep any answers in laymans terms, since I am a real PHP noob! This webpage is the result of A LOT of trial and error, but it works! Any suggestions are welcome! audio.php
  20. Notice: Undefined variable: bing_results in /home/msc2012/12254822/public_html/safe_dir/Almost_Gs.php on line 295 Basically, its the 'Interleaving' case that does not work as the echoed variables are not recognized when run on the server but the IDE does not highlight them as errors so it recognizes them. If you pay attention further down the switch statement under other cases I use the same variable $bing_results where it works and is recognized by the server. The scenario is the same with $Blekko and $Google case 'Interleaving': $irl =0; while($irl <= 90) { echo 'hellooo!!'; echo '<a href ='.$bing_results[$irl]['url'].'><h5>'.$bing_results[$irl]['url_title'].'</h5></a><br>'; echo '<p>'.$bing_results[$irl]['snippet'].'</p><br>'; echo '<p>'.$bing_results[$irl]['rank'].'<p><br>'; echo '<b>'.$bing_results[$irl]['engine'].'</b><br>'; echo '<hr>'; echo '<a href ='.$Blekko[$irl]['url'].'><h5>'.$Blekko[$irl]['url_title'].'</h5></a><br>'; echo '<p>'.$Blekko[$irl]['snippet'].'</p><br>'; echo '<p>'.$Blekko[$irl]['rank'].'<p><br>'; echo '<b>'.$Blekko[$irl]['engine'].'</b><br>'; echo '<hr>'; echo '<a href ='.$google[$irl]['url'].'><h5>'.$google[$irl]['url_title'].'</h5></a><br>'; echo '<p>'.$google[$irl]['snippet'].'</p><br>'; echo '<p>'.$google[$irl]['rank'].'<p><br>'; echo '<b>'.$google[$irl]['engine'].'</b><br>'; echo '<hr>'; $irl++; } break; case 'Non-Aggregated': $nag_c=0; // non aggregated count while ($nag_c <=$blekko_count) { echo '<a href='.$Blekko[$nag_c]['url'].'><h4>'.$Blekko[$nag_c]['url_title'].'</h4></a>'; echo '<p>'.$Blekko[$nag_c]['snippet'].'<p>'; echo '<b>'.$Blekko[$nag_c]['engine'].'</b>'; echo '<hr>'; $nag_c++; } $nag_c =0; while ($nag_c <= $google_count) { echo '<a href='.$google[$nag_c]['url'].'><h4>'.$google[$nag_c]['url_title'].'</h4></a>'; echo '<p>'.$google[$nag_c]['snippet'].'</p><br>'; echo '<b>'.$google[$nag_c]['engine'].'</b><br>'; echo '<hr>'; $nag_c++; } $nag_c=0; while ($nag_c<=$bing_count) { echo '<a href='.$bing_results[$nag_c]['url'].'>'.'<h4>'.$bing_results[$nag_c]['url_title'].'</h4></a>'; echo '<p>'.$bing_results[$nag_c]['snippet'].'</p>'; echo '<b>'.$bing_results[$nag_c]['engine'].'</b>'; echo '<hr>'; $nag_c++; } case 'Bing': $binger = 0; while ($binger<=$bing_count) { echo '<a href='.$bing_results[$binger]['url'].'>'.'<h4>'.$bing_results[$binger]['url_title'].'</h4></a>'; echo '<p>'.$bing_results[$binger]['snippet'].'</p><br>'; echo '<b>'.$bing_results[$binger]['engine'].'</b><br>'; echo '<hr>'; $binger++; } break; case 'Blekko': $blekr = 0; while ($blekr<=$blekko_count) { echo '<a href='.$Blekko[$blekr]['url'].'><h4>'.$Blekko[$blekr]['url_title'].'</h4></a>'; echo '<p>'.$Blekko[$blekr]['snippet'].'<p>'; echo '<b>'.$Blekko[$blekr]['engine'].'</b>'; echo '<hr>'; $blekr++; } break; case 'Google': $froo = 0; while ($froo <=$google_count) { echo '<a href='.$google[$froo]['url'].'><h4>'.$google[$froo]['url_title'].'</h4></a>'; echo '<p>'.$google[$froo]['snippet'].'</p>'; echo '<b>'.$google[$froo]['engine'].'</b>'; echo '<hr>'; $froo++; } break; } ?>
  21. I have an array containing the users input of 14 strings, I want to search this array to find duplicates, but I'm not sure how to go about it efficiently... there isn't already a function that does this by any chance is there? Thanks
  22. I'm trying to get a query expansion sort of effect that shows suggestions for misspellings and then lets you click them to input them in to your form. So I have passed a variable through a hyperlink but I can't seem to GET it in to the "value" field <form method="POST" action='AllinOneMonstaaa.php'> <label for="query">Query</label><br/> <input name="query" type="text" size="60" maxlength="60" value="<?php echo ($_GET['query']);?>" /><br /><br /> Notice the $_GET. I want it to be auto-filled if a user has selected an option in the previous page from the following php file. if ($s_count > 1) { echo ('<h4>Did you mean?</h4>'); while ($ss_count <=$s_count) { echo '<a href = "AllinOneMonstaaa.php?query='.$suggestion[$ss_count].'">'.$suggestion[$ss_count].'</a><br>'; $ss_count++; } }
  23. I wrote a long explaination, but then the page was refreshed an I lost it... essentially I can't get variables to work between functions, resorted to globals, I can get away with it, but I can't even get that to worl... code: <?php global $checkvar; //get the 'checkvar' this is an array of strings $checkvar = $_GET['checkvar']; checkvariable(); function checkvariable() { var_dump($checkvar); } ?> the dump of $checkvar comes up NULL in the function, but fine right after its been called.
  24. 'http://www.dictionaryapi.com/api/v1/references/collegiate/xml/'.$query.'?key=' $query is surrounded with ' ' when I try to echo. How do I avoid them?
  25. Hi, I am trying to produce a result that requires 2 seperate queries to get the values required to produce the result. It works if I hard code the BETWEEN date values but when I try to pull them from the `Reportrange` table no results are returned. I am using includes to set variables, open and close the connection. (also works if BETWEEN dates are hard coded) See below: The idea is that it can search the `DMCstats` table for a count of each distinct 'gender' value WHERE the 'encdate' matches the range set in `Reportrange` record#1(---->bdate and edate) I think the issue is with the way I am calling the variables $bdat , $edat for $result My apologies in advance if this post does not conform to this forums expectations, its my first post here, feel free to enlighten me! Thanks in advance to all those donating their time for the greater good! Open Connection Include: <?php //Conection Info $con=mysqli_connect("localhost","******","******","******"); // Check connection if (mysqli_connect_errno()) echo "Failed to connect to MySQL: " . mysqli_connect_error(); ?> Close Connection Include: <?php mysqli_close($con); ?> Date Variables include: <?php include 'openconnection.php'; $bdat=mysqli_query($con,"SELECT bdate, FROM `ReportRange` WHERE cf_id=1"); $edat=mysqli_query($con,"SELECT edate, FROM `ReportRange` WHERE cf_id=1"); include 'closeconnection.php'; ?> Gender Query: //Open Connection include 'openconnection.php'; //Set Variables include 'datevars.php'; //Query $result=mysqli_query($con,"SELECT gender,encdate, COUNT(gender) AS gender_count FROM `DMC_Stats` WHERE encdate BETWEEN " . $bdat . " AND " . $edat . " GROUP BY gender"); //Output to html echo "<table border='1'> <tr> <th>Gender</th> <th>Total</th> </tr>"; while($row=mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['gender'] . "</td>"; echo "<td>" . $row['gender_count'] . "</td>"; echo "</tr>"; } echo "</table>"; //Close connection include 'closeconnection.php'; ?> Regards
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.