-
Posts
16,734 -
Joined
-
Last visited
-
Days Won
9
Everything posted by PFMaBiSmAd
-
SELECT COUNT(*) as cnt FROM $table GROUP BY value
-
Doing the conversion in the query is at least 8x faster than doing it using php code. Kind of important if you have a lot of data being retrieved or you need your site to to handle a large number of visitors.
-
Is the From: address being used an email address hosted at the sending mail server or is it the email address that the visitor supplied? Does the sending mail server have an SPF DNS record set up?
-
Session Data is Not Being Carried to 3rd Page
PFMaBiSmAd replied to OldWest's topic in PHP Coding Help
Php code is executed when the page is requested. onclick="<?php session_destroy(); ?>" is meaningless because the php code was executed when the page was requested and output by the server. There is nothing in the javascript onclick event code (take a look at the 'view source' of the page in your browser.) -
The only thing that code does (did you read it?) would be to report and display any php detected errors. If it suddenly started working, you likely had an existing session id cookie set with values that did not work and you likely completely closed your browser so that you got a new session id cookie with the setting that does work.
-
You should be dynamically building the <option></option> list using php code in a loop so that the current value IS in a variable and you can easily output the selected="selected" when it needs to be.
-
Add the following three lines of code to both files, starting on the next line after your first opening <?php tag - ini_set("display_startup_errors", "1"); ini_set("display_errors", "1"); error_reporting(E_ALL);
-
The error message means that your query failed due to an error and returned a FALSE value. If you echo mysql_error(); it will tell you why the query failed.
-
Getting a datatype from a form submission (one user input only)
PFMaBiSmAd replied to j.smith1981's topic in PHP Coding Help
By definition (it's mentioned somewhere in the php.net documentation) all $_GET, $_POST, and $_COOKIE variables are string data types, no matter what they contain. You should instead be more concerned with the value in the variable, than the type of the variable. See the is_numeric function to determine if the value in a variable is numeric. -
You would use the domain name only, because you want the setting to match all variations of the domain name - ini_set('session.cookie_domain', '.maindomain.co.uk');
-
You can only set php settings in a .htaccess file when php is running as an Apache Module AND your web host has permitted settings to be changed in a .htaccess file. You can only set php settings in a local php.ini when php is running as a CGI application AND your web host has configured your server to cause php to use a local php.ini (some server configurations require a local php.ini in each folder that you want the settings to affect.) If both of those methods are not available, you can always set the session.cookie_domain setting in your script (before every session_start() statement), using either session_set_cookie_params or ini_set
-
Is the subdomain hosted on the same server as the domain? Have you set the session.cookie_domain setting so that it matches all variations of your domain name?
-
You would add a conditional statement to test the INFORMATIONTYPE element of the array - if($this->current['INFORMATIONTYPE'] == 'Fast'){ // process the data as needed... }
-
<?php // use OOP so that the call-back fucntions can share values // The real advantage of the xml_parser is that it parses the file line by line. This does however require that you "remember" // the current tag if you are not directly outputing content in order to associate the correct data with it class xml_class { private $parser; // instance of the xml_parser private $current = array(); // current set of values private $tag; // current tag function __construct(){ $this->parser = xml_parser_create(); xml_set_element_handler($this->parser, array('xml_class', 'start'),array('xml_class', 'stop')); xml_set_character_data_handler($this->parser, array('xml_class', 'char')); } function doit($file){ $fp=fopen($file,"r"); while ($data=fread($fp,4096)){ xml_parse($this->parser,$data,feof($fp)) or die (sprintf("XML Error: %s at line %d",xml_error_string(xml_get_error_code($this->parser)),xml_get_current_line_number($this->parser))); } xml_parser_free($this->parser); } function start($parser, $element_name, $element_attrs){ //echo 's' . $element_name . 's'; $this->tag = $element_name; // remember the current tag switch($element_name){ case "RED": // this is the start of a set of data $this->current = array(); // create an empty set break; default: } } function stop($parser, $element_name){ //echo 'e' . $element_name . 'e'; switch($element_name){ case "RED": // this is the tag that is after the end of the stated set of data, complete and execute the query here - // code to build the whole query statement and your mysql_query() goes here ... print_r($this->current); // contains the values for [TRIP], [PLATFORM], and [iNFORMATIONTYPE] echo "<br />"; break; default: } } function char($parser,$data){ $data = trim($data); if($data != ''){ $this->current[$this->tag] = $data; // echo "Tag: {$this->tag}, Value: $data<br />"; } } } // end of class $file = 'vehicle.xml'; $xml = new xml_class(); $xml->doit($file); ?>
-
Because the three call-back functions - startTag, endTag, and contents are completely independent and the xml_parser_ does not provide any way to communicate the current state between the functions, it is better if you wrap your code with an OOP/Class so that you can use class variables to communicate the current state between the functions. Once you do this, you can set a flag(s) when you detect the correct startTag value(s) so that you only process the data that matches the tag(s) you are looking for.
-
help with making string from <OPTION> values
PFMaBiSmAd replied to seany123's topic in PHP Coding Help
Your code probably has an error in it somewhere. -
help with making string from <OPTION> values
PFMaBiSmAd replied to seany123's topic in PHP Coding Help
You likely have a non-printing character stored as part of your data AND you would generally test a value in the query rather than actually retrieving the data and comparing it using some slow parsed, tokenized, interpreted php code. Your code will execute at least 10x faster. Since you do have the values in php variables, use var_dump() on both of them to see what they actually contain. -
help with making string from <OPTION> values
PFMaBiSmAd replied to seany123's topic in PHP Coding Help
^^^ How do you know that? And your code can be greatly simplified - $string = $n1 . $n2 . $n3 . $n4; -
Cannot help with errors without seeing the code that produces the error and the error.
-
http://us2.php.net/manual/en/function.natcasesort.php
-
A) Your code has absolutely no error checking and error reporting logic in it to check if the upload worked before accessing any of the uploaded file information. B) $HTTP_POST_FILES was depreciated a really long time ago (php 4.1, Dec. 2001), turned off by default in php5, and to be removed in the next major php revision. The code should be using $_FILES instead of $HTTP_POST_FILES C) I recommend that you read the upload handling section of the php.net documentation before spending any more of your time on that code.
-
The problem is a missing semi-colon ; on the line above where the error is being reported. When you leave out some php syntax, the language parser does not know what you intended (the following line could have been a continuation of the line that is missing the closing and can only report when it does find something that does not belong in the current context. Also, don't put @'s in your code (ever.) All they do is hide errors. Your code still won't work AND you won't get any errors to help you find where the problem is at in your code.
-
Adding a textbox field at runtime in PHP
PFMaBiSmAd replied to theITvideos's topic in PHP Coding Help
Then in the code example I posted you would use $_POST['id-memberName-box'] as the array where the data values would be. -
Cannot connect to database thru my admin_common.php file.
PFMaBiSmAd replied to KDM's topic in PHP Coding Help
I'm going to guess that mysql is not your database server's host name (that's an incomplete host name at a minimum.) Perhaps if you referred to your new web host's documentation - http://community.godaddy.com/help/article/39