Jump to content

akphidelt2007

Members
  • Posts

    174
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by akphidelt2007

  1. You can add the variable name to the function... Like function any_name($example1,'example1') {}
  2. No, it's per the documentation. Isset simply checks to see if the key/variable exists regardless of the value. You can use... if(isset($_POST['message']) && !$_POST['message']) This would indicate the key/variable exists but the value is empty, blank, 0, false, etc...
  3. I have never had a problem with mod_rewrite preventing GET from being a suitable solution for what you are doing. The other solution is to use the db and set up a table that handles, like the user_id and some flag that says they need a message. But that seems a little over the top for something that should be very simple.
  4. You have to send some kind of trigger for it to recognize a success. And basically your options are GET variables, SESSIONS, redirecting them to a different script, or javascript/ajax. Why are you against using the "success=1" option?
  5. That's on the javascript side. You'd have to figure out what triggers the calendar and why is the trigger only recognizing the first input.
  6. Oh, now I see it. You notice the ) isn't showing up at the end of the string? Add the closing parentheses to the VALUES part of the query and it should work.
  7. So what debugging did you try to figure out why? When you do print_r($title_season) what does it show you?
  8. Whenever you have query problems like this... echo out the query for debugging... I'm willing to bet you will see what your problem is. One of the values might be containing a character that is breaking the query. echo "INSERT INTO shopping_cart (cart_identifier, product_id, product_title, product_qty, product_price, sdate) VALUES ('". mysql_real_escape_string($_SESSION['cid']) . "', '$product_id', '{$products['product_title']}', '$product_qty', '{$products[product_price]}', '$sdate'")";
  9. Sizeof($all_info) will always be 5 because you are creating the array with 5 other arrays. Do sizeof($title_season) and don't worry about the $all_info
  10. Getting the contents part is easy, it's the parsing that takes some time. This was for mlb. It worked perfectly for me, but this was two years ago... and I know there's probably a lot of efficiencies you can add to it. But for time purposes I'll just post the simple code. This was to get individual game data for each game. //plug in a date here that you want to get the info for or to start your loop for tons of dates $date = '2013-05-01'; $unix = strtotime($date) $espnDate = date('Ymd',$unix); $url = 'http://scores.espn.go.com/mlb/scoreboard?date='.$espnDate; //here's how easy it is to get the file $handle = file_get_contents($url); $str = htmlentities($handle); //extract the game ids from the game date $pattern = '/(\d*)-gameDetails/'; preg_match_all($pattern, $str, $gameIDs); //now you have the divs that contain each of the games and you just loop through them and then go through the same process foreach($gameIDs[1] as $id) { $url = 'http://scores.espn.go.com/mlb/boxscore?gameId='.$id; $handle = file_get_contents($url); $str = htmlentities($handle); //now you have a mess of regex to parse the actual html to break up the actual data and store in a database }
  11. This is a pretty complex process and I'm pretty certain no one on this forum is going to type it up unless they already have it available. I would just google... Parse Address in PHP. I know Google has an API that is as robust as it gets for parsing address. There's also this https://gist.github.com/Jonathonbyrd/536049
  12. You can get it by the error message. 4 means that no file was submitted. So if($_FILES['myfile']['error']==4) { echo 'No file has been submitted'; } You can view a list of the error types here... http://php.net/manual/en/features.file-upload.errors.php
  13. It's actually much easier than it seems. Just look up file_get_contents. The only thing you will have to know is regex and how to manipulate the url to get the correct contents. Like I did a project for some guys where I scraped all of ESPN's baseball data for the past decade and that was simply just changing the date on the URL and parsing ESPN's structure.
  14. To keep a modal open you would have to prevent the default form submit behavior and submit the form via another ajax call and handle the submittal yourself.
  15. Happens to the best of us,
  16. Put quotation marks around $address
  17. I'm glad you found a solution, but if that works... the previous foreach() loop solution should work also.
  18. Well what do you think the problem is? When you print out $answers and $myArray are you getting the arrays that you think you are supposed to be getting? If that's the case, then is $myArray holding special characters? I see you do $myArray_trimmed = array_map('trim', $myArray); But then you don't use $myArray_trimmed, you go back to using $myArray.
  19. You really don't need to send the array to get_link. Just return the url from get_link in to an array in get_host. for($i=1; $i <= $rows_affected; $i++) { $row2 = $stm->fetch(PDO::FETCH_ASSOC); $url=$row2['link1']; //don't need to send $array $array[] = get_Link($db,$url,$i,$rows_affected); } //then once this loop is done you can send the array to the player function player($db,$array) Just have to make sure you return the url from the get_link function
  20. You are sending an empty array to get_Link every time and just adding the $pos to it. So each time the array will just have one value in it. When you say you see 3 values, I don't see how that is possible with the code you have set up. I'm willing to bet what you are seeing is the array being dumped 3 times and you have mistaken those dumps for one array. Then when it gets to the last condition it's still just showing one value.
  21. substr_replace does not change the array. You have to store it in a variable or include it in the die statement So when you say die($progeny[$key*$x+$x]);... it is still going to contain the same value that it was before substr_replace. Do... $replace = substr_replace($progeny[$key*$x+$x],$replacement, $letter, 1); die($replace);
  22. I would create an array by category with the scores. Sort of like this $scores = Array('Assignment'=>Array(),'Exam'=>Array(),'Final Project'=>Array()); foreach($_POST['categories'] as $index => $category) { $scores[$category][] = $_POST['scores'][$index]; } //now you will have an array like //$scores['Assignment'] = Array('score1','score2','score3') //loop through to get the totals foreach($scores as $cat => $array) { $count = count($array); $sumOfScores = array_sum($array); $average = $count > 0 ? $sumOfScores/$count : 0; echo "Category: $cat has $count scores and an average score of $average<br>"; }
  23. When using the GET method the form creates the query string in the url through it's inputs. So the query string in your action gets erased. You can create a hidden input field and assign the id value to it. Sort of like <form method="get" action="update_win.php"> <input type="hidden" value="'.$id.'" name="id"> <input type="submit" value="add win"/>
  24. You need quotes around STORE_ADDRESS other wise it is using the STORE_ADDRESS constant value to check whether it is defined. So it should be defined('STORE_ADDRESS')
  25. Wait a second, I see what you are doing... you have the field names like RMAD1... RMAD2... RMAD1000? If that's the case then you really need to change the column or sort it on the PHP side by extracting the integer.
×
×
  • 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.