Jump to content

iarp

Members
  • Posts

    326
  • Joined

  • Last visited

Everything posted by iarp

  1. The query's all worked, i echo'd them out and could see them all after the script stopped, and then manually tried them in mysql. So my next thought was an issue about resources (being on a shared server and all). So i mysql_close() after the query in the header area and then opened a new connection right above the queries. It works now, something must've been going on with mysql dropping the connection or something i'm unsure of.
  2. max_execution_time = 600 max_input_time = 200 Is set in the php.ini My script runs exec("wget $url"); # This line uploads the wget'd item to my amazon s3 bucket # Email about status, successful or not /* * Series of inserts into mysql */ Now, it downloads, uploads and emails without issue, but the queries don't execute. There is no errors shown at all, and nothing in the database afterwards. The file is anywhere from 60-100MB's, and takes about 4seconds to download, 12-30seconds to upload. I'm not sure if it's the execution time, or maybe running out of resources to execute mysql queries? Not sure what to do from here.
  3. I'm trying to limit the number of calls on the database I must make. I have one that returns approx 4000 rows. I'm needing to use the results in two separate while loops, without making two calls resulting in 8000 rows being passed. I've tried just an easy [below], which didn't work, the second while loop didn't echo anything and didn't even error at all. $results = $results2 My guess as to why that happened would be because the first $result emptied the dataset and the $results2 was acting like a pointer or something, i'm not sure, completely speculating.
  4. I run the exact same SP within the database itself and all data is correct, all data is present and everything has information, every cell. But within the $teams->Fields entries, they are empty depending on what order i call them in. This is a paste of the columns i have to deal with. There are many others, another SP i'm calling from has many many more columns. PlayerIds LeagueName DivisionName SubDivisionName SeasonName DraftListrOUNDNumber DraftListPickNumber RndPck DraftStartPosition Team LastName FirstName HCId SMId Season League Division PlayerAvailable PlayerType BChk DOBY DateOfBirth FullName Avl PlayerType MF Rank Rating Goals Assists Shoots Position
  5. $teams = $db->Execute("EXEC Sports.dbo.TeamMembers"); while(!$teams->EOF) { echo $teams->Fields['RdPk']; echo $teams->Fields['Position']; echo $teams->Fields['Bchk']; echo $teams->Fields['Rating']; $teams->MoveNext(); } $teams->Close(); Mind you that is a small list of columns. But the SP returns it in this order 1. Position 2. RdPk 3. Rating 4. Bchk
  6. Hey there, i have a stored procedure that passes me information from the techs database. I'm stuck using some type of ADODB system, I've never used it in the past. But i'm finding, if i have 50 columns and i call column 29 and then try to call on column 15 (using their names not the number) column 15 comes through as blank. But if i call column 15 and then 29 everything works. Not sure how to do this, i cannot modify the Stored Procedure to my column ordering on the web page, and i have a lot of columns. At first i thought of maybe putting the data in the order of the SP's results into variables and then using the variables as i see fit, just there's a lot of columns i'm pulling.
  7. Your <option> tags in the form need to be value="" not id="" This will get you the description on the receiving end: $getDescription = mysql_query("SELECT ex_description FROM getfit_exercises2 WHERE id = '" . $_POST['select'] . "'"); $row = mysql_fetch_array($getDescription); echo $row['ex_description'];
  8. Long story short, some people have been storing credit cards in open note areas of a program they bought. It runs off of MSSQL. MSSQL has no way of finding all credit card numbers and masking them with X's. So I've resorted to using PHP. The area where the CC numbers were stored are the notes area, a place they also store the order details and much more. # Remove all spaces, dashes, and extra html from the note. $note = trim(strip_tags(str_replace(array('-', ' ', 'P,UL,OL,DL,DIR,MENU,PRE{margin:0auto;}'), '', $row['notes']))); A var_dump on $note results in string(22) "4123123412341234 blah" RegEx to find the cards # RegEx check against Visa, Mastercard, Amex, if(preg_match('/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$/i', $note)) { $found[] = $row['recid']; } After the while loop, i want to see what is in $found print_r($found); # Results in Notice: Undefined variable: found in ..... test.php on line # I have tried many regex strings trying to get preg_match to work. The idea is, once the recid is found to contain a credit card number i will then loop through $found again and update each row as necessary. Am i using preg_match in an incorrect way? If i edit the note in the program and remove the blah so it's just the CC number it returns positive and $found gets the recid. But as soon as anything else is entered it fails and no recid.
  9. Where are you running the script? If it's a linux based machine with postfix it could potentially be in a queue system (postfix --flush I think). Also possible that the email system is setup to not accept emails from the domain for some reason. It sends just fine on my linux and windows based systems.
  10. After reading your posts, it makes sense I clean up those bad variable names. Also, fixed my double redirect issue of, submit form -> process -> redirect back to form, now it posts right back to itself. My only wonder is, if you think I shouldn't be running this within a class, what better way is there. I primarily did it in a class format just to the user could add $form->getForm(); as well to not have to deal with potential scoping or variable issues from other applications that might use the same variable I am. The statement is still big, but i think it's easier to read. foreach ($_POST['data'] as $liveField => $liveData) { foreach ($this->info as $storedField => $storedData) { if ($storedField == $liveField) { if ( ( $storedData['required'] && ( empty($liveData) || !isset($liveData) ) ) || ( !$this->escape_data($liveData,$storedData['type']) ) || ( !$this->escape_data($liveData,$storedData['type']) && ($storedData['required']) ) ) { if ($storedData['required'] || (!$storedData['required'] && !empty($liveData)) ) $this->errors[$liveField] = true; } elseif ($storedData['required'] && ($liveData == $storedData['default'])) { if ($storedData['readonly'] != true) $this->errors[$liveField] = true; } elseif ($storedData['required'] && $storedData['readonly'] && ($liveData != $storedData['default']) ) { $_POST['data'][$liveField] = $storedData['default']; # Box is required, set to readonly and has a default value, if this triggers then the user has tampered with our form. } elseif (isset($this->errors[$liveField])) { unset($this->errors[$liveField]);# = false; } } elseif ( isset($this->info['file']) ) { if ($this->info['file']['required'] && $_FILES['file']['size'] == 0) $this->errors['file'] = TRUE; else unset($this->errors['file']); } } } Always learning new tricks.
  11. It's from a form that the user fills out, if the form fails, I've yet to find another way to pass the data back to the form so the user doesn't have to re-fill everything in, GET/POST isn't possible, cookies too unreliable. I'm not sure how to respond about the class doing too much. Everything I've written so far has a flow through that requires access to all 10 functions I've written, I could attempt to separate some parts, but I'm not sure how that would help as I would still have to call all functions/classes, I figured one class would be easiest to manage.
  12. I'm trying to clean up some past coding for a project of mine and this block keeps standing out like a sore thumb, but it works and i can understand it. What it's doing is comparing each of the users submitted data to the admin-set data and then flagging if there any errors or not. Any suggestions on a different approach? foreach ($_SESSION['usersData'] as $k => $v) { foreach ($this->info as $m => $n) { if ($m == $k) { if ( ($n['required'] && ( empty($v) || !isset($v) ) ) ) { $_SESSION['errors'][$k] = TRUE; } elseif ( (!$this->escape_data($v,$n['type'])) && ($n['required']) ){ $_SESSION['errors'][$k] = true; } elseif ($n['required'] && ($v == $n['default'])) { if ($n['readonly'] != true) $_SESSION['errors'][$k] = true; } elseif ($n['required'] && $n['readonly'] && ($v != $n['default']) ) { # Box is required, set to readonly and has a default value, if this triggers then the user has tampered with our form. $_SESSION['usersData'][$k] = $n['default']; } elseif (isset($_SESSION['errors'][$k])) { unset($_SESSION['errors'][$k]);# = false; } } elseif ( isset($this->info['file']) ) { if ($this->info['file']['required'] && $_FILES['file']['size'] == 0) { $_SESSION['errors']['file'] = TRUE; } else { unset($_SESSION['errors']['file']); } } } }
  13. Digging up my original post. After a while of recoding things to fix the Undefined Index issues, i've run into others. For the most part, this is my getVar function: function getVar($varname) { if(isset($_GET[$varname])) { return $_GET[$varname]; } elseif (isset($_POST[$varname])) { return $_POST[$varname]; } else { return false; } } I don't have to worry about both GET and POST because it's only one or the other for all fields anyways and this function seems to be working well enough. My issue is that i have a lot of short if's that are checking for an array entry such as: $html .= ($v['readonly']) ? ' readonly="readonly"' : NULL; $html .= ( ($v['uri']) && ($this->getVar($v['uri'])) ) ? urldecode($_GET[$v['uri']]) : NULL; And it is now these empty array values that are causing the index issues. Do I fix these short ifs somehow or figure out how to set all defaults(if not present) in the array items themselves (somehow).
  14. The function idea is very smart, I shall do that. The script currently has both GET's and POST's. I was just hoping that servers set to not show errors wouldn't be slowed down (i.e. skip the errors). But if that is the case I shall fix them.
  15. I'm trying to sort out a piece of code, my development web server is set to show all errors. I'm currently getting 50+ 'Undefined Index' errors upon initial load (they all disappear after form submission since all variables are in use). Should I be worried, and add a if(isset(.....)){...} wrapper or do most people just leave it be?
  16. Scripts stopped working, i'm not sure what to do about using the temporary location rather than storing.
  17. I'm modifying a script I built a few months ago to allow someone to upload an attachment via a form and then email it off. It is expected that this form will receive a lot of hits and so it won't be possible to store the attachment in a folder before emailing it out (right away). Problem: If I skip the move_uploaded_file part, and just attach the tmp_name the tmp_name is how I receive it rather than the PDF that it actually is. How can i change the documents name before sending it off, without saving it to a general location. My worry with saving it is, someone uploads their copy and at the exact moment it's supposed to email off, someone somewhere else uploads theirs and it overwrites the first persons and then the email gets sent with the newest persons data. index.php <form action="process.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="file" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> process.php <?php print_r($_FILES); if ($_FILES["file"]["type"] == "text/plain") { if ($_FILES["file"]["error"] > 0) { echo "Return Code: " . $_FILES["file"]["error"] . "<br />"; } else { echo "Upload: " . $_FILES["file"]["name"] . "<br />"; echo "Type: " . $_FILES["file"]["type"] . "<br />"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb<br />"; echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br />"; if (file_exists("upload/" . $_FILES["file"]["name"])) { echo $_FILES["file"]["name"] . " already exists. "; } else { move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $_FILES["file"]["name"]); echo "Stored in: " . "upload/" . $_FILES["file"]["name"]; } } } else { echo "Invalid file"; } ?>
  18. When you click on something such as New, Edit, Cancel, Apply, Save...etc it directs you to a page with the task set to article.<event> and then redirects again to what ever it's supposed to do next. Such as clicking Save it gets article.save and then redirects back to the main article listing. I'm in the process of modifying old code to get it up to standards and I had hoped that I wouldn't have to dig through a ton of code to find all "save", "edit", "new" ...etc and replace them with "article.new" or "articles.publish". By catching this task var during the redirection event i could then split it on the period and use $task as the old system did saving myself a lot of work. But after a lot of deliberation with friends about this, I'm going to just update everything to standards instead of this shortcut, the proper way and be done with it for the future.
  19. var_dump on $task_array is just "NULL" printed. var_dump on $task_array during event is string(14) "article.cancel"
  20. Same issue, I believe that the JRequest::getVar('task') is always populated so the array will always be set at least 1 key. When i echo out [ 0 ] and [ 1 ] nothing prints but isset trips to true and it still produces the error. Stupid me hit Quote instead of Modify...
  21. Same issue, I believe that the JRequest::getVar('task') is always populated so the array will always be set at least 1 key. When i echo out [0] and [1] nothing prints but isset trips to true and it still produces the error.
  22. I'm trying to develop a Joomla plugin for 1.6/1.7 and from what I've read, future versions are supposed to be php E~STRICT compliant. I know that doesn't mean I have to fix this since it is just a notice, but I am curious how one would hide the error. $task_array = explode('.', JRequest::getVar('task')); # Splits article.save $task = $task_array[1]; #This is line 58 I know it happens because $task_array is empty, but how can i wrap that in something to stop this Notice error? I've tried !empty() but that doesn't work.
  23. I have an application that was written back in PHP4 days and has ceased development ever since. PHP 4 is basically gone, i can't get it to install on any of my machines now and what i use on my windows boxes (XAMPP) doesn't include PHP4 anymore. When i set everything up, i get ~50 of these: Deprecated: Assigning the return value of new by reference is deprecated in.... and on every line it looks like: $var =& _____ or $var = &something... yada-yada and removing the & symbol removes the error message. Using editplus i removed all the "=&" and "= &" and just replaced the & with space, i had read on google PHP5 doesn't need it anymore so that should've worked. But as my luck would have it, the server errors out with 500 code until i replace all the &'s back, and then the errors show up yet again. Is there anyway to force php5 to run this program despite having php4 things in it?
  24. You've made me have a "ah your an idiot iarp" moment. For some reason, in my head i was thinking in order to edit items in an array you needed to take the data out and then put it back in with some kinda merge. But just setting it to true will do exactly what i want. The code is part of a contact form i was asked to build some weeks ago, i did build it for them and it works just fine, but after that i had no work to be done and rather then waste time in games, i started building onto what i had done already. As for the error, yes it is a developer error and i could/should just leave it in. I built another script that puts the formdata array together for people, but everything about the array is editable by the developer in the config file, and TBH what good is a contact form without the users email address?
  25. He said the <option> tags in your while loop do not not have a value="name-here" attribute which is needed. You also don't need selected="selected" on the Rim entry because it's the first entry it default gets selected anyways.
×
×
  • 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.