
Dan06
Members-
Posts
103 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
Dan06's Achievements

Member (2/5)
0
Reputation
-
Thanks for the help. I followed your suggestions and got the code to work. Best, Dan
-
The following code is supposed to return a variable containing text, currently the code posts the data but returns an "undefined" variable. Can someone tell me what's wrong? Thanks. function ajaxPost(params, url){ var XMLHttpRequestObj = false; if (window.XMLHttpRequest){ XMLHttpRequestObj = new XMLHttpRequest(); } else if (window.ActiveXObject){ XMLHttpRequestObj = new ActiveXObject("Microsoft.XMLHttp"); } if (XMLHttpRequestObj){ XMLHttpRequestObj.open("POST", url, true); XMLHttpRequestObj.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); XMLHttpRequestObj.setRequestHeader("Content-length", params.length); XMLHttpRequestObj.setRequestHeader("Connection", "close"); XMLHttpRequestObj.onreadystatechange = function(){ if (XMLHttpRequestObj.readyState == 4 && XMLHttpRequestObj.status == 200){ var requestResponse = XMLHttpRequestObj.responseText; delete XMLHttpRequestObj; return (requestResponse); } } XMLHttpRequestObj.send(params); } }
-
Uploading multiple files - request entity or php issue?
Dan06 replied to Dan06's topic in PHP Coding Help
Thanks for the suggestion; I tried it but it didn't solve the problem. To figure out the problem, I printed the array, below is the result: Based on the above, my guess is the problem is the request entity. Anyone have anymore suggestions? -
I'm having trouble uploading multiple files at the same time. For example, if I send two files at the same time, the first file is uploaded but the second is seemingly ignored. I don't know if the problem is with the request entity or the php code. Does anyone know which is the problem? Thanks. Below is the "Request Entity" that is submitted to the server: --3D6atZKLBPujpCZzClN-wz3AJ0Eh-BBWlRr Content-Disposition: form-data; name="imgFile[]"; filename="Inbox_Msg_Display.GIF" Content-Type: application/octet-stream; charset=ISO-8859-1 Content-Transfer-Encoding: binary --3D6atZKLBPujpCZzClN-wz3AJ0Eh-BBWlRr-- --A2cG-IXHLNC2Rk7kF3fQ5-bQPQpuDwmUU Content-Disposition: form-data; name="imgFile[]"; filename="Table_Msg_Content.GIF" Content-Type: application/octet-stream; charset=ISO-8859-1 Content-Transfer-Encoding: binary --A2cG-IXHLNC2Rk7kF3fQ5-bQPQpuDwmUU-- Following is the code I'm using to process the request entity: for ($i = 0; $i < count($_FILES['imgFile']); $i++){ $targetPath = "profile_images/"; $targetPath = $targetPath . basename($_FILES['imgFile']['name'][$i]); move_uploaded_file($_FILES['imgFile']['tmp_name'][$i], $targetPath); }
-
I'm using a query that selects all records that have a particular recipient and matching ids. I want to refine the select criteria to include one record from each group based on recipient, message id, and latest date. The records are grouped based on "threadId." How can I do this? There are two tables involved: message_inbox and message_content. The message_content table has the following fields: msgId, threadId, msgParent, msgChild, msgDate, msgSubject, msgContent The message_inbox table has the following fields: msgRecipient, msgSender, msgId Here is my current mysql query: $messagesQuery = sprintf("SELECT msgSender, message_content.msgId, msgDate, msgSubject, msgContent FROM utilist.message_inbox, utilist.message_content WHERE msgRecipient = %s AND message_inbox.msgId = message_content.msgId", $format->formatValue($_SESSION["userId"]));
-
The problem seems to be caused because I assigned mysql_fetch_assoc($msgQueryResult) twice. Below is the entire code. I used the do rather than a while loop because when I used a while loop the image query did not work. class messageDetails{ public function displayDetails($msgLinkEnd){ $format = new stringFormat(); $dbconn = new dbConnection(); $msgParentQuery = sprintf("SELECT message_content.msgParent FROM utilist.message_content WHERE message_content.msgId = %s", $format->formatValue($msgLinkEnd)); $parentQueryResult = mysql_query($msgParentQuery, $dbconn->conn()) or die("Parent Message Query Error: " . $msgParentQuery . mysql_error()); $parentId = mysql_fetch_assoc($parentQueryResult); $messageQuery = sprintf("SELECT msgSender, message_content.msgId, message_content.msgParent, msgDate, msgContent FROM utilist.message_outbox, utilist.message_content WHERE message_content.msgId = %s AND message_outbox.msgId = message_content.msgId", $format->formatValue($parentId["msgParent"])); $msgQueryResult = mysql_query($messageQuery, $dbconn->conn()) or die("Outbox Message Query Error: " . $messageQuery . " " . mysql_error()); $msgFields = mysql_fetch_assoc($msgQueryResult); $membershipIdQuery = sprintf("SELECT membershipId FROM utilist.user_information WHERE userId = %s", $format->formatValue($msgFields["msgSender"])); $memIdQueryResult = mysql_query($membershipIdQuery, $dbconn->conn()) or die("Membership Id Query Error: " . $membershipIdQuery . " " . mysql_error()); $membershipIdValue = mysql_fetch_assoc($memIdQueryResult); $profileImgQuery = sprintf("SELECT profileImage FROM utilist.profile WHERE membershipId = %s", $format->formatValue($membershipIdValue["membershipId"])); $profileImgResult = mysql_query($profileImgQuery, $dbconn->conn()) or die("Profile Image Query Error: " . $profileImgQuery . " " . mysql_error()); $profileImgLoc = mysql_fetch_assoc($profileImgResult); while ($msgInfo = mysql_fetch_assoc($msgQueryResult)){ echo '<div class="displayMsg">' . '<img src="' . $profileImgLoc["profileImage"] . '" width="100px" height="100px" />' . ' ' . $msgInfo["msgDate"] . ' ' . '<a href=message_details.php?msgId=' . $msgInfo["msgId"] . '>' . $msgInfo["msgContent"] . '</a>' . '</div>'; } /* if ($msgInfo["msgParent"] != NULL || $msgInfo["msgParent"] != "NULL" || $msgInfo["msgParent"] != ""){ $this->displayDetails($msgInfo["msgId"]); } else{ return true; } */ } // end displayDetails function } // end messageDetails class
-
I have a php object that performs a series of sql queries and displays the results, the object is supposed to call itself if a particular value is not null. Currently, the object works correctly the first time through the code - the correct information is displayed. But when it comes to calling itself something goes wrong. The page displays the following error: Below is the php object code, anyone know where I've gone wrong? Thanks. class messageDetails{ public function displayDetails($msgLinkEnd){ $format = new stringFormat(); $dbconn = new dbConnection(); ... SQL QUERIES ... do{ echo '<div class="displayMsg">' . '<img src="' . $profileImgLoc["profileImage"] . '" width="100px" height="100px" />' . ' ' . $msgInfo["msgDate"] . ' ' . '<a href=message_details.php?msgId=' . $msgInfo["msgId"] . '>' . $msgInfo["msgContent"] . '</a>' . '</div>'; } while ($msgInfo = mysql_fetch_assoc($msgQueryResult)); if ($msgInfo["msgParent"] != NULL || $msgInfo["msgParent"] != "NULL" || $msgInfo["msgParent"] != ""){ $this->displayDetails($msgInfo["msgId"]); } else { return true; } } // end displayDetails function } // end messageDetails class
-
I'd like to create an app that performs multiple file upload. I'm new to java so I'm not sure exactly how to go about accomplishing my goal. Is it best to create an app and then use web start? Or is there another, possibly better way? Does anyone know of any tutorials, books, etc. that have examples or cover upload applications? Thanks
-
Thanks, changing = to IS resolved the issue.
-
I used parentheses as shown below: SELECT msgSender, message_content.msgId, msgDate, msgContent FROM utility.message_inbox, utility.message_content WHERE msgRecipient = "o4jd9sk1" AND (message_inbox.msgId = message_content.msgId AND message_content.msgChild = "NULL") but an empty result set was returned. It seems that the cause of the problem is the: AND message_content.msgChild = "NULL" statement. When I changed the aforementioned statement to: AND message_content.msgId = "1" the result set showed the expected content. Currently, the msgChild field is by default set to NULL, it's supposed to indicate that the current message is the last one in the thread since it has no children. Is the error in my statement or elsewhere?
-
How can I have a mysql query with 3 (or more) Where clauses (I know Where only takes 2). The following code doesn't work, but it demonstrates what I'd like to achieve: SELECT msgSender, message_content.msgId, msgDate, msgContent FROM utility.message_inbox, utility.message_content WHERE msgRecipient = "o4jd9sk1" AND message_inbox.msgId = message_content.msgId AND message_content.msgChild = "NULL"
-
Thanks for the clarification... I was confused because I incorrectly thought that each time the $msgInfo = mysql_fetch_assoc($msgQueryResult) code is called it automatically starts from the beginning, i.e. the first array set.
-
In my php page, in the head section I perform a few mysql queries. I then use these queries to display page content in the body. I don't understand why, but when I use a while loop only the latest/last set of queried information is displayed. However, when I use a Do while loop all the queried information is displayed. Can someone help me understand what is going on? Here is my code: <html> <head> <?php include("objects.php"); $dropmenu = new dropmenuDisplay(); $format = new stringFormat(); $dbconn = new dbConnection(); session_start(); $messagesQuery = sprintf("SELECT msgSender, message_content.msgId, msgDate, msgContent FROM utility.message_inbox, utility.message_content WHERE msgRecipient = %s AND message_inbox.msgId = message_content.msgId", $format->formatValue($_SESSION["userId"])); $msgQueryResult = mysql_query($messagesQuery, $dbconn->conn()) or die("Inbox Message Query Error: " . $messagesQuery . " " . mysql_error()); $msgInfo = mysql_fetch_assoc($msgQueryResult); $membershipIdQuery = sprintf("SELECT membershipId FROM utility.user_information WHERE userId = %s", $format->formatValue($msgInfo["msgSender"])); $memIdQueryResult = mysql_query($membershipIdQuery, $dbconn->conn()) or die("Membership Id Query Error: " . $membershipIdQuery . " " . mysql_error()); $membershipIdValue = mysql_fetch_assoc($memIdQueryResult); $profileImgQuery = sprintf("SELECT profileImage FROM utility.profile WHERE membershipId = %s", $format->formatValue($membershipIdValue["membershipId"])); $profileImgResult = mysql_query($profileImgQuery, $dbconn->conn()) or die("Profile Image Query Error: " . $profileImgQuery . " " . mysql_error()); $profileImgLoc = mysql_fetch_assoc($profileImgResult); ?> </head> <body> <?php while ($msgInfo = mysql_fetch_assoc($msgQueryResult)){ echo '<div class="displayMsg">' . '<img src="' . $profileImgLoc["profileImage"] . '" width="100px" height="100px" />' . ' ' . $msgInfo["msgDate"] . ' ' . $msgInfo["msgContent"] . '</div>'; } ?> </body> </html>
-
There were 2 problems: 1. var p = null; was inside the callback function, it needed to be outside of the function 2. The word suggestion in document.getElementById("suggestionBox")... was misspelled. Once the above two errors were fixed the code works fine.
-
I've made some progress with the code, but I'm having trouble with two aspects. 1. The following code is an ajax callback function, which inserts the responseText into the markup and binds an anonymous function to onkeypress. When the user presses the up or down arrows the current li position should be stored in variable p and adjusted based on the number of times up or down is pressed. The idea was that every time a new suggestion list is created/displayed the value of p would be returned to null. However, in my code, the code always returns the value of variable p to be 1 if up is pressed and 0 if down is pressed. function suggestionCallback(ajaxResponse){ if (!ajaxResponse.match(/Error/i) && ajaxResponse != ""){ $("#suggestionBox").show(); var suggestionList = document.getElementById("suggestionList"); suggestionList.innerHTML = ajaxResponse; var inputBox = document.getElementById("msgRecipient"); var li = suggestionList.getElementsByTagName("li"); var p = null; inputBox.onkeypress = function(e){ // If [TAB] or [ENTER] keys are pressed if ( e.keyCode == 9 || e.keyCode == 13 ){ } else if ( e.keyCode == 38 ){ // If the up key is pressed, select the previouse user or the last user if at the beginning p = (p == null) ? li.length-1 : p-1; if (p < 0){ p = li.length-1; } alert("p: " + p); updatePos( li[p] ); } else if ( e.keyCode == 40 ){ // if the down key is pressed, select the next user or the first user if at the end p = (p == null) ? 0 : p+1; if (p > li.length-1){ p = 0; } alert("p: " + p); updatePos( li[p] ); } }; // end binding of function to input.onkeypress } else { alert(ajaxResponse); } } // end suggestionCallback 2. The following combination of functions is supposed to remove a class from an li position and add a class to another li position depending on the value of variable p. Seemingly the problem is that the value of p and its resulting li[p] value is not being recognized in the functions that are supposed to perform the addition/removal of classes. Below is the code: function addClass( target, theClass ){ target.setAttribute("class", theClass); } function removeClass( target, theClass ){ target.setAttribute("class", ""); } // Change the highlight of the user that's currently selected function updatePos( elem ) { // Update the position to the currently selected element var elementPos = elem; // Get all the user li elements var li = document.getElementById("suggestonBox").getElementsByTagName("li"); // Remove the 'cur' class from the currently selected one for ( var i = 0; i < li.length; i++ ){ removeClass( li[i], "suggestionLight" ); } // And add the highlight to the current user item addClass( elementPos, "suggestionLight" ); } Help appreciated.