Jump to content

Chezshire

Members
  • Posts

    283
  • Joined

  • Last visited

Everything posted by Chezshire

  1. My friend JD helped slipped me a solution that works nicely. slight refactoring $filter = filter_input_array(INPUT_POST, [ 'postType' => [ 'filter' => FILTER_SANITIZE_STRING ], 'contents' => [ 'filter' => FILTER_SANITIZE_STRING ], ]); //var_dump($filter); //echo "<br /><br />"; $search = false; //in the switch, false is reassigned value of the sanitized string and all is happiness
  2. I don't see an action set on your form, that might be something to look at. An action is the url/address that the form is sending too. example: <form action="action_page.php"> First name:<br> <input type="text" name="firstname" value="Mickey"> <br> Last name:<br> <input type="text" name="lastname" value="Mouse"> <br><br> <input type="submit" value="Submit"> </form>
  3. GOAL: echo switch statement case which maps/matches to 'postType' PROBLEM: Regardless of what I try, the $_POST data seems to vanish, thus the switch statements default case is triggered and the form shows again instead of the intended/desired echo statement that I hope to show based on the postType contained within the $filter variable. I am working in PHP 5.4 A var_dump returns: array(2) { ["postType"]=> NULL ["myContent"]=> string(4) "dsfs" } I believe that I have both the form and the switch statement syntaxs/formatting correct. My problem, i think is somewhere in how the data is or isn't being passed to the switch via the filter_input_array(INPUT_POST, [...]) my humble code stub: error_reporting(E_ALL | E_STRICT); define('THIS_PAGE',basename($_SERVER['PHP_SELF'])); //test data //$_POST = [ 'postType' => 'myPlayby', 'myContent' => 'Anna King', ]; //build the array of data created by from for switch checks $filter = filter_input_array(INPUT_POST, [ 'postType' => [], 'myContent' => [], ]); var_dump($filter); echo "<br /><br />"; //$search = false; switch ($filter['postType']) { case 'myChar': echo "Character Check: " . $filter['myCharacter']; $search = $filter['myCharacter']; break; //test data ought to trigger myPlayby case showing 'Playby check: Anna King' here... frack case 'myPlayby': echo "Playbe Check: " . $filter['myPlayby']; $search = $filter['myPlayby']; break; case 'myFoobar': echo "Foo Check: " . $filter['myFooBar']; $search = $filter['myFooBar']; break; default: echo '<form type="submit" method="post" action="' . THIS_PAGE . '"; > <select name="postTypes"> <option default disable>-------------</option> <option value="myChar">Character</option> <option value="myPlayby">Playby</option> <option value="myFooBar">Foo</option> </select> <input type="text" value="" name="myContent"/> <input type="submit" name="submit" value="Submit"> </form>' ; break; } This is my first time working with filter_input_array to handle $_POST data, and after a day of trial, error, research and effort which include looking at Lynda.com, searching Google and reading what relevant posts I could find on StackOverflow, php.net, etc, I am flummoxed.test-switch-stack.php
  4. Thank you, i think that i get that conceptually, but not how to actually do it.
  5. Newb here trying to build a form that works with ints to count how many red shirts die in a classic episode of star trek (exercise to get better with forms and ints). I have an error which reads as '7 Error message: Undefined index: rsTot'. I have tried a few things and read that setting it(casting it?) as a float was the safest way to work with the int, however each thing i've attempted results in some sort of error so after a day of reading and trying i'm very confused and hoping for an answer I can understand here. I have read through stackOverflow for an answer but not seen one which i can understand and apply that speaks to the problem i'm having of initially entering and process a number as an int which i can later do some math on. error can be seen here: http://zephir.seattlecentral.edu/~jstein11/itc250/z14/w03c0102_OOPform/w03c0102_OOPform.php <?php //w03c0102_OOPform require '../inc_0700/config_inc.php'; #provides configuration, pathing, error handling, db credentials //END CONFIG AREA ---------------------------------------------------------- $rsTot = (float)$_POST['rsTot'];// float more forgiving int $rsSurvived = (float)$_POST['rsSurvived']; $rsSum = $rsTot - $rsSurvived; $rsRatio = 0; # Read the value of 'action' whether it is passed via $_POST or $_GET with $_REQUEST if(isset($_REQUEST['act'])){$myAction = (trim($_REQUEST['act']));}else{$myAction = "";} switch ($myAction) {//check 'act' for type of process case "display": # 2)Display user's name! showName(); break; default: # 1)Ask user to enter their name showForm(); } function showForm() {# shows form so user can enter their name. Initial scenario get_header(); #defaults to header_inc.php ?> <script type="text/javascript" src="<?=VIRTUAL_PATH;?>include/util.js"></script> <script type="text/javascript"> function checkForm(thisForm) {//check form data for valid info if(empty(thisForm.YourName,"Field Empty, please fill out")){return false;} return true;//if all is passed, submit! } </script> <p align="center"><?=smartTitle();?></p> <h3 align="center">Star Trek Classic</h3> <h2 align="center">Death-Shirt Calculator</h2> <form action="<?=THIS_PAGE;?>" method="post" onsubmit="return checkForm(this);"> <p align="center">Classic Star Trek Episode Name<br /> <input type="text" name="epName" /><br /><br /> Esitmated number of officers with red shirts<br /> <input type="text" name="rsTot" /><br /><br /> Esitmated number of officers with red shirts<br /> to actually survive the episode<br /> <input type="int" name="rsSurvived" /><br /><br /> <input type="submit" value="Go!"> </p> <input type="hidden" name="act" value="display" /> </form> <?php get_footer(); #defaults to footer_inc.php } function showName() {#form submits here we show entered name get_header(); #defaults to footer_inc.php if(!isset($_POST['epName']) || $_POST['epName'] == '') {//data must be sent feedback("No form data submitted"); #will feedback to submitting page via session variable myRedirect(THIS_PAGE); } if(!ctype_alnum($_POST['epName'])) {//data must be alphanumeric only feedback("Only letters and numbers are allowed. Please re-enter your name."); #will feedback to submitting page via session variable myRedirect(THIS_PAGE); } $epSubmitted = strip_tags($_POST['epName']);# strip data entered echo '<h3 align="center">' . smartTitle() . '</h3>'; echo '<p align="center">Episode Name: <b>' . $epSubmitted . '</b><br />'; echo '<p align="center">Total Red Shirts Appearing: <b>' . $rsTot . '<br />'; echo 'Red Shirts Still Breathing at End of Episode: <b>' . $rsSurvived . '<br />'; echo 'Red Shirt Episode Survival Ratio: <b>' . $rsRatio . '</b>!</p>'; echo '<p align="center"><a href="' . THIS_PAGE . '">RESET</a></p>'; get_footer(); #defaults to footer_inc.php } ?>
  6. Newb here. My form works with sessions and the video loads etc, data submits, etc. all that is good. But i've gotten lost in the complexity of the build it seems and my html has become malformed I think. As a result each submission or page reload inserts another form inside the form inside the form etc etc etc. It some sort of weird looping madness or something. I'm very new to classes and how they work and i can't find where the madness is coming from. To duplicate the error, fill out the form and submit (the video won't play in firefox so use safari or chrome to test). I've been trying to resolve this for hours - i'm very lost in the complexity. <?php # '../' == sub-folder. use './' == root require '../inc_0700/config_inc.php'; #provides configuration, pathing, error handling, db credentials echo '<link rel="stylesheet" type="text/css" href="w05c09_gojiraIncidentReport.css">'; //END CONFIG AREA ---------------------------------------------------------- # Read the value of 'action' whether it is passed via $_POST or $_GET with $_REQUEST if(isset($_REQUEST['act'])){$myAction = (trim($_REQUEST['act']));}else{$myAction = "";} switch ($myAction){//check 'act' for type of process case "display": # 2)Display user's name! showObjects(); break; case "clear": # 3 Clear the session data clearObjects(); showForm(); break; default: # 1)Ask user to enter their name showForm(); } function showForm(){# shows form so user can enter their name. Initial scenario get_header(); #defaults to header_inc.php echo '<script type="text/javascript" src="' . VIRTUAL_PATH . 'include/util.js"></script> <script type="text/javascript"> function checkForm(thisForm){//check form data for valid info if(empty(thisForm.YourName,"Please Enter Your Name")){return false;} return true;//if all is passed, submit! } </script> <video id="bgVideo" preload="auto" autoplay="true" loop="loop" muted="muted" volume="0" poster="_bgGrfxs/bg_vidGlobe.jpg"> <source src="_bgVideo/bg_vidLoop.mp4" type="video/mp4"/> <source src="_bgVideo/bg_vidLoop.ogv" type="video/ogg"/> </video> <!-- This image stretches exactly to the browser width/height and lies behind the video--> <div id="bodyDummy"> <!-- <h3 align="center"">' . smartTitle() . '</h3>--> <br /> <br /> <br /> <br /> <br /> <br /> <form align="center" action="' . THIS_PAGE . '" method="post" onsubmit="return checkForm(this);"> <img width="10%" src="img_logo-panPacificDefenseCenter.png" alt="Kaiju Incident Reporter"/> <br /> <h2 style="color: #ff6d26;">Incident Report Form</h2> <br /> <!-- incWho? --> <br /> <b>Reporting Officer ID:</b><br /> <input type="text" name="incWho" placeholder="Please enter your full name here" /> <br /> <br /> <!-- incWhat --> <b><a id="orange" href="http://godzilla.wikia.com/wiki/Main_Page">Massive Unidentified Terrestrial Organism encountered:</a></b><br /> <select type="text" name="incWhat" data-placeholder="Select Incident Location..." class="chzn-select" multiple style="width:354px;" tabindex="40"> '; include 'ddlist-Kaiju.php'; echo '</select> <br /> <br /> <!-- incWhen = date of incident --> <b>Date of Incident:</b><br /> <input type="text" name="incWhen" placeholder="Please enter your full name here" /> <br /> <br /> <!-- incWhere --> <b>Incident Location:</b><br /> <select type="text" name="incWhere" data-placeholder="Select Incident Location..." multiple style="width:354px;" tabindex="111"> '; include 'ddlist-countriesInternational.php'; echo '</select> <br /> <br /> <!-- incWhy --> <b>Incident notes:</b><br /> <textarea name="incWhy" cols="54" rows="3" placeholder="Please enter any details you can recall of the incident - if incident is still occurring run" ></textarea> <br /> <br /> <!-- incScale --> <b>Rate the severity of the incident (0 to 5):</b> <br /> <br /> <input type="range" data-show-value="true" data-hightlight="true" data-popup-enabled="true" name="incScale" min="0" max="5" value="0" onchange="updateTextInput(this.value);"> <br /> <br /> <input id="go" type="submit" value="Go!"> </p> <input type="hidden" name="act" value="display" /> </form> <br /> <p style="#444"><i>Once you have completed your incident report, Run! For the love god man run, run for the hills and be safe!</i></p> '; get_footer(); #defaults to footer_inc.php echo '</div><!-- END bodyDummy -->'; } function showObjects() {#form submits here we show entered name //dumpDie($_POST); //if the session is not started, that could be a problem get_header(); #defaults to footer_inc.php if(!isset($_SESSION)){session_start();} echo "<br />"; if(!isset($_SESSION['kSession'])) {//if no session exists, create it $_SESSION['kSession']= array(); } //we need to add post data here $_SESSION['kSession'] [] = new incReport($_POST['incWho'], $_POST['incWhat'], $_POST['incWhen'], $_POST['incWhere'], $_POST['incWhy'], $_POST['incScale']); $totalScale = 0; foreach($_SESSION['kSession'] as $incReport)//loop thru each array item { echo $incReport; $totalScale += $incReport->incScale; } $totalReports = count($_SESSION['kSession']); $aveRating = $totalScale/$totalReports; echo '<div style="margin: auto; padding:0 10px; background-color:#ff6d26;width: 300px";><p style="color:white;">Average Incident Severity:</p> <h1 style="color:white;";>'; echo "$aveRating"; echo'</h1></div>'; if ($aveRating == 5){ echo '<p>Five: We suggest you make peace with this, your final moment.. enjoy the sunset before that giant foot comes down on you.</p>';} if ($aveRating == 4){ echo '<p>Four: The end is near, run man run, she isn\'t worth it, save yourse<p>lf.</p>';} if ($aveRating == 3){ echo '<p>Three: And your still there? Seriously?</p>';} if ($aveRating == 2){ echo '<p>Two: Take a picture, it will last longer. Now. Run for the hills!</p>';} if ($aveRating == 1){ echo '<p>One: Have you considered running?</p>';} if ($aveRating == 0){ echo '<p>Zero: This would be a good time to consider moving to a safer vantage point.</p></form></div><!--end dummy-->';} //get_footer(); #defaults to footer_inc.php //------end of work area-------// get_header(); #defaults to footer_inc.php if(!isset($_POST['incWho']) || $_POST['incWhat'] == ''){//data must be sent feedback("No form data submitted"); #will feedback to submitting page via session variable myRedirect(THIS_PAGE); } if(preg_match('[^A-Za-z0-9]', $_POST['incWho'])){//data must be alphanumeric only feedback("Only letters & numbers are allowed."); #will feedback to submitting page via session variable myRedirect(THIS_PAGE); } $myName = strip_tags($_POST['incWho']);# here's where we can strip out unwanted data } function clearObjects(){ //echo "clearing objects here"; if(!isset($_SESSION)){session_start();} unset($_SESSION['kSession']); feedback("session cleared"); } class incReport{ public $incWho = ""; public $incWhat = ""; public $incWhen = ""; public $incWhere = ""; public $incWhy = ""; public $incScale = ""; function __construct($incWho, $incWhat, $incWhen, $incWhere, $incWhy, $incScale){ $this->incWho=$incWho; $this->incWhat=$incWhat; $this->incWhen=$incWhen; $this->incWhere=$incWhere; $this->incWhy=$incWhy; $this->incScale=$incScale; } function __toString(){ static $kID = 1;//kaiju incident number $myReturn = '<video id="bgVideo" preload="auto" autoplay="true" loop="loop" muted="muted" volume="0" poster="_bgGrfxs/bg_vidGlobe.jpg"> <source src="_bgVideo/bg_vidLoop.mp4" type="video/mp4"/> <source src="_bgVideo/bg_vidLoop.ogv" type="video/ogg"/> </video> <div id="bodyDummy"> <br /> <br /> <br /> <br /> <br /> <br /> <form><p> Incident ID: kID00' . $kID ; //works $kID++; //iterate report $myReturn .= ' | Incident Reported by: ' . $this->incWho . ' ' ;//works $myReturn .= ' | Massive Terrestial Organsim Observed: ' . $this->incWhat . ' ' ;//shows where... $myReturn .= ' | Date of Incident: ' . $this->incWhen . ' ' ; //works $myReturn .= ' | Incident Location: ' . $this->incWhere . ' '; //shows what $myReturn .= ' | Incident Details: ' . $this->incWhy. ' '; // working $myReturn .= ' | Incident Severity: ' . $this->incScale . '</p> <p align="center"><a href="' . THIS_PAGE . '">File Report, then Run!</a> | <a href="' . THIS_PAGE . '?act=clear">Reset</a></p> ' ; return $myReturn; } }
  7. Wanted to add that i was able to find the second problem once I got through the first, so again, thank you Psycho for all your help.
  8. Thank you Psycho for the help, I learned a lot and will be re-examining how i do my indenting as I don't believe i've been indenting correctly. Is there a guide somewhere that you would recommend to look at on how to and when to indent? I am also now able to get to what appears to be my main error which is 'Error in file: '/home/classes/jstein11/public_html/itc250/z14/surveys/w06c02cxx.php' on line: 69 Error message: Unknown column 'Survey14' in 'where clause''. I believe that that means that i don't have the column that is begin asked for or that i've misspelt the column I am asking for. thank you for the help, it was very educational and very much appreciated.
  9. Thanks - I'm crawling through your notes and I promise i do indent, but i'm not getting my indents to come through when i copy them from my editor, so i am doing something wrong there and I will have to work on that/will work on that. Thanks for the tips, i'm off to continue crawling through the notes you left - thank you.
  10. I've looked at my closing braces Jacques1, and i've gone an re-uploaded my code. I thought i had to enter it a certain way into the editor here for it to post, i'm still not quite sure how to post my code so that it shows i've practiced proper indenting but I do believe that i have. I've gone through all my closing braces '{' and '}' and they all seem to be properly paired. I'm quite stumped on this - i can't find the error.
  11. My error happens on line #81 My error: Parse error: syntax error, unexpected 'class' (T_CLASS), expecting function (T_FUNCTION) in w06c02cxx.php on line 81 Troubleshooting notes: I've been reviewing this exercise throughout the weekend trying to find my error. I've used my code editors syntax highlighting tools (BBedit 10), but still the error persists. I learned about the 20/20/20 rule during this process and have practiced that while attempting to debug the code. I've scoured the web trying to find examples to help me, but i'm a new and nothing i've thus found has helped me to resolve my error, hoping someone here can help. I think the error is happening in my survey class, somewhere before line #81 Link to error: http://zephir.seattlecentral.edu/~jstein11/itc250/z14/surveys/w06c02cxx.php require '../inc_0700/config_inc.php'; #provides configuration, pathing, error handling, db credentials $config->titleTag = smartTitle(); #Fills <title> tag. If left empty will fallback to $config->titleTag in config_inc.php $config->metaDescription = smartTitle() . ' - ' . $config->metaDescription; //END CONFIG AREA ---------------------------------------------------------- get_header(); #defaults to header_inc.php $mySurvey = new Survey(1);//all our code happens in here if ($mySurvey->isValid){ echo ' The title of the surevis is ' . $mySurvey->Title . ' <br />'; echo ' The title of the surevis is ' . $mySurvey->Description . ' <br />'; }else{echo ' No such survey exists';} dumpDie($mySurvey); //like var_dump inside/available this app because of common file get_footer(); #defaults to footer_inc.php class Survey{//class creates one object at a time, creates as many as you want //create properties public $SurveyID = 0; public $Title = ''; public $Description = ''; public $isValid = FALSE; public $Questions = array();// how we add an array of questions to a survey function __construct($id){ $id = (int)$id; //cast to an integer - stops most sequal injection in this case if($id == 0){ return false; //don't bother asking database, there is no frog, don't ask - no data no dice } $sql = "select Title, Description, SurveyID from sp14_surveys where SurveyID = $id"; $result = mysqli_query(IDB::conn(),$sql) or die(trigger_error(mysqli_error(IDB::conn()), E_USER_ERROR)); //echo '<div align="center"><h4>SQL STATEMENT: <font color="red">' . $sql . '</font></h4></div>'; if(mysqli_num_rows($result) > 0) {#there are records - present data while($row = mysqli_fetch_assoc($result)) {# pull data from associative array $this->SurveyID = (INT)$row['SurveyID']; $this->Title = $row['Title']; $this->Description = $row['Description']; } $this->isValid = TRUE; } @mysqli_free_result($result);//at symbol surpresses multiple copies of an error silences a line basically $sql = "select * from sp14_questions where Survey14 = $id"; $result = mysqli_query(IDB::conn(),$sql) or die(trigger_error(mysqli_error(IDB::conn()), E_USER_ERROR)); if(mysqli_num_rows($result) > 0) {#there are records - present data while($row = mysqli_fetch_assoc($result)) {# pull data from associative array $this->Questions[] = new Question((INT)$row['QuestionID'],$row['Question'],$row['Description']); } }//end of constructor }//end of survey class //BEGIN new question object class Question{ public $QuestionID = 0; public $Text = ''; public $Description = ''; function __construct($QuestionID, $Question, $Description){ $this->QuestionID = $QuestionID; $this->Question = $Question;// field is named Question $this->Description = $Description;// the context info about the question asked }//END question Constructor }// END question Class } w06c02cxx.php
  12. I'm attempting to set display some data pulled from the database and present it in a table so i can get everything to line up correctly. When I attempt to form a table around it, the content hops out of the table or part of it does not display. Working on the first row, it currently displays 'CITIZENSHIP: USA' //if ($citizenship) { echo "<strong>CITIZENSHIP:</strong> $citizenship"; If I try this, it displays 'USA', the citizenship 'vanishes'. //if ($citizenship) { echo "<tr> // <td align=\"right\" valign=\"top\"><p><strong>CITIZENSHIP:</strong></p></td> // <td width=\"10\"> </td> // <td valign=\"top\"><p>" . $citizenship . "</p> // </td></tr>"; <table cellpadding=\"0\" cellspacing=\"0\"> <?php //if ($citizenship) { echo "<tr> // <td align=\"right\" valign=\"top\"><p><strong>CITIZENSHIP:</strong></p></td> // <td width=\"10\"> </td> // <td valign=\"top\"><p>" . $citizenship . "</p> // </td></tr>"; if ($citizenship) { echo "<strong>CITIZENSHIP:</strong> $citizenship"; if ($legalstatus) { echo ", $legalstatus"; } echo "<br >\n"; } else if ($legalstatus) { echo "<strong>Legal Status:</strong> $legalstatus"; } // end legal status if ($type=="administrator" || $type=="alumni" || $type=="faculty" || $type=="staff" || $type=="student") { $theseFields = array("placeofbirth", "maritalstatus", "occupation", "affiliation"); } else { $theseFields = array("placeofbirth", "maritalstatus", "occupation", "affiliation", "baseofoperations"); } // end if resident foreach ($theseFields as $thisField) { if (${$thisField}) { echo "<strong>" . ${$thisField . "Name"} . ":</strong> "; echo ${$thisField}; if (isset(${"former" . $thisField})) { if (${"former" . $thisField}) { echo " (formerly " . ${"former" . $thisField} . ")"; } } // end if set } // end if info } // end FOREACH if ($type=="administrator" || $type=="alumni" || $type=="faculty" || $type=="staff" || $type=="student") { ?> </table> ANy help would be greatly appreciated. I'm very much a newb. Thanks to anyone kind enough to try to help me with this. I've been struggling with this all day and i really thought it'd tage a few minutes. Thanks
  13. I was able to make the script work on FF as long as it was not colliding with all the APIs that are referenced on the page (jQuery, Scriptaculous, etc.) So I added the following code at the bottom of the 'snow' JS: if (browserok) { addOnload(initsnow); } function addOnload(myfunc) {//addOnload function allows us to attach if(window.addEventListener){ window.addEventListener('load', myfunc, false); }else if(window.attachEvent){ window.attachEvent('onload', myfunc); } } But it is only working on firefox and I.E. (and safari I think) for the PC. Anyone have any suggestions - I am very defeated at this point
  14. Hi everyone, First let me say that I am at best a novice when it comes to code. Generally speaking i can copy a script and plug it in and get it working (usually). Currently I'm trying to get it to snow for the holidays on a friend's gaming site for the holidays as a present. I've tested the code and it works in all browsers (www.xaviers-children.net/snow.php) but when I try to plug the script in so that it works throughout the site by having it delivered through the header, it only works in I.E. Im safari and firefox, the snowflakes accumulate in a single spot (in the upper right corner of the surreal portrait of Professor Xavier - it's a fun x-men site ) Site url: www.xaviers-children.net/welcome.php test url: www.xaviers-children.net/snow.php Javascript code: // Set the number of snowflakes (more than 30 - 40 not recommended) var snowmax=35 // Set the colors for the snow. Add as many colors as you like var snowcolor=new Array("#aaaacc","#ddddFF","#ccccDD") // Set the fonts, that create the snowflakes. Add as many fonts as you like var snowtype=new Array("Arial Black","Arial Narrow","Times","Comic Sans MS") // Set the letter that creates your snowflake (recommended:*) var snowletter="*" // Set the speed of sinking (recommended values range from 0.3 to 2) var sinkspeed=0.6 // Set the maximal-size of your snowflaxes var snowmaxsize=22 // Set the minimal-size of your snowflaxes var snowminsize=8 // Set the snowing-zone // Set 1 for all-over-snowing, set 2 for left-side-snowing // Set 3 for center-snowing, set 4 for right-side-snowing var snowingzone=1 /////////////////////////////////////////////////////////////////////////// // CONFIGURATION ENDS HERE /////////////////////////////////////////////////////////////////////////// // Do not edit below this line var snow=new Array() var marginbottom var marginright var timer var i_snow=0 var x_mv=new Array(); var crds=new Array(); var lftrght=new Array(); var browserinfos=navigator.userAgent var ie5=document.all&&document.getElementById&&!browserinfos.match(/Opera/) var ns6=document.getElementById&&!document.all var opera=browserinfos.match(/Opera/) var browserok=ie5||ns6||opera function randommaker(range) { rand=Math.floor(range*Math.random()) return rand } function initsnow() { if (ie5 || opera) { marginbottom = document.body.clientHeight marginright = document.body.clientWidth } else if (ns6) { marginbottom = window.innerHeight marginright = window.innerWidth } var snowsizerange=snowmaxsize-snowminsize for (i=0;i<=snowmax;i++) { crds[i] = 0; lftrght[i] = Math.random()*15; x_mv[i] = 0.03 + Math.random()/10; snow[i]=document.getElementById("s"+i) snow[i].style.fontFamily=snowtype[randommaker(snowtype.length)] snow[i].size=randommaker(snowsizerange)+snowminsize snow[i].style.fontSize=snow[i].size snow[i].style.color=snowcolor[randommaker(snowcolor.length)] snow[i].sink=sinkspeed*snow[i].size/5 if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)} if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)} if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4} if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2} snow[i].posy=randommaker(6*marginbottom-marginbottom-6*snow[i].size) snow[i].style.left=snow[i].posx snow[i].style.top=snow[i].posy } movesnow() } function movesnow() { for (i=0;i<=snowmax;i++) { crds[i] += x_mv[i]; snow[i].posy+=snow[i].sink snow[i].style.left=snow[i].posx+lftrght[i]*Math.sin(crds[i]); snow[i].style.top=snow[i].posy if (snow[i].posy>=marginbottom-6*snow[i].size || parseInt(snow[i].style.left)>(marginright-3*lftrght[i])){ if (snowingzone==1) {snow[i].posx=randommaker(marginright-snow[i].size)} if (snowingzone==2) {snow[i].posx=randommaker(marginright/2-snow[i].size)} if (snowingzone==3) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/4} if (snowingzone==4) {snow[i].posx=randommaker(marginright/2-snow[i].size)+marginright/2} snow[i].posy=0 } } var timer=setTimeout("movesnow()",50) } for (i=0;i<=snowmax;i++) { document.write("<span id='s"+i+"' style='position:absolute;top:-"+snowmaxsize+"'>"+snowletter+"</span>") } if (browserok) { window.onload=initsnow } Any help is greatly appreciated Thank you everyone and cheers/happy holidays to one and all alike
  15. Hello to one and all, History: I'm a novist (at best) regarding PHP. Recently I moved my site from GoDaddy to Dreamhost's servers and now when someone tries to register on our forum, they usually error out. I believe that this is do to a 'regex' expression issue. Specifically, the problem surfaces when the user submits a mix of single and double quotes. I think that the single and double quotes are being registered as code?(am i saying/describing that correctly?) I'm hoping that I can get some help sorting this problem out - I'm very very confused and very very beyond my abilities to resolve this (thank you very very much for any and all help). TEST MESSAGE/SAMPLE DATA/DATA SUBMITTED: 'test' "test" test's RESULTING ERROR MESSAGE (PHP Error Produced): Error! There was an error updating the Player database and your changes may not have been made. Provide the following information to the system administator: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'test" test's", "", "", "", "1", "", "test", "", "", "", "", "true", "", "", "", ' at line 1 (1064) INSERT INTO login (username, password, moderated, name, email, emailprivate, aimprivate, yahooprivate, icqprivate, gtalkprivate, web, city, state, country, comments, sampleLDB, fcRequestLDB, historyLDB, charCount, moderator, aim, gTalk, yahoo, icq, approved, confirmTerms, charApprove, charEdit, charCountApprove, charRemove, memApprove, memAway, memBan, memEdit, memRemove, okCountdown, okDate, okTime, okWeather, postApprove, postEdit, postRemove, postSuspend , lastmodified, dateadded) VALUES("Test02", "dd", "", "Test01", "test02@test.com", "", "", "", "", "", "", "", "", "US", "'test' "test" test's", "", "", "", "1", "", "test", "", "", "", "", "true", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", NOW(), NOW()) EXPECTED RESULT: Profile Submitted Successfully! Your member profile has been submitted! Once it's approved by a moderator, you will have access to the the site. Click here to return to the main xaviers-children page. MY CODE: // ================ IF THEY SUBMITTED THE CHANGES, MAKE THEM! $patterns = array ("/([^\n\r\f])[\n\r\f]+([^\n\r\f])/"); $replace = array ("\\1\n\\2"); $allFields = array_merge($fields, $fields_extra); FOREACH ($allFields as $thisField) { $THISFIELD = strtoupper($thisField); if (isset($_POST{$THISFIELD})) { ${$THISFIELD} = $_POST[$THISFIELD]; } else { ${$THISFIELD} = ""; } ${$THISFIELD} = preg_replace ($patterns, $replace, ${$THISFIELD}); } // end FOREACH if (!$id) { if ($PASSWORD != $PASSWORD2 || !$PASSWORD) { $errorText="You must choose a password and you must enter it twice for accuracy. Please go back and submit the form again."; } if (preg_match("/[ \(\)\+\.]/",$AIM) || preg_match("/[ \(\)\+\.]/",$GTALK) || preg_match("/[ \(\)\+\.]/",$YAHOO)) { $errorText="Please only put the screen name in the AIM, Google Talk and Yahoo fields, no comments or special characters."; } $existTest = readDatabase("SELECT * FROM login WHERE username=\"$USERNAME\" || email = \"$EMAIL\"",$db); if ($existTest["email"] == $EMAIL) { $errorText = "That email address is already in use, and there's only one account allowed per person!<br />Please go back and submit the form again after making changes."; } if ($existTest["username"] == $USERNAME) { $errorText = "That username is already in use. You'll have to choose a different one, I'm afraid!<br />Please go back and submit the form again after making changes."; } } // end if no ID if (!$USERNAME) { //if they didn't a name for their profile... $errorText="You must choose a username for this profile.<br />Please go back and submit the form again after making changes."; } // end if no NAME I appologize if i've given too large a code sample of the file, but I'm not sure what is necessary and am trying to provide all necessary detail in hopes of getting an answer that will help me to resolve my problem. I'm hoping that it's just a matter of placing in a new pattern in to $patterns = array ("/([^\n\r\f])[\n\r\f]+([^\n\r\f])/");' on line #88 (I dont' really understand any of this, i'm just the joe-idiot trying to fix/resolve it). Thank you one and alll for any help thank you thank you thank you. -Chez the novist
  16. Update: I tried revising my code like so -- but I still get no notice, everything else on the site appears to be working though. I'm very confused. if (!$APPROVED && !$id) { echo mail(file_get_constants("_modEmailAddresses.txt"), "[$siteName] New Player", "A new member has submitted a profile to the $siteName website.\n\n Name: $NAME\nUsername: $USERNAME\n\n Visit this URL to approve the member:\nhttp://www.xaviers-children.net/home.php", "Return-Path: xaviers-children <chezshire@gmail.com>\n Errors-To: xaviers-children.net <chezshire@gmail.com>\n From: xaviers-children <chezshire@gmail.com>\n Reply-To: xaviers-children.net <chezshire@gmail.com>\n X-Mailer: PHP/" . phpversion()); }
  17. Hello everyone, currently i have a small site with a few moderators which change (frequently), as such I have to update a lot of scripts so that they will receive notifications so they can do they're thing. I am currently trying to simplify the process down so that I have only one file to update vs. twenty plus files to update by using the 'file_get_contents' in the mail call. However, when I tried this i get no results -- everything appears to work, but no notices/emails go out. Below is an example of the script -- (from line #314 to #323). It would be really awesome if someone could tell me what boneheaded thing I am or am not doing to make this work correctly. Thank you for any and all help (and please know that I am a complete newb who once he gets this headache resolved is going to try to make a function to do it so he doesn't have to update anything -- but i need to go one step at a time as I really don't know what I am doing). Script as it was (This one works - but i have to manually update it everytime their is a change in moderators) if (!$APPROVED && !$id) { mail("ADAMS <doyleconlan@ireland.com>, DITKO <chezshire@gmail.com>, VAUGHAN <vismaior2000@yahoo.com>", "[$siteName] New Player", "A new member has submitted a profile to the $siteName website.\n\nName: $NAME\nUsername: $USERNAME\n\nVisit this URL to approve the member:\nhttp://www.xaviers-children.net/home.php", "Return-Path: xaviers-children <chezshire@gmail.com>\nErrors-To: xaviers-children.net <chezshire@gmail.com>\nFrom: xaviers-children <chezshire@gmail.com>\nReply-To: xaviers-children.net <chezshire@gmail.com>\nX-Mailer: PHP/" . phpversion()); } This is what I'm trying to change it to so I only have to update a text file using the get_file_contents function Script as it was (This one works - but i have to manually update it everytime their is a change in moderators) $emailAddresses = file_get_contents("_modEmailAddresses.txt"); $to = $emailAddresses; if (!$APPROVED && !$id) { mail($emailAddresses, "[$siteName] New Player", "A new member has submitted a profile to the $siteName website.\n\n Name: $NAME\nUsername: $USERNAME\n\n Visit this URL to approve the member:\nhttp://www.xaviers-children.net/home.php", "Return-Path: xaviers-children <chezshire@gmail.com>\n Errors-To: xaviers-children.net <chezshire@gmail.com>\n From: xaviers-children <chezshire@gmail.com>\n Reply-To: xaviers-children.net <chezshire@gmail.com>\n X-Mailer: PHP/" . phpversion()); } This is the text file I am calling with the email addresses ADAMS <doyleconlan@ireland.com>, DITKO <chezshire@gmail.com>, NICIEZA <zombiesgogrrr@aol.com>, STERANKO <siege_perilous6403@yahoo.com>, VAUGHAN <vismaior2000@yahoo.com> Any help is very thankfully received and appreciated Thanks Chez
  18. I went and read up some more on the mail() function, and thought that perhaps what I was doing work if i put the $emailAddresses and $to directly inside the mail call (I dont' think i'm using the termis correctly-sorry still learning) - please see example below for what else did not work - it produced an error if (!$APPROVED && !$id) { mail( //Gets address as a string from text file - one place to update all addresses $emailAddresses = file_get_contents("_modEmailAddresses.txt"); $to = $emailAddresses; $emailAddresses, "[$siteName] New Player", "A new member has submitted a profile to the $siteName website.\n\nName: $NAME\nUsername: $USERNAME\n\nVisit this URL to approve the member:\nhttp://www.xaviers-children.net/home.php", "Return-Path: xaviers-children <chezshire@gmail.com>\nErrors-To: xaviers-children.net <chezshire@gmail.com>\nFrom: xaviers-children <chezshire@gmail.com>\nReply-To: xaviers-children.net <chezshire@gmail.com>\nX-Mailer: PHP/" . phpversion()); } Still scratching my head on this one.
  19. I just attempted to revise third line like so and received a parsing/t-string errors. I am a complete newb who is over his head. if (!$APPROVED && !$id) { mail = $emailAddresses("[$siteName] New Player", This didn't work either. Any suggestions are appreciated. I think that i'm close - this will, if i can get it to work make my life so much easier. thanks
  20. Hi Everyone, I recently learned about the 'file_get_contents' function here at phpFreaks (thank you) and I am now trying to use that automate all my email scripts. It's working in most of them, however this one is not am I am unsure of why. I tried it like this: //Gets address as a string from text file - one place to update all addresses $emailAddresses = file_get_contents("_modEmailAddresses.txt"); $to = $emailAddresses; //if (!$APPROVED && !$id) { mail($emailAddresses, "[$siteName] New Player", "A new member has submitted a profile to the $siteName website.\n\nName: $NAME\nUsername: $USERNAME\n\nVisit this URL to approve the member:\nhttp://www.xaviers-children.net/home.php", "Return-Path: xaviers-children <chezshire@gmail.com>\nErrors-To: xaviers-children.net <chezshire@gmail.com>\nFrom: xaviers-children <chezshire@gmail.com>\nReply-To: xaviers-children.net <chezshire@gmail.com>\nX-Mailer: PHP/" . phpversion()); } This did not work, so I tried changing the third line variable from '$email' to '$mail' as show below, this also did not work. //Gets address as a string from text file - one place to update all addresses $emailAddresses = file_get_contents("_modEmailAddresses.txt"); $mail = $emailAddresses; if (!$APPROVED && !$id) { mail($emailAddresses, "[$siteName] New Player", "A new member has submitted a profile to the $siteName website.\n\nName: $NAME\nUsername: $USERNAME\n\nVisit this URL to approve the member:\nhttp://www.xaviers-children.net/home.php", "Return-Path: xaviers-children <chezshire@gmail.com>\nErrors-To: xaviers-children.net <chezshire@gmail.com>\nFrom: xaviers-children <chezshire@gmail.com>\nReply-To: xaviers-children.net <chezshire@gmail.com>\nX-Mailer: PHP/" . phpversion()); } I feel that I'm very close, and that my problem is just staring me right in the face and I can't see it -- any help would be greatly appreciated. Thank you very much -chez
  21. Yes I did test it, but it didn't appear to work. But following the guidance provided here, I looked at my text file being read in and realized I had some quote marks in the text file what was causing my script to error out. Thank you everyone -Chez
  22. So I should change this line of code: $emailAddresses = file_get_contents(email_addresses.txt); to this: $emailAddresses = file_get_contents("email_addresses.txt"); Am i understanding you correctly? Thank you very much for the help -Chez
  23. Hmms, So should I change this line of code: $emailAddresses = file_get_contents(email_addresses.txt); to this: $emailAddresses = file_get_contents(email_addresses.\txt); There is a period in the line of code - is that causing a concatenation thus erring out script? -Chez
  24. Hello to one and all, newbie/hobbiest here - I am attempting to adjust the mail function in my scripts so that rather then having to constantly update 30 different scripts I can have one text doc that they can all draw on using the file_get_contents function to read in the email address as a string and send the notices to those email address, however I am getting an error when I attempt this which reads as follows: Warning: file_get_contents(email_addressestxt) [function.file-get-contents]: failed to open stream: No such file or directory in /home/maxster/xaviers-children.net/modMail/charRequest.php on line 2 $emailAddresses = file_get_contents(email_addresses.txt); $to = $emailAddresses; [\code] Error produced: Warning: file_get_contents(email_addressestxt) [function.file-get-contents]: failed to open stream: No such file or directory in /home/maxster/xaviers-children.net/modMail/charRequest.php on line 21 text file being read: [code] Ditko <chezshire@gmail.com>, Bill<example@example.com> Full Php Script: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Xavier's Children » Character Request Sent!</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body align="center"> <h2 align="center">Xavier's Children » Character Request Sent!</h2> <?php $name = $_POST['namePlayer']; $topic = $_POST['nameTopic']; $char_overview = $_POST['charOverview']; $char_requested = $_POST['charRequested']; $email = $_POST['email']; $oc_fc = $_POST['OcFc']; //$emailAddresses = file_get_contents(email_addresses.txt); //$to = $emailAddresses; $to = 'ADAMS <doyleconlan@ireland.com>, DITKO <chezshire@gmail.com>, VAUGHAN <vismaior2000@yahoo.com>'; $subject = 'Xavier\'s Children » Character Request ' . $oc_fc . ' - ' . $char_requested; $msg = "FROM: $name \n \n"; $msg .= (empty($oc_fc)) ? "" : "OC or FC: $oc_fc \n \n"; $msg .= (empty($char_requested)) ? "" : "CHARACTER NAME: $char_requested \n \n"; $msg .= "CHARACTER OVERVIEW: $char_overview \n \n"; mail($to, $subject, $msg, 'From:' . $email); echo 'Your petition to play <strong>' . $char_requested . '</strong> has been submitted and forward to the appropriate member\'s staff members ' . $name . '. Please allow us to review and consider your request. We will attempt to contact you with a decision within twenty-four hours.<br /> <br />'; ?> <p align=center><a href=../messages.php>RETURN TO XAVIER'S CHILDREN</a></p> </body> </html>
  25. Oops - I've been posting in the wrong portion of the forum - I am uber sorry (See I am a newb). My apologies to one and all. -Chez
×
×
  • 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.