Jump to content

Miko

Members
  • Posts

    131
  • Joined

  • Last visited

    Never

Everything posted by Miko

  1. Hello, I need to parse some html for validation. Not an entire html page but something like a "string" of html tags, don't know how to say it correct in english. Basically, I have this to parse (for example): <object width="100%" height="81"> <param value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F12483908" name="movie"> <param value="always" name="allowscriptaccess"> <embed width="100%" height="81" type="application/x-shockwave-flash" src="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F12483908" allowscriptaccess="always"> </object> I know it's possible in php, but don't know which function there is for this? Anyone? Thanks!
  2. Hello, i'm trying to replace a br tag. I have this as code for the moment: var br = document.getElementsByName("br"); br.parentNode.replaceChild(document.createElement("p"), br); but I get this error: "br.parentNode is undefined" Someone knows what I'm doing wrong here? Thanks!
  3. Hello, I have to make a JS script that will create the standard popup window for downloading a file (we all know that popup ). The popup window that will propose the download is already done, but now, is there a way to have a callback when the user actually clicks on OK? Thanks!
  4. Miko

    regex

    Hello, I'm working on a regular expression for a window.open() javascript function. This is what the string can have: This is what I already have for the check: window.open\(\'(\s)*((ht|f)tp(s?)://)[\p{L}\p{N}]+[~\p{L}\p{N}\p{Zs}\-_\.@#$%&;:,\?=/\+!]*(\s)*\'\,\''\,\''\);return false; This works for window.open('http://www.google.com','','');return false; But not yet for the other parameters, someone can help me further with this? Thanks!
  5. I did some searching on Google and came up with: http://([\w-]+\.)+[\w-]+(/[\w- ./]*)+\.(?:gif|jpg|jpeg|png|bmp|GIF|JPEG|JPG|PNG|BMP|Gif|Jpg|Jpeg|Png|Bmp) Changed it to: this.src='http://([\w-]+\.)+[\w-]+(/[\w- ./]*)+\.(?:gif|jpg|jpeg|png|bmp|GIF|JPEG|JPG|PNG|BMP|Gif|Jpg|Jpeg|Png|Bmp)'; But it's not working Any ideas?
  6. Well it should first start with a this.src=' the rest will be an url of an image that can have any extension, like in the url. Thanks.
  7. Hello, I don't have much experience with regular expressions so bear with me . I need a regex for an onmouseover function in an image tag. the content will be something like this: Anyone knows? thanks!
  8. Hi, I have in my DB a column with a timestamp as definition. Now I would like to have only the month and year of that column for further use in a form. How can I achieve that? Thanks!
  9. Hi, I have a function that resides in a class, this function deletes a file in a specific folder. This works, the file is deleted but I get the warning that he can't find the file in the folder. So here's the error: And here's the code: Delete function: function remove_mp3_file(){ $target_path = dirname(__FILE__)."/player/songs/"; unlink($target_path.$this->filename); } function that calls the remove function: function remove_xml_item(){ //$this->open_xml_playlist(); $xml = new DOMDocument('1.0', 'UTF-8'); $xml->preserveWhiteSpace = false; $file = dirname(__FILE__)."/player/music.xml"; $xml->load($file); $xpath = new DOMXPath($xml); $query = '//song[title="'.htmlentities($this->title).'" and artist = "'.htmlentities($this->artist).'" ]'; $entries = $xpath->query( $query ); foreach( $entries as $entry ){ $entry->parentNode->removeChild($entry); } $savefile = $xml->save($file); $remove_file = $this->remove_mp3_file(); if( (!$savefile) && (!$remove_file) ){ return false; }elseif( ($savefile) && ($remove_file) ){ return true; } } First I thought that it was I set a variable that calls the delete function and then I use a if statement for this, but it wasn't that. Anyone an idea? Thanks!
  10. Hello, I have made a PHP script that will feed an existing XML file. The file stores song details like, title, name of singer etc ... Now the file structure is like this for the moment: <?xml version="1.0" encoding="UTF-8"?> <music> <song> <title>Without me</title> <artist>Eminem</artist> <url>songs/coreIssues.mp3</url> <image>img/den.jpg</image> <discspeed>11</discspeed> </song></music> But I need it to be: <?xml version="1.0" encoding="UTF-8"?> <music> <song mainTitle="Eminem - Without me"> <title>Without me</title> <artist>Eminem</artist> <url>songs/coreIssues.mp3</url> <image>img/den.jpg</image> <discspeed>11</discspeed> </song></music> I need it to be like that so if I want to delete a song from the list I just check for the element which will have a unique mainTitle and then delete that element with all it's details. Now, I've searched on Google for some solutions but didn't find any yet. Anyone here knows how to do this? Thanks!
  11. Okay, it's working, thanks mate!
  12. ow yeah, .. why didn't I think of that ... thanks
  13. Hi, I can't believe after more then a year I'm stuck with the simplest upload script. Here's my code: <?php if( isset($_POST['upload']) ){ $uploaddir = "uploads/"; $uploadfile = $uploaddir.$_FILES['fileupload']['name']; if( move_uploaded_file($_FILES['fileupload']['tmp_name'], $uploadfile) ){ echo "Upload OK!"; }else{ echo "Upload FAILED!!!"; } }else{ ?> <form action="<?php $_SERVER['PHP_SELF'] ?>" name="upload" method="post"> <input type="file" name="fileupload" /> <input type="submit" name="upload" value="upload" /> </form> <?php } ?> this is the simplest php upload script that you can find, though the least secure one (it's for a local pc project). When I try to upload any file it gets to my else statement. Anyone an idea why? I don't see it Thanks!
  14. never mind, I've entered the wrong filename ... D'oh!
  15. Hello, I'm editing an XML file using PHP, the XML file contains a playlist of songs for a flash mp3 player. Now I'm able to edit the XML file, but I'm not able to save it . Here's my code: $random_speed = mt_rand(1,15); // Discspeed $song_title = /*mysql_real_escape_string($_GET['song_title'])*/ "My First XML Edit"; $song_artist = /*mysql_real_escape_string($_GET['song_artits'])*/ "A great author"; $song_filename = /*basename(mysql_real_escape_string($_GET['song_filename']))*/ "myfirstxmledit.mp3"; /* Open image directory and get a random image name */ $dir = "./img"; /* Scan the directory and put everything in an array */ $files = scandir($dir); /* Count the elements in the array */ $count_array = count($files); /* Pick a random index from the array */ $rand_array = array_rand( $files, 1 ); /* Pick the value of the random index */ $random_image = $files[$rand_array]; /* Loop through array and if element is not equal to "." or ".." then set the random_image variable */ if( ($random_image == "." ) || ($random_image == ".." ) ){ while( ($random_image == "." ) || ($random_image == ".." ) ){ $random_image = $files[$rand_array]; } }elseif( ($random_image != "." ) || ($random_image != ".." ) ){ echo $random_image; } /* Open the music.xml file */ $xml = new DOMDocument('1.0', 'utf-8'); $xml->formatOutput = true; $xml->preserveWhiteSpace = false; $xml->load('music.xml'); /* Begin settin new element to music.xml file */ $newItem = $xml->createElement('song'); $newItem->appendChild($xml->createElement('title', "'$song_title'")); $newItem->appendChild($xml->createElement('artist', "'$song_artist'")); $newItem->appendChild($xml->createElement('url', "songs/'$song_filename'")); $newItem->appendChild($xml->createElement('image', "img/'$random_image'")); $newItem->appendChild($xml->createElement('discspeed', $random_speed)); /* Add the new elements to the xml tag 'song' */ $xml->getElementsByTagName('song')->item(0)->appendChild($newItem); /* Save the xml file */ $xml->save(); I've tried to enter the filename in the last $xml->save() function, didn't work, added the location + filename, didn't work ... Anyone knows what or how do I save the file? Thanks!
  16. Thanks lenstanbera, It didn't work the way you say, but what I've done is when I get the record I take the t_start_timestamp value and store it in a seperate variable, then I update both t_start_timestamp AND t_end_timestamp. Seems that the problem was my hosting server, since this one is in the US and I'm in Belgium the server updated the t_start_timestamp to the local acutal time. After checking the parameters of my table I saw that I've set the t_start_timestamp to 'CURRENT TIME' or something like that ... changed this and problem solved
  17. Hi! To calculate my real time hours worked for/at a client I've made 3scripts, 1 to start the time, 1 to show the running time and 1 for stopping it. The first and last are put into my hosted DB. I'm accessing them through SSH so that I don't need my laptop all the time. Now here's the problem, when I start the time and I look into my DB I see the actual correct time and date (timestamp), but when I execute the script for stopping it the start time changes, so for example I started at 9:00, that time will be changed to for example 11:00 when I stop it... very strange, here are my scripts: start: <?php date_default_timezone_set('Europe/Brussels'); $timestamp = date('Y-m-d H:i:s'); $conn = mysql_connect('server' 'user', 'pw') or die(mysql_error()); mysql_select_db('hystudi_timesheets', $conn) or die(mysql_error()); mysql_query("INSERT INTO timesheet (t_start_timestamp) VALUES ('$timestamp')", $conn) or die(mysql_error()); ?> stop: <?php date_default_timezone_set('Europe/Brussels'); $timestamp = date('Y-m-d H:i:s'); $conn = mysql_connect('server', 'user', 'pw') or die(mysql_error()); mysql_select_db('hystudi_timesheets', $conn) or die(mysql_error()); $records = mysql_query("SELECT id, t_start_timestamp FROM timesheet ORDER BY id DESC LIMIT 1"); while ($row = mysql_fetch_array($records)) { $id = $row['id']; $start_timestamp = date("U", strtotime($row['t_start_timestamp'])); } $duration = (date("U", strtotime($timestamp)) - $start_timestamp) / 3600; // duration mysql_query("UPDATE timesheet SET t_end_timestamp = '$timestamp', t_calculated_time = '".round($duration,2)."' WHERE id = $id", $conn) or die(mysql_error()); ?> Anyone sees what I'm doing wrong here? Or could it be my server? It's a shared host
  18. Miko

    php question

    hot damn it works!! thanks mate!
  19. Miko

    php question

    The design shows me that the headers are only in 2 colors, so if the header has more then 3 words it will still stay the same and have 2 different colors (it's pretty nice though). The main thing that I need is to figger out how to fetch the 'unknown amount' of elements after the first element (after exploding off course).
  20. Hello, I have a 'strange' situtation. I have this string "Who Am I" that will be used as an header (site for a client) but the design shows that the word "Who" and the words "Am I" are in 2 different colors, in HTML this is a quick fix, but in PHP? What I was thinking was explode the string and fetch the first element put it in a var en then concat the 2 others. But what if the title is more then 3 elements after exploding? It needs to be more dynamic, but I don't know how to do it. Does anyone have an idea?
  21. hi! I have here a select statement with a left join: SELECT m.sender_name1, m.sender_id, p.vis FROM `Levensloop`.`peter` p LEFT JOIN `Levensloop`.`MPSAVIS` m ON m.sender_id = p.vis The field m.sender_id contains information like 2300000217, the 217 is a customer number, the field vis contains all the customer numbers but here the customer number is only 217 and not 2300000217. I know that I can achieve the select statement with left join but I don't think I'm doing it right here. Anyone can help me out here? Thanks!
  22. Hi, I'm trying to create a query that will get data from t1 and if not found go search in t2. I have this for the moment: SELECT * FROM tbl1, tbl2 WHERE tbl1.clnr = '$clnr' OR tbl2.clnr = '$clnr' This kinda works but Instead of receiving 1 result I get the same result 100 times. Anyone an idea? thanks
  23. For centering a div you must use: position: relative; margin: 0 auto;
  24. Hello, I'm trying to make an SQL statement that insert data when it isn't found with a SELECT, and this in 1 query I have this for the moment: INSERT INTO checkedimage (quality, date, depot, tour, image_name, year, month, day, name_ok) SELECT * FROM checkedimage WHERE image_name NOT IN (SELECT * FROM checkedimage), VALUES('y', 20091019, 0530, 'T002', '03-RUDI VAN LAER') I'm doing wrong here, but don't know what
×
×
  • 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.