ScotDiddle
Members-
Posts
204 -
Joined
-
Last visited
Never
About ScotDiddle
- Birthday 01/15/1955
Contact Methods
-
Website URL
http://www.webtdo.com
Profile Information
-
Gender
Male
-
Location
Richmond Virginia, United States of America, Earth, Solar System, Galaxy, Known Universe, Unknown Universe
ScotDiddle's Achievements
Member (2/5)
0
Reputation
-
marcus_epik, I would use jQuery AJAX, but here is a "Quick and Dirty" that should work... Scot L. Diddle, Richmond VA <script> parmPassedToPHP = new Image(); function getUsersScreenResolution(incomingVar) { var passedParm = incomingVar; // alert('Hi Mom'); var result; var at = '@'; var tilde = '~'; var param1A = screen.width; var param1B = 'W'; var param2A = screen.height; var param2B = 'H'; var phpVariable = param1A + at + param1B + tilde + param2A + at + param2B; iURL="transferJSParamToPHP.php?variable=" + phpVariable; result = parmPassedToPHP.src=iURL; // alert(result); }; </script> Where : transferJSParamToPHP.php looks like this... <?php $getVariable = $_GET['variable']; // Copy $getVariable to DB... ?>
-
gaggid, Take a look at this class... It writes, then reads (parses) the content of an XML File. http://www.phpclasses.org/browse/file/19181.html Scot L. Diddle, Richmond VA
-
AJAX return to JS variable - Undefined
ScotDiddle replied to Muddy_Funster's topic in Javascript Help
Muddy_Funster, Yeah, but... Don't discount jQuery... Get it here: http://jquery.com/ Then you can turn off / on async functionallity... on: don't wait, off (false) wait... Plus, jQuery takes complex tasks and makes them easy... The following is a sub-set of my own ajax processing scheme... 1.) ajax call: <script type="text/javascript"> // #DMGPOWNER is the id of the select box var DMGPOWNER = jQuery('#DMGPOWNER option:selected').text(); DMGPOWNER = strtoupper(DMGPOWNER); var ClaimantDriver = AJAXTrafficCop('ClaimantDriverYN', DMGPOWNER); var validAJAXResult = checkAJAXResults(ClaimantDriver); var debug = false; if (debug) { alert('ClaimantDriver Ajax Return: ' + "'" + ClaimantDriver + "'"); } if (validAJAXResult) { var propertyType = document.getElementById('DMGPTYPE').selectedIndex; if (propertyType === 1 || propertyType == 2) { // Vehicle OR Other ClaimantDriver = Boolean(ClaimantDriver); if (ClaimantDriver) { // As determined by ajaxTrafficCop.js / .php // alert('Setting up Claimant Driver'); $("#VehicleInfo").show(); $("#ClaimantVehicleType").show(); $("#InsuredVehicleType").hide(); } // END if (ClaimantDriver) { } // END if (propertyType === 1 || propertyType == 2) { // Vehicle OR Other } // END if (validAJAXResult) { /** * * Make sure PHP ('AJAXTrafficCop.php') * * and * * JavaScript ('AJAXTrafficCop.js') played nice... * */ function checkAJAXResults(valueToCheck) { var returningValueToCheck = valueToCheck; suppliedJSParmsAreInvalid = stristr(returningValueToCheck, 'invalid'); // See around line 89 in // 'AJAXTrafficCop.js' if (suppliedJSParmsAreInvalid) { errorText = returningValueToCheck; alert(errorText); return false; } suppliedPHPParmsAreMissing = stristr(returningValueToCheck, 'missing'); // See around line 104 in // 'AJAXTrafficCop.php' suppliedPHPParmsAreInvalid = stristr(returningValueToCheck, 'invalid'); // See around line 109 in // 'AJAXTrafficCop.php' if ( (suppliedPHPParmsAreMissing) || (suppliedPHPParmsAreInvalid) ) { pieces = explode('|', returningValueToCheck); line1 = pieces[0]; line2 = pieces[1]; errorMessage = line1 + line2; alert(errorMessage); return false; } return true; } // END function checkAJAXResults(valueToCheck) { </script> 2.) AJAXTrafficCop.js function AJAXTrafficCop(jurisdiction, citation) { if ( typeof(citation) != 'undefined') { var directive = null; } var trafficCop = jurisdiction; var directive = citation; var complexID = stristr(trafficCop, '_'); // Multiple ID's for the same task var debug = false; if (debug) { alert('trafficCop : ' + trafficCop); alert('directive : ' + directive); alert('complexID : ' + complexID); } if (complexID) { // Detective work needed pieces = explode('_', trafficCop); trafficCop = pieces[1]; // 'Complete' // alert('TrafficCop : ' + trafficCop); complexSubject = pieces[0]; // 'BasicInfo' // alert('ComplexSubject : ' + complexSubject); } debug = false; if (debug) { // One... // Or the other : // if ( (debug) || (complexID == 'INSVEHZIP') ) { alert('trafficCop : ' + trafficCop); alert('complexSubject : ' + complexSubject); } var asyncParmBoolean = false; // Do you want the callling JS to wait for the AJAX to complete ? // "asyncParmBoolean = false" means to process the request // asyncronously - ie.: wait for AJAX to complete first... var returnAJAXResult = false; // Do you want to "see" (read use) any output from AJAX ? // Even if you produce output, you may not want to intercept... switch(trafficCop) { case 'ClaimantDriverYN' : // Called From checkTrio() in 'Header' segment of // 'AutoDamgProp.phw' around line 668. var asyncParmBoolean = false; var returnAJAXResult = true; // Directive: 'Property Owners Name'. directive = strtoupper(directive); var dataParm = "ClaimantDriverYN=" + directive; var debug = true; if (debug) { alert(dataParm); } break; default : alert('A switch error occurred in \'AJAXTrafficCop.js\' while trying to process \'' + trafficCop + '\' for: \'' + directive + '\'.\n\n\tOne or more of the expected parm values are invalid.\n\n \n (Or : \'ajaxTrafficCop.php\' has a syntax error which prevented it from processing a valid JS request...) \n \n\tThe data generated for this page cannot be trusted !\n\nPlease report this message to the IT Helpdesk !'); return; break; } $.ajax({ type: "GET", url: "/common/include/ajaxTrafficCop.php", data: dataParm, async: asyncParmBoolean, success: function(msg) { /** * * Handle programmer error... * */ if (stristr(msg, 'ajaxTrafficCop.php')) { alert( msg ); return; } else { // Maybe user wants to see the results of the AJAX Call... var render = returnAJAXResult; // If true, and you get back a null msg, check // trafficCop.php for $display = false or // make sure the item of interest is echo'ing // somthing... if (render) { debug = false; if (debug) { // Change this bad boy to something of interest... if (trafficCop == 'DOMToCheckZipFor') { alert(msg); } } result = msg; } } } // END success: function(msg) { }); // END $.ajax({ if (returnAJAXResult) { if ( typeof(result) != 'undefined') { return result; // Generally used when a JS call to AJAX needs the results of the // call at a later time. ( Also needs 'asyncParmBoolean = false;' ) } else { // We don't return a value, because this message should only be generated // when we were expecting 'AJAXTrafficCop.php' to return some value(s), but didn't. alert('An error occurred in \'AJAXTrafficCop.js\' while trying to process \'' + trafficCop + '\' for: \'' + directive + '\'.\n\n\tThe expected return value was not genrated in \'AJAXTrafficCop.php\'\n\n(Or : there is a syntax error in \'AJAXTrafficCop.php\' which prevented valid JS parms to be processed.)\n\n\tThe generated data on this page cannot be trusted !\n\nPlease report this message to the IT Helpdesk !'); } } // END if (returnAJAXResult) { } // END function AJAXTrafficCop(id, status) { 3.) ajaxTrafficCop.php <?php // Set no caching header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); set_time_limit(0); session_start(); $debug = false; if ($debug) { error_reporting(E_ALL); ini_set('display_errors', 'on'); } $incomingGetParm = $_GET; $debug = FALSE; if ($debug) { $parm = $incomingGetParm; echo "<pre><h3 style=\"color: red;\"> \n"; var_dump($parm); echo "</pre></h3> \n"; } foreach ($incomingGetParm as $getIDX => $gottenItem) { $switchCriteria = $getIDX; $getParmValue = $gottenItem; } $debug = FALSE; if ($debug) { if ($switchCriteria == 'ownedNonowned') { // Change as needed for debug processing... echo "Debug report from ajaxTrafficCop.php with built-in exit. /* --> \$switchCriteria --> " . $switchCriteria . "<-- :: \$getParmValue --> " . $getParmValue . " <-- */ \n"; exit; } } // echo " !!! \$switchCriteria : $switchCriteria !!! \n"; switch($switchCriteria) { case 'ClaimantDriverYN' : // Called from around line 668 in the "Header" segment of // 'AutoDmgProp.phw' /** * * In AutoDmgProp.php, we have to determine whether or not we are dealing * * with an 'Insured Driver' or a 'Claimant Driver' to decide whether or * * not to allow "Same As Owner's" check-box. * */ $nameToCheck = strtoupper($getParmValue); $claimantDriver = stristr($nameToCheck, 'CLAIMANT DRIVER'); if ($claimantDriver) { echo true; } else { echo false; } break; default : if ( ($switchCriteria == null) || ($switchCriteria == '') || (!isset($switchCriteria)) ) { $switchCriteria = '!! MISSING !!'; $missingCriteria = true; } if ($missingCriteria) { echo " AJAX \$switchCriteria parm (\"$switchCriteria\") missing in program: 'ajaxTrafficCop.php'. \n \n"; } else { echo " AJAX \$switchCriteria parm (\"$switchCriteria\") is invalid in program: 'ajaxTrafficCop.php'. \n \n"; } echo "(Check the parms passed to AJAXTrafficCop JS and the switch setting in same.) \n\n"; echo " Please report this message to the IT Help Desk... "; echo "\n"; break; } // switch($switchCriteria) { ?> Scot L. Diddle, Richmond VA -
Ieszer, Your extra php delimiters are getting in the way. My IDE shows a syntax error... I'm surprised it ran at all... Try: $message = include("another.php"); echo $message; Scot L. Diddle, Richmond VA
-
searls03, Will this work for you ? session_start(); // Must start session first thing /* Created By Adam Khoury @ www.flashbuilding.com -----------------------June 20, 2008----------------------- */ // Here we run a login check if (!isset($_SESSION['complete'])) { echo 'Please <a href="/login.php">log in</a> to access your account'; exit(); } else { // Place Session variable 'id' into local variable require_once "connect.php"; $sql = mysql_query("SELECT * FROM cart"); while($row = mysql_fetch_array($sql)){ $cid = $row["cart_id"]; $academy = $row["academy"]; $complete = "".$cid."".$academy.""; $_SESSION['complete'] = $complete; $_SESSION['cart_id'] = $cid; $_SESSION['academy'] = $academy; } } //Connect to the database through our include require_once "connect.php";// Place Session variable 'id' into local variable $academy = $_SESSION['academy']; $sql = mysql_query("SELECT * FROM cart"); while($row = mysql_fetch_array($sql)){ $cid = $row["cart_id"]; $_SESSION['cart_id'] = $cid; } echo $cid; echo "<br />"; echo $academy; ?> I changed 'include_once' to 'require_once' so the prcess will die if your SQL credentials are not found. Scot L. Diddle, Richmond VA
-
Bazzaah, I don't use MySQL, I'm a DB2 guy, but take a look a this link: http://www.tizag.com/mysqlTutorial/mysqlfetcharray.php (I only used an array because I did not have access to your table, nor did I have the time or inclination to build one in DB2) Scot L. Diddle, Richmond VA
-
Bazzaah, Good morning... First off, when you run your script and view source, you get: <table width="800px" class="center" border="1"><td><tr><td><a href="word.php?w="></a></td><td><a href="word.php?w="></a></td><td><a href="word.php?w="></a></td></tr><tr><td><a href="word.php?w="></a></td><td><a href="word.php?w="></a></td><td><a href="word.php?w="></a></td></tr><tr><td><a href="word.php?w="></a></td><td><a href="word.php?w="></a></td><td><a href="word.php?w="></a></td></tr><tr><td><a href="word.php?w="></a></td><td> </td><td> </td></tr></table> Kind of hard to debug... Adding some Source control new line characters , we get: <table width="800px" class="center" border="1"> <td><tr> <td><a href="word.php?w="></a></td> <td><a href="word.php?w="></a></td> <td><a href="word.php?w="></a></td> </tr> <tr> <td><a href="word.php?w="></a></td> <td><a href="word.php?w="></a></td> <td><a href="word.php?w="></a></td> </tr> <tr> <td><a href="word.php?w="></a></td> <td><a href="word.php?w="></a></td> <td><a href="word.php?w="></a></td> </tr> <tr> <td><a href="word.php?w="></a></td> <td> </td> <td> </td> </tr> </table> Right away, we can now see that we have a leading <td> which should not be there. Here is the result of my altered script: <table width="800px" class="center" border="1"> <tr> <td><a href="word.php?w=1">1</a></td> <td><a href="word.php?w=2">2</a></td> <td><a href="word.php?w=3">3</a></td> </tr> <tr> <td><a href="word.php?w=4">4</a></td> <td><a href="word.php?w=5">5</a></td> <td><a href="word.php?w=6">6</a></td> </tr> <tr> <td><a href="word.php?w=7">7</a></td> <td><a href="word.php?w=8">8</a></td> <td><a href="word.php?w=9">9</a></td> </tr> <tr> <td><a href="word.php?w=10">10</a></td> <td> </td> <td> </td> </tr> </table> A note about the new line character ( and tab character ), they don't work hidden behind '', only if imbedded in : "". You code has a mix of single quotes and double quotes for holding your string content... for any html you want to parrot out, always use double quotes and the new line character... Here is my altered code: <?php // Program Name: test.php // Program Title: // Created by: // Template family: // Template name: // Purpose: // Program Modifications: // Set no caching header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); set_time_limit(0); session_start(); echo '<table width="800px" class="center" border="1">' . "\n"; $i = 0; $max_columns = 3; $myArray = array(1,2,3,4,5,6,7,8,9,10); // while ($list = mysql_fetch_array($result)) { while (!empty($myArray)) { // make the variables easy to deal with $list['word'] = array_shift($myArray); // open row if counter is zero if($i == 0) echo "<tr> \n"; /** * * * Bad coding technique ( Works, just hard do follow... ( your indent is wrong. ) ) * * Better to always use: * * if ($someVar = $someVal) { * doSomething(); * } * * even for one-line directive for true "if" * * */ echo '<td><a href="word.php?w=' . $list['word'] . '">' . $list['word'] . "</a></td> \n "; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr> \n"; $i=0; } // END if(++$i == $max_columns) { } // END while (!empty($myArray)) { // } END while ($list = mysql_fetch_array($result)) { // clean up table - makes your code valid! if($i < $max_columns) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td> \n"; /** * * * Bad coding technique ( Works, just hard do follow... ) * * Better to always use: * * for($j=$i; $j<$max_columns;$j++) { * doSomething(); * } * * even for one-line directive for true "for" * * */ } // END if($i < $max_columns) { echo '</tr>' . "\n"; echo '</table>' . "\n"; ?>
-
PHP - Register User Before Downloading File
ScotDiddle replied to johnny_v's topic in PHP Coding Help
johnny_v, If you don't store the user-supplied credentials (user name / PW) in a DB (like MySQL or DB2 or some such) then why have them enter it. Session variables: $_SESSION['UserID'] = $POST['userid'] and $_SESSION['Password'] = $_POST['password'] don't do you much good for subsequent visits by the same user on some other date... $_SESSION var are only good until the user closes his browser. You should ask for User Name and PW, AND write them to your DB Users_table (make up your own name here...) Then, on later visits, when the user logs in again, query the DB to see whether or not he has registered before... If he has, extract the variables from the DB and assign the DB Row values to $_SESSION['UserID'] = $sqlResult['userid'] and $_SESSION['Password'] = $sqlResult[password] . If he is a new user, store the info in the DB. Scot L. Diddle, Richmond VA -
Pikachu2000, Thanks for the suggestion, howerver that was not the issue. I found the solution here: http://stackoverflow.com/questions/4898752/css-style-differs-in-localhost-vs-machine-name "I too had the same issue. This is due to the compatibility issue in ie8. go to tools->compatibility View Settings uncheck "Display intranet sites in Compatibility view." Ya gotta love Google. Scot L. Diddle, Richmond VA
-
Hi Folks, When I get index.php with 10.x.x.x, the CSS behaves correctly. If I pull up the same page using an internal domain name Vis.: 'somename.somecompany.com'. the CSS is skewed. Any ideas what might cause this... ( by "skewed" I mean the font is bigger and superfluous space appears between the Tabs at the top and Tab content. Any help will be appricated. Thanks , Scot L. Diddle, Richmond VA
-
function doesnt work on explorer but work on other browsers why?
ScotDiddle replied to Lisa23's topic in Javascript Help
Lisa23, I tested on IE 8 and all seems fine here also. Scot L. Diddle, Richmond VA -
esoteric, What is failing ? Did you try something like this: On the logon page, : $_SESSION['who'] = $_POST['who']; $_SESSION['ID'] = $_POST['ID']; Then, later, to store values in a DB: $who = $_SESSION['who']; $ID = $_SESSION['ID']; ScotL. Diddle, Richmond VA
-
Trouble creating a single string out of a mysql result set
ScotDiddle replied to drayarms's topic in PHP Coding Help
drayarms, You could try something similar to the following... Scot L. Diddle, Richmond VA <?php /** * * Simulate multiple SQL queries * */ $array1 = array('red', 'white', 'blue'); $array2 = array('yellow', 'orange', 'purple'); $array3 = array('pink', 'plum', 'violet'); $array = array($array1, $array2, $array3); foreach ($array as $arrayOfColors) { // Simulate SQL Query results $stringOut = ''; foreach ($arrayOfColors as $colors) { $stringOut .= "'" . $colors . "', "; } $strLength = strlen($stringOut); $last = $strLength - 2; $cols = substr($stringOut,0, $last); echo $cols . '<br />'; } /** * * Output: * */ // 'red', 'white', 'blue' // 'yellow', 'orange', 'purple' // 'pink', 'plum', 'violet' ?> -
infrabyte, Your $_GET parm is empty because you are submitting your form with post method. If you "got" your mobile parm from another page with method="GET" you can save the variable for later use by learning and implementing $_SESSION variables. ( In a nut shell, at the top of each script enter: session_start(); Then, once your $_GET['mobile'] parm is set to $mobile, do: $_SESSION['mobile'] = $mobile; Later when you want this value on another page, start the page with session_start(); then code: $mobile = $_SESSION['mobile'] and you should be good to go. ) Scot L. Diddle, Richmond VA
-
hoponhiggo, This is a perfect example of where AJAX will come in handy. I recommend the JQuery AJAX interface (http://api.jquery.com/jQuery.ajax/) Scot L. Diddle, Richmond VA