-
Posts
15,229 -
Joined
-
Last visited
-
Days Won
427
Everything posted by requinix
-
Because you named the input "background" and not "color"?
-
Yup. Pick another variable name and you're good to go.
-
I was wondering what was going on... Now that I have successfully infiltrated the staff, on to my real mission...
-
What's the rest of the code? Might you be overwriting $input or $file inside the loop?
-
How do I form XML from bash command in PHP script?
requinix replied to jason404's topic in PHP Coding Help
Saves you a bit of code: rather than add stuff to $paths and then loop over it later, forget that second loop and just do whatever you need with the individual values the moment you get them. -
As you've highlighted, you're using mysqli_connect() in one place and mysql_* functions in the rest. Which means the default username/password combination is valid to connect to your database (since the mysql_* functions did that automatically since you tried to use them without connecting first) and you shouldn't let that happen.
-
How do I form XML from bash command in PHP script?
requinix replied to jason404's topic in PHP Coding Help
That stuff is the replacement for the `find` command - done entirely in PHP code. After it is done you'll have an array of absolute $paths to all the required files. You can actually do away with the $paths variable entirely: 1. Start the XML with the 2. Go with the above code up until it adds $path to the $paths array 3. Instead of that, add $path to the XML in a . Note that $path has the whole absolute path (I think) so if you only want the path starting with /wp-content/ you'll need to get that 4. Use the rest of the code 5. Finish the XML -
Can you post your real code? The full and complete version that can actually run?
-
JSON, Commands out of sync; you can't run this command now
requinix replied to Joak's topic in PHP Coding Help
Without downloading and looking at your code I'm going to say If you use unbuffered queries, with PDO or mysqli or whatever, then you have to completely read one query's results before you can run another. In rough order of preference your solutions are: 1. Use JOINs to get all the data you need at once without having to issue queries inside loops. A little bit more work but gives much better performance. 2. Use buffered queries. The alternative in case you can't get #1 to work. (I say "the alternative" because #3 is so bad you shouldn't even consider it.) 3. Keep the unbuffered queries but read out all the data into a temporary array and loop over that. Also known as "doing buffered queries the wrong way". -
And that's literally a caret and an at-sign? You're not, like, viewing this from a terminal window, right?
-
Then it could very well be caching. Likely by the browser, which means your site is sending some sort of response headers telling the browser to do caching. Can you see what the headers are? (If you're not sure how, no offense but it'll be easier for everyone if you Google it.) Relevant headers include Cache-Control, Pragma, Expires, and Last-Modified, and while you're there try to see if your browser sends headers such as If-Modified-Since or If-None-Match.
-
Are you sure you didn't do the SELECT before making the changes? Also, Try to avoid deleting data whenever you can. It'll help you in the long term when you're able to look at data and not have holes because you permanently deleted something that was useful to know.Mark the player as "deleted", then modify your selectplayers() and other similar functions to not return players that have been marked as such.
-
Where's the "Dislike This" button? We need one.
-
Your PHP errors are probably being written somewhere else then. DreamHost? Don't use that AddHandler/FCGIWrapper thing and just name your file with .php instead. Then try your script and, assuming it fails again, check your error log once more.
-
What's the value of result? Maybe it's a complete URL and not just the identifier?
-
Looks like it should be an array and then you can .push the URLs or whatever into it. var songs = []; songs.push(result); What does "insert" mean? The .push you have down below? Copy that. ytplayer_playlist.push(result);And now the songs variable looks extra because you're inserting directly into the ytplayer thing? Or do you need it yourself somewhere?
-
Have you checked your server error logs? What you've described sounds like PHP stopped executing in the middle of the code, which could mean a syntax error or that there's something the form builder requires that you don't have set up yet.
-
Is it just me or is it that the amount and price vary based on the flavor? Table 1 for the shake by itself, and table 2 for the flavor, amount, and price - and a foreign key to the shake. products id | whatever ---+-------- 1 | shake 1 2 | shake 2 flavors? or maybe product variants? id | amount | price | flavor | product ---+--------+-------+------------+-------- 1 | 500 | 26,50 | banana | 1 2 | 500 | 26,50 | chocolate | 1 3 | 750 | 28,90 | strawberry | 2 4 | 750 | 28,90 | mango | 2 5 | 750 | 28,90 | vanilla | 2
-
loadmore.php is returning HTML - probably just by outputting it like normal. Instead you can use output buffering to capture the HTML, stick it into an array, put the latest ID/date in the array as well, then output the JSON-encoded array. A minimal example would be ob_start(); // whatever you to do generate the HTML $html = ob_end_clean(); $array = array( "id" => $latest_id_from_the_query, "html" => $html ); header("Content-Type: application/json"); echo json_encode($array);Now for the Javascript. var latest_id_from_the_ajax = <?php echo $id; ?>;That happens either globally or directly inside the ready(...) function; further inside the code won't work as it gets executed repeatedly later and you'll just end up overwriting whatever value you got dynamically with the $id. url: "loadmore.php?lastid=" + latest_id_from_the_ajax, success: function(data){ if(data){ latest_id_from_the_ajax = data.id; $(".main_page").append(data.html); $('.load_more').html('Load More'); }else{ $('.load_more').replaceWith('<center>No more posts to show.</center>'); } }The "html" variable there previously wasn't representing just HTML anymore but an object (with the values you had in your array in the PHP). [edit] Don't call it "latest_id_from_the_ajax", of course. Pick a better name than that
-
Make your AJAX return not just HTML but JSON that includes the HTML. Also include in that JSON the latest ID returned. It'll look something like {"latest":123,"html":"whatever it returns now"}Track that "latest" ID somewhere and stick the "html" into the main_page. When they click the Load More button again you can stick that ID in the URL you request. Remember to set the default value of that latest ID with the very same <?php echo $id; ?> thing you were considering using (though it'll be in a slightly different place). Word of advice: don't use the ID to sort items. Use an actual date field. Then make sure you update all the stuff to not use an ID but the latest date value instead. (Pretty much the exact same code, just using a different column for the value.) Oh, and addslashes() is not safe. Use mysql_real_escape_string. Even better would be to stop using the mysql extension and its mysql_* functions and to switch to PDO or mysqli instead.
-
You can't put HTML in the middle of PHP code. Use <?php to switch from HTML to PHP mode, then ?> to switch back. <?php if($_SESSION['uid'] == 'X') { ?> html and some <?php code and ?> more html <?php } else { ?> more html and <?php code and ?> stuff <?php } ?>
-
$cTemp is the variable holding the Celsius value. You can round it in two places: 1. When you calculate it 2. When you output it #2 is the best choice: leave the math be as exact as possible and make it only show the one decimal place. That idea of not modifying a value early on and instead waiting until you need to do so (and to do it without permanently modifying the original value) is a good habit to get into as it will help you later with other concepts. Instead of outputting $cTemp, output the result of the round() function; "$val" is the value and "$precision" is the number of decimal places to round to. round($cTemp, 1)