Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. Thats it. Or you can do it when you echo, up to you: echo nl2br($var);
  2. Okay, the reason for this is that when you create a new line inside the text box, that is a newline character (\n). When you output something to a browser, it is not new line characters which create a new line, but break line tags (<br >) The fix for this: On the output of this data, apply the nl2br() function. It's generally considered better practice to store the data in its raw form, and add in thinks like the <br > tags on the output of the data.
  3. None of the enctype stuff is going to help if your host isn't allowing PHP uploads. My suggestion: move host.
  4. So you want a count of each different maingame? SELECT COUNT(*),maingame FROM tbl GROUP BY maingame
  5. Not at all. Whilst the majority of people using PHP use mySQL as their database, you don't have to. There's plently of alternatives (SQL lite, postgreSQL, MSSQL etc). Indeed, there's no requirement to have a database at all. That said, if you want a quick and easy way to get started with running PHP/mySQL locally, i'd recommend installing wamp. It'll install PHP, mySQL and apache (web server) in a couple of steps. It'll also add in useful tools like phpMyAdmin (web based application that allows you to work with mySQL easily). As for learning, i'd just get started with some tutorials.
  6. Post up what you're trying to do, and im sure someone could point you in the right direction.
  7. What kind of integration are you looking to do? This class here includes some numerical methods: http://www.phpclasses.org/browse/package/2812.html If you were looking for symbolic integration, then i think you'll probably struggle.
  8. The problem is that it is working - it's just also matching the <title> tags. If you were to view the source of the above, you would find the title tags. Nothing is displayed because title tags don't display anything. To grab just the title and not the tags too, use: <?php $url = "http://www.anyurl-anywhere-online.com"; $data = file_get_contents($url); preg_match('/<title>(.*?)<\/title>/',$data, $matches); $title = $matches[1]; print $title; ?> By the way, there's no need to put empty strings before all your variables.
  9. Well, you can create images on the fly with the GD library: www.php.net/gd To make them look like an HTML page would either take a lot of effort to parse the HTML page and determine what it's supposed to like, or it might be possible to use this function: imagegrabwindow() The above function is only supported with a PHP version of 5.2.2 or higher, and a window machine. It should be possible to save the HTML the user generates, then use that function to take a screenshot of it. Finally, you could use the gd library functions to create an image.
  10. By default, sessions also use cookies. A session ID is stored in a cookie, so the server can keep track of which request relates to which session. It is possible to pass the session ID around in the URL. By default, sessions last till the browser is closed. This can be changed, however. And yes, you'll need to use cookies for a remember me feature.
  11. As far as im aware, the database would select the first occuring ID for each artist, so it wouldn't really work. That is, if you ordered by ID, it would be in the order of the first track added to a particular artist; the order wouldn't change if you added a second track to that same artist.
  12. So there's no thumbnails already created? Well, there's not point generating them on the fly each time you browsed the directory, it'd be hideously slow. So your best bet would be to just load the images, and display them as a particular size. That said, you'd ultimiately be better off creating thumbnails of the images at some point. For reading all the images from a folder see: glob() - If all the images have the same extention, or readdir() If they don't.
  13. You'll have to show us how you're using the above. Also, when you post your code, please use tags.
  14. This line: while(list($id,$name,$artist,$count) = mysql_fetch_row($sql4)){ Should read: while(list($id,$name,$artist,$count) = mysql_fetch_row($result)){
  15. Oh, i didn't notice your table name. Because of the dash, you'll need to put backticks around the table name in the query: SELECT id,name,artist,COUNT(*) FROM `cr-mp3` WHERE alpha='".$alpha."' GROUP BY artist
  16. Well, the ftp_put() function takes a local file, and uploads it to an ftp server. The file in question isn't local to the server, it's local to the user's machine. You don't need FTP functions for this. PHP can handle uploads itself. Take a look at the manual page: http://uk.php.net/manual/en/features.file-upload.php There's a full example of an upload form there.
  17. With my method: <?php function checkurl($url){ $ch = curl_init($url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE); curl_setopt($ch,CURLOPT_FAILONERROR,TRUE); if(curl_exec($ch) !== FALSE){ return 'URL ok'; }else{ return 'Could not connect to site'; } } echo checkurl('http://www.google.co.uk'); echo '<br />'; echo checkurl('http://www.madeupurl.com'); ?>
  18. You were mising a comma in your list of fields. Adding a field to the field list also means you need to add it to the list() function. Try: <?php $sql4 = "SELECT id,name,artist,COUNT(*) FROM cr-mp3 WHERE alpha='".$alpha."' GROUP BY artist"; $result = mysql_query($sql4) or die(mysql_error()); //the below is pointless. $sql4 is a string. By doing what you have done below, you would just have the 1st,3rd and 2nd characters of that string.Not sure what you were trying to achieve with it. //$link = $sql4[0]; //$name = $sql4[2]; //$artist = $sql4[1]; while(list($id,$name,$artist,$count) = mysql_fetch_row($sql4)){ if($count > 1){ echo '<a href="artists.php?artist='.$artist.'">'.$artist.' ['.$count.' songs]</a>'; }else{ echo $artist.' - '.$trackname; } echo '<br />'; } ?> See the comment, also.
  19. You could use cURL and check the HTTP response code: <?php $url = 'http://www.google.co.uk'; $ch = curl_init($url); curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE); curl_exec($ch); echo curl_getinfo($ch,CURLINFO_HTTP_CODE); ?> http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
  20. You'll obviously need to change field/table names and add your formatting, but i would do something like this: <?php $sql = "SELECT trackname,artist,COUNT(*) FROM tbl GROUP BY artist"; $result = mysql_query($sql) or die(mysql_error()); while(list($trackname,$artist,$count) = mysql_fetch_row($sql)){ if($count > 1){ echo '<a href="artists.php?artist='.$artist.'">'.$artist.' ['.$count.' songs]</a>'; }else{ echo $artist.' - '.$trackname; } echo '<br />'; } ?>
  21. You shouldn't be placing quotes around the table name. Ether use nothing, or backticks(`) You'll need to use backticks if the table name or field name is a reserved word (see: http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html) - though it's usually better not to name your fields/tables with these words in the first place.
  22. Im afraid I really don't know what you're saying. What is the output you want? You want to display songs in the order newest to oldest but you also want them grouped by artist? That doesn't make a lot of sense to me.
  23. Use the GROUP BY clause: SELECT * FROM tbl GROUP BY artist
  24. What's your database structure? Sounds like a fairly simple join...
×
×
  • 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.