Jump to content

bsmither

Members
  • Posts

    213
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by bsmither

  1. Within quotes, PHP will expand variables. $_GET is a variable, and PHP will try to show it's contents - but can't because it is an array. Within apostrophes, PHP will not expand variables. So, the line might work better as: exit('$_GET not SET - '.print_r($_GET,true));
  2. A basic web form will POST the form element name (key) and the user entered data (value) back to the form's action attribute. To get a form to submit data via the querystring (so that the script will use $_GET -- if you insist), the form's method attribute must be 'get' (although this might be the browser's default action).
  3. $sql = ('INSERT INTO `'.$_SESSION["use"][0].'` (ID,Amic) VALUES (`'.$_SESSION["person"][0].'`, `"1"`)'); 1. I believe surrounding the entire right side of the equal sign is not necessary. 2. Backticks are used only to "quote" (bad term) database names, table names, and column names - never values.
  4. I found references to the task by Googling: display pdf in flash player
  5. You could try the Flash Player approach. The PDF will need to be converted to a Flash-compatible file.
  6. Usually, the message: Access denied for user 'asdasd'@'localhost' (using password: YES) means that, even though a password is being supplied, the problem is... * the username is not recognized by the database server * the password is not recognized by the database server * the database being connected to does not have permission to let this user access it as per the database server * the database server has been told to only allow this user access from a particular computer, other than localhost
  7. I am not at all sure the ternary format is conducive to making statements (sorry, I don't have the terminology to name this type of statement). As best I know, the ternary format is supposed to return a value from two expressions, one for true and one for false, and assign it to a variable, or to use it 'in-line'. So, this, define('DS', DIRECTORY_SEPARATOR), doesn't evaluate to anything. It certainly does something, but is doing something in this context the same as making a result available for use. (I've seen some weird statement formulations, especially with the for() parameters, so this may be perfectly legitimate.) But I have my doubts. So, I would experiment with: if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR);
  8. "$_POST ['b_first'] $_POST ['b_last']" ------ ----------- ------ ---------- $_POST is certainly the name of an array variable. The fact that the brackets are disconnected from the variable name makes the brackets a literal string. Hence, they show in the email. So, let's look at this: " $_POST['b_first'] $_POST['b_last'] \n"; ----------------- ---------------- $_POST is certainly the name of an array variable, but can PHP accurately determine if the brackets belong to the variable? Since there is some doubt, we may wish to force the issue and try one of two alternatives: " ".$_POST['b_first']." ".$_POST['b_last']." \n"; This concatenates literal strings with stand-alone variables. Guaranteed to work. " {$_POST['b_first']} {$_POST['b_last']} \n"; This encapsulates the entirety of the variable expression in braces. This may work.
  9. " 8 types of fruits and 8 types of electronic gadgets and you just want to know the total number of count of each item" Can we assume that for each of the 16 types/categories of items, they can be grouped by a distinct identifier? Such that: SELECT COUNT(*) AS `count` FROM `table` WHERE `condition` = 'x' SELECT COUNT(*) AS `count` FROM `table` WHERE `condition` = 'y' SELECT COUNT(*) AS `count` FROM `table` WHERE `condition` = 'z' Can this be grouped such as: SELECT COUNT(`condition`) FROM `table` GROUP BY `condition` (Hope I got that right.)
  10. In the application I am very familiar with, it uses a cache. It will MD5 the query to use as a filename, serialize/base64_encode the resultset as the file contents, then save it. Assuming the database contents don't change all that frequently, the code that would send this query to the database can MD5 the query, do a file_exists() test, and if it's in the cache, re-use that resultset.
  11. Ah! I think the database is returning strings instead of floats. So, the line might work better as: $price[] = (float)$row['krl'];
  12. I don't know PHPChart, but... Maybe because $price is already an array? You are sending an array, of which the only element is the array $price, into the class.
  13. You are assembling <td>'s based on a $row loop. Perhaps you mean to use the $column parameter. Then you can use the $row parameter to have an outer loop that makes $row number of <tr> rows.
  14. I have seen several versions of several browsers be able to detect and internally fix non-serious syntactical errors: <tag attr1="val1"attr2="val2" /> where there is a missing space <tag><nest1></nest1><nest2></tag> where there are open tags When I ask FF to show me the source code, the display will put in bold red things like the above. So, perhaps some browsers would recognize the start of another tag and internally finish the input tag. Or, ignore the less-than-a sequence, treat the href attribute as inconsequential (to be identified by a javascript selector, perhaps), and also ignore the close anchor tag (But that would show in FF's source code view.)
  15. Using global $db is one way. Another way I see often (and confused me because I didn't realize what was going on) is to realize that variables assigned in the global scope can be reached via the $GLOBALS['db'] super-variable. You may want to initially use $GLOBALS['db'] = new PDO().
  16. What are the practical differences between PHPX.Y.Z's source download release, qa release, and snapshot release? I am trying to build my own PHP from source on Windows Server 2008 using Visual Studio 2013. I get to a point in the process as outlined in a step-by-step narrative where I am suppose to choose all my options, but the option to have the FPM enabled isn't in the list - but the folder is there. Is there a specific source variant that gives me everything - and I mean everything! - so I will get the FPM anyway - without the gnashing of teeth caused by having no instruction on what to do when something slightly different is needed than what the narrative lays out.
  17. Please observe how you are using $_SESSION('uid') as the name of a function, rather than the name of an array variable.
  18. This seems to be concatenating three apparent strings to one string. $dob = $dob_day . '' . $dob_month . '' . $dob_year; Then you are using $dob[0], $dob[1], $dob[2] as an array.
  19. There is also Google Charts, which is javascript based. Once the javascript chart is up and running in the browser (with your data), there are some nifty things you can do with it.
  20. I know of two approaches to solve this. At the end of cart_update.php, have: * this statement: include /{full path to store code}/index.php; * or this statement: header(location: /index.php ); The first saves a request by the browser, but the browser sees the incoming page as belonging to the last URL used. The second allows for the code to retain important parts of the querystring, if needed, from the POSTed URL.
  21. "disabled in the server configuration" This says you are not going to get your file. Please have a conversation with your hosting provider.
  22. "I am getting an error with PHP." How do you know it's an error? A pervasive mistake I see is this: while ($row = mysql_fetch_assoc($result)) { Technically, you are testing for $row containing a non-false value, but you are not doing anything should the expression for while() be false. mysql_fetch_assoc could return false - and it eventually will - but return false immediately. Sketch your flowchart and determine where program control flows when while() is false.
  23. I don't like the %20 sequences in the javascript code. (Doesn't mean I know they are bad. Just don't like 'em.)
  24. Fatal error: Call to a member function fetchAll() on a non-object The call to fetchAll() in this statement: // Does a space between the function name and the argument list in parentheses cause a problem? $query -> fetchAll (PDO::FETCH_ASSOC); is based on $query being an object in the same "scope" as that of the statement. If $query was assigned in the root, or global scope, then you might not be able to see it inside functions. However, I have learned (the hard way) that variables assigned in the global scope can be seen anywhere because PHP makes $GLOBALS['query'] from $query. Just FYI. I also think this can be looked at closer. I am of the opinion DISTINCT is not a SQL function. DISTINCT(shift) as value This will cause problems. PHP comments do not work as comments inside a string. Here is the MySQL comment format. DATE(start) = '2014-05-07' //THIS DATE IS ONLY FOR TESTING And I generally don't like separating the function name from the argument list, although I do not see why PHP would complain: Was: if ( count ($result) == 0 ) die ("No agents found"); Now: if( count($result) == 0 ) die("No agents found");
  25. Actually, you have your PHP fairly well separate from your HTML. This, however: <div class = 'header'> <? if(isset($_SESSION['popo']) && $_SESSION['popo'] == "POPO"): ?> <h2><br> POPO IS GREAT </br></h2> <? else : ?> <h2><br> POPO IS LATE </br></h2> <? endif ; ?> </div> is mixing "data logic" with "display logic". There actually is no display logic required in this example. This variation: <?php session_start(); $_SESSION['popo']="POPO"; if (isset($_SESSION['popo']) && $_SESSION['popo'] == "POPO") {$message = "POPO IS GREAT";} else {$message = "POPO IS LATE";} ?> <!-- snipped --> <div class = 'header'> <h2><?= $message ?></h2> </div> <!-- snipped --> (The PHP is condensed. Refer to post #3.) All the data gathering and preparation logic is performed in the PHP area. All the presentation logic (loops to build selectors, etc) is in the HTML area.
×
×
  • 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.