Jump to content

tryingtolearn

Members
  • Posts

    293
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by tryingtolearn

  1. I have the following result that I am getting from a source. SimpleXMLElement Object ( [CategoryID] => 1 [Name] => Other [Order] => 0 [link] => http://www.link.com?sub=1 ) SimpleXMLElement Object ( [CategoryID] => 1233916011 [Name] => ceramic [Order] => 1 [ChildCategory] => SimpleXMLElement Object ( [CategoryID] => 1234016011 [Name] => dish [Order] => 1 ) [link] => http://www.link.com?sub=13476 ) SimpleXMLElement Object ( [CategoryID] => 1233917011 [Name] => laminate [Order] => 2 [link] => http://www.link.com?sub=98247 ) I need to get it into a database with the following structure id categoryID cName cOrder clink cparent By using foreach($this->resp->Store->CustomCategories->CustomCategory as $cat) { $sub = $cat->CategoryID; $ord = $cat->Order; $linkto = "$stlink?fsub=$fsub"; $nm = htmlspecialchars($cat->Name); $par=$cat->ChildCategory->Order; $query = "INSERT INTO Cat (categoryID,cName,cOrder,clink,cparent) VALUES ('$sub','$nm','$ord','$linkto','$par')"; $result = @mysql_query ($query); // Run the query. } I can get id categoryID cName cOrder clink cparent 1 1 Other 0 http://www.link.com?sub=1 0 2 1233916011 ceramic 1 http://www.link.com?sub=13476 0 2 1233917011 laminate 2 http://www.link.com?sub=98247 0 But I need to get the ChildCategory in there w/ cparent like id categoryID cName cOrder clink cparent 1 1 Other 0 http://www.link.com?sub=1 0 2 1233916011 ceramic 1 http://www.link.com?sub=13476 0 3 1234016011 dish 1 1 <--- like this 4 1233917011 laminate 2 http://www.link.com?sub=98247 0 any help appreciated...
  2. have you looked at str_word_count http://php.net/manual/en/function.str-word-count.php
  3. Found a different way.
  4. Hi all, I have a form that is populating select boxes dependamt on what is selected in the box before it. It is all working fine. I have to replace a function in it though to remove a replace function and Im not sure exactly how to do it. This is the code working fine <script type="text/javascript"> var categories = []; categories["startList"] = ["1","2","3"] categories["1"] = ["a", "aa", "aaa"]; categories["2"] = ["b", "bb"]; categories["3"] = ["c", "cc", "ccc", "cccc", "ccccc"]; categories["a"] = ["1a", "2a"]; categories["aa"] = ["3a", "4a"]; categories["aaa"] = ["5a", "6a"]; categories["b" Intel"] = []; categories["bb"] = ["8a"]; categories["c"] = ["9a", "10a"]; categories["cc"] = ["11a"]; categories["ccc"] =[]; categories["cccc"] = ["12a", "13a", "14a", "15a"]; categories["ccccc"] = ["16a", "17a", "18a", "19a"]; var nLists = 3; function fillSelect(currCat,currList){ var step = Number(currList.name.replace(/\D/g,"")); for (i=step; i<nLists+1; i++) { document.forms[0]['List'+i].length = 1; document.forms[0]['List'+i].selectedIndex = 0; } var nCat = categories[currCat]; for (each in nCat) { var nOption = document.createElement('option'); var nData = document.createTextNode(nCat[each]); nOption.setAttribute('value',nCat[each]); nOption.appendChild(nData); currList.appendChild(nOption); } } function init(){ fillSelect('startList',document.forms[0]['List1']) } onload=init; function fabString(){ document.getElementById('fabStringDrop').value = document.getElementById('List1').value+' '+document.getElementById('List2').value+' '+document.getElementById('List3').value return true; } </script> <form name="Search" method="GET" action="#" target="_blank" onsubmit="return fabString()"> <input type="hidden" name="_nkw" id="fabStringDrop" value=""> <select name='List1' onchange="fillSelect(this.value,this.form['List2'])"> <option selected>Make a selection</option> </select> <br /><br /> <select name='List2' onchange="fillSelect(this.value,this.form['List3'])"> <option selected>Make a selection</option> </select> <br /><br /> <select name='List3'> <option selected >Make a selection</option> </select><br /><br /> <input type="submit" value="Search"> </form> This is the part I need to replace var step = Number(currList.name.replace(/\D/g,"")); for (i=step; i<nLists+1; i++) { document.forms[0]['List'+i].length = 1; document.forms[0]['List'+i].selectedIndex = 0; } I cannot use the replace part how I need to use this. How can I code that directly in the script to reset each of the form fields if the option selected changes? I hope that makes sense.
  5. Just a stab but if it works pasted directly in page located in the root dir but doesnt when its in the includes but both times your are calling api.php then that tells me that api.php is in the root dir not the includes dir. Wouldnt you need to change that path?
  6. Oh I get you now http://dictionary.reference.com/browse/jokes
  7. What do you mean by ALL PHP's??
  8. This particular one isnt html But there are plenty of applications that I do use them. No better way to boost sales than a few product pictures w/ links right to the item to buy it. Never underestimate the impulse shoppers
  9. Cags, I appreciate you taking the time on this thread. Its a broad topic and when I hear something I start to question things so I just wanted to be sure what I was thinking made sense. Thanks for the time and input.
  10. I guess thats the skinny of my question. So if you have a set up like this ... if (preg_match('/^[[:alnum:]][a-z0-9_\.\-]*@[a-z0-9\.\-]+\.[a-z]{2,4}$/i', trim(htmlentities(stripslashes($_POST['email']))))) { $e = strip_tags($_POST['email']); } else { $e = FALSE; echo '<p class="error">Please enter a valid email address!</p>'; } ... $message = "NAME-$fn $ln \r\n"; $message .= "EMAIL - $e \r\n"; $message .= "STATE/ZIPCODE - $st $zc \r\n"; $message .= "DESCRIPTION - $sanscript"; mail('[email protected], 'mySubject', $message) is it vulnerable through the $ message var? Sorry if Im seeming a bit dense on this but I guess Im not seeing how this is a vulnerability but I have been told that it is.
  11. Thanks for the response, Im just passing the variables in the body of the email to get the info. htmlentities - OK I was just thinking to get rid of it alltogether but... So would it be better to remove instances of \r \n?
  12. Im trying to figure out if my bases are covered Here is the scenario: There is an html form on 1 site that points to a processing form on another site. It has name, and email text fields and a comments text box passed via POST. The processing form takes each of the variables passed to it like this trim(strip_tags(stripslashes($_POST['var']))) the mail script has the to address hardcoded into it. Is it still vunerable to header injection? I guess Im trying to grasp how the info is going to get from the form to the header in this manner. Thanks for any input.
  13. Hmmmm well it seems changing $mime->addAttachment ($file, $content_type, $file_name, 1); to $mime->addAttachment ($file, $content_type); solves it but no idea why
  14. Hi all, Cant seem to figure where Im going wrong. I have a form that writes the input to a .csv file That works. Then I wanted the form with the data to be sent to an email address as an attachment. The problem is the data in the .csv is overwritten by the file name ($file) so instead of the .csv being filled w/ the form data - A1 simply has the name of the .csv file instead) Any ideas? [Things I already tried - Not having the file name - didnt send an attachment Changing the content type between application/vnd.ms-excel and text/csv - no difference - got the file name both times] $classmail=array(''.$posted.','.$site.''); $fp = fopen('file.csv', 'a+'); foreach ($classmail as $line) { fputcsv($fp, explode(",", $line)); } fclose($fp); //construct eMail include('Mail.php'); include('Mail/mime.php'); $sender = "classMail Info <[email protected]>"; $recipient = "JOE <[email protected]>"; $subject = "classMail Spreadsheet"; $text = 'Here is your updated classMail spreadsheet.'; $html = '<html><body><p><b>Here is your updated classMail spreadsheet.</b></p></body></html>'; $crlf = "\n"; $headers = array( 'From' => $sender, 'Return-Path' => $sender, 'Subject' => $subject ); // Creating the Mime message $mime = new Mail_mime($crlf); // Setting the body of the email $mime->setTXTBody($text); $mime->setHTMLBody($html); // Add an attachment $file = "file.csv"; $file_name = "file.csv"; $content_type = "application/vnd.ms-excel"; $mime->addAttachment ($file, $content_type, $file_name, 1); $body = $mime->get(); $headers = $mime->headers($headers); // Sending the email $mail =& Mail::factory('mail'); $mail->send($recipient, $headers, $body);
  15. Thanks - google was my friend with getting this hahaha Appreciate you taking a look. It just got confusing w/ all the math I guess...
  16. Hi all, can someone tell me if I am going about this the correct way (Or if there is a better way to do it) I need to get the difference between the time now and the timestamp of a MYSQL timestamp table. so it reads - 3 days 23 hours 14 minutes 32 seconds (For example) I think Its correct but for some reason it is really confusing me and just wondering if I should be doing it different. //current time $date1 = time(); //$exp is a mySQL timestamp field $date2 = strtotime($exp); $dateDiff = $date2 - $date1; $daysLeft = floor($dateDiff/(60*60*24)); $hoursLeft = floor(($dateDiff-($daysLeft*60*60*24))/(60*60)); $minutesLeft = floor(($dateDiff-($daysLeft*60*60*24)-($hoursLeft*60*60))/60); $secondsLeft = floor(($dateDiff-($daysLeft*60*60*24)-($hoursLeft*60*60)-($minutesLeft*60)));
  17. Sloved by adding to a session. I suppose that works.
  18. I have a class that adds data to an array Then I have a second class and I need to check if the data it returns is in the array created in the first class. But I get undefined variable: Array name Basically the array is empty outside of the first class. Is it possible to use that array between classes?
  19. I need a way to add certain parts of an array to certain parts of a simplexml object The array I have is like this Array ( [0] => ../_designer-shoes_AA00_crtZ4ew_qridZ55690714aa_wowsidZp4634322 [1] => ../_Other_AA00_crtZ1ew_qridZ55690714aa_wowsidZp4634322 ) The simplexml object returned is this SimpleXMLElement Object ( [iD] => 7 [Name] => OTHER [Order] => 0 ) SimpleXMLElement Object ( [iD] => 12 [Name] => designer shoes [Order] => 15 ) SimpleXMLElement Object ( [iD] => 546781 [Name] => OUTSIDE PRODUCTS [Order] => 32 ) So now i need to match up the NAME with the link from the array and if it matches add it to the object to end up with this SimpleXMLElement Object ( [iD] => 7 [Name] => OTHER [Order] => 0 [Path] => ../_Other_AA00_crtZ1ew_qridZ55690714aa_wowsidZp4634322 ) SimpleXMLElement Object ( [iD] => 12 [Name] => designer shoes [Order] => 15 [Path] => ../_designer-shoes_AA00_crtZ4ew_qridZ55690714aa_wowsidZp4634322 ) SimpleXMLElement Object ( [iD] => 546781 [Name] => OUTSIDE PRODUCTS [Order] => 32 [Path] => NO PATH ) Is that something that can be done?
  20. changed $purl = 0; and $aurl = 0 TO $purl="WRONG" $aurl="WRONG" and its working.
  21. Glad it worked, Yes, the html will show. You wont see the php code but you will see the html. The includes are just taking different pages and putting them together where you include them But it wont hide the html
  22. Think its missing the closing bracket, try this </div> <div id="footer">Copyright 2007, Widget Corp</div> </body> </html> <?php // 5. Close connection if (isset($connection)) { mysql_close($connection); } ?>
  23. whats on line 9 of footer.php? The html will show up.
  24. When writing the article and you select the image Can(are) you store the image name in the DB? Then when you go to edit the article it will use that image name but if you want to change it you can just pick a different one and update the name in the DB.
  25. Hmmm tried it but no luck, still 0
×
×
  • 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.