Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. The problem you're dealing with is that the browser thinks it is dealing with a relative path. If you dont start your link with a domain or a / then it'll append the link to whatever is currently in the url. To prevent this you need to make the link absolute, by adding the / at the start. Example <a href="/Sim1/Sim2/Sim3">Link</a>
  2. You should be referencing billy.swf here, not billy.php <embed src="http://www.isthisabs...music/billy.php" How your swf player works is by sending it a query string of mp3 files to play. Example billy.swf?autoplay=1&f0=file1.mp3&t0=song-title1&f1=file2.mp3&t0=sone-title2&etc.. What billy.php should be doing is to automatically build the query string of mp3 files to play, by looping over all the mp3 files found within a directory. Your code does this but it is messy and relies on an outdated coding method. How I'd code billy.php would be <?php /* --------------CONFIG--------------------------------------------------------------*/ $mp3folder = '/mp3files/'; // playmode // 0 = alphabetically file list // 1 = shuffle file list $playmode = 1; // force first file in shuffle // enter filename of the song you always wants to play first. // eg. $firstfile='mysong.mp3'; // leave blank for total shuffle eg. $firstfile=''; $firstfile = ''; /* ------------CODE---------------------------------------------------------------*/ $baseurl = 'http://'.$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); $basepath = $_SERVER['DOCUMENT_ROOT'] . dirname($_SERVER['PHP_SELF']) . $mp3folder; $mp3url = $baseurl . $mp3folder; $mp3files = array(); // find .mp3 files add to array foreach(glob($basepath . '*.mp3') as $mp3) $mp3files[] = basename($mp3); // make sure array is not empty if (!empty($mp3files)) { if($playmode == 1) shuffle($mp3files); // set the first file to play defined by $firstfile, if it is not empty if(!empty($firstfile) && $mp3files[0] != $firstfile) { // find the file, get its key $key = array_search($firstfile, $mp3files); unset($mp3files[$key]); // remove file from array array_unshift($mp3files, $firstfile); // add file as first item in array $mp3files = array_values($mp3files); // amend array keys } // Build the query string $queryString = 'autoplay=true&total='.count($mp3files).'&'; foreach($mp3files as $i => $mp3file) { $queryString .= "f{$i}=$mp3url$mp3file&"; $queryString .= "t{$i}=$mp3file&"; } $queryString = trim($queryString, '&'); // outout the embed code for the mp3 player echo '<embed src="'.$baseurl.'/billy.swf?'.$queryString.'" quality="high" wmode="transparent" width="200" height="10" name="billy" align="middle" type="application/x-shockwave-flash" />'; } else { // echo error echo '<div style="color:red;font-weight:bold">Cannot find mp3 files in ' . $mp3url . '!</div>'; } You'd call billy.php in your html using <div id='tumblings-player'> <center><div id='playericon'><a href="http://tumblings.net...lr-music-player"><img alt="Tumblr Music Player" src="http://i122.photobucket.com/albums/o260/mhilka/minigifs/minigif01.gif"/></a></div></center> <?php include 'billy.php'; /* generates webplayer html, or displays an error */ ?> <div style="color:#000; background-color:#fff; padding:100px; font-size:10px;"><a href="http://tumblings.net...lr-music-player">Tumblr Music Player</a></div> </div> </div>
  3. Oops, replace the code in reply #28 with $imageListKey = ($key == 'offer') ? 'imageList' : 'images'; // <-- forgot to include this echo '<p><b>Image: </b><img src="'.$item[$key][$imageListKey]['image'][1]['sourceURL'].'" /></p>';
  4. This code is looping over the images stored in the imageList array // display product images echo '<p><b>Images: </b>'; $imageListKey = ($key == 'offer') ? 'imageList' : 'images'; foreach($item[$key][$imageListKey]['image'] as $image) { echo '<img src="'.$image['sourceURL'].'" /> '; } echo '</p>'; If you only want to display one image size, say a 200px x 200px image of the product then replace the above code with echo '<p><b>Image: </b><img src="'.$item[$key][$imageListKey]['image'][1]['sourceURL'].'" /></p>';
  5. That is what my code change does. It sets the Name as the label for the select input. It still sends the id associated with that name when form is submitted. Live Example http://phpfiddle.org/lite/code/c71-1p4 (click the run button, right hand side when page loads)
  6. Better option would be to populate the select field with the users first name, setting the id as the value for that option, eg echo '<form method="POST">Select name to edit: <select name="id">'; $query = $dbh->query('SELECT id, first FROM contacts ORDER BY first ASC'); foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) { // set record id as value, and first name as option label echo '<option value="'.$row['id'].'">'.$row['first'].'</option>'; } echo '</select>'; Now you'd select the the name you want to edit, and then when the form is submitted the name will be updated to whatever you entered into the name field.
  7. htmlentitites should be htmlentities ( entities spelt with two t's not three)
  8. Use str_replace
  9. Umm, almost exactly 6 years ago you posted this question and no one has given you an answer. Time to give up?
  10. Would you be happy for someone to spy on you without you knowing? If you answered no, then why do you think it is acceptable to do it to someone else?
  11. HTML on its own doesn't allow whole rows to be linkable. Instead you'll need to use javascript to provide that functionality. Example with JQuery http://www.electrictoolbox.com/jquey-make-entire-table-row-clickable/
  12. If your server is setup correctly it should serve index.php by default if you go to site.com/ without specifying a file after the domain. But if you're passing a query string to index.php then you cant hide it. Although you could use mod_write, eg RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?x=$1 [L] Will pass anything after site.com to index.php?x=whatever. For example site.com/example will actually call index.php?x=example and ofcourse $_GET['x'] will return example
  13. That should pass the rows id to secondpage provided you do have a column called id in your database, which holds the records id. The code used in secondpage.php should work, however I'd use the following when getting the id $rowId=intval($_GET['id']);
  14. The code I posted was untested. I coded it from looking at array structure you posted. Try the following instead foreach ($json_arr['categories']['category'] as $category) { echo "<b> Link </b>" .$category['categoryURL'] ."<br/><hr /><h2>Products</h2>"; foreach($category['items']['item'] as $item) { // get the sub array key $key = key($item); echo "<p><b>Name: </b> " .$item[$key]['name']. " </p>"; echo "<p><b>Manufacturer: </b>" . (isset($item[$key]['manufacturer']) ? $item[$key]['manufacturer'] : '') . "</p>"; // get item description, // for offer use description key // for product use fullDescription key $descriptionKey = ($key == 'offer') ? 'description' : 'fullDescription'; echo "<p><b>Description</b> " . $item[$key][$descriptionKey] . '</p>'; // display product images echo '<p><b>Images: </b>'; $imageListKey = ($key == 'offer') ? 'imageList' : 'images'; foreach($item[$key][$imageListKey]['image'] as $image) { echo '<img src="'.$image['sourceURL'].'" /> '; } echo '</p>'; // the store logo and name echo '<p><b>Buy From: </b>'; if(isset($item[$key]['store'])) { echo '<img src="'.$item[$key]['store']['logo']['sourceURL'].'" /> ' .$item[$key]['store']['name'] .'</p>'; } echo '<hr />'; } }
  15. Yes that can be done, without seeing the code I can not tell you specifically what and where you need to edit. Hopefully there is a main config file which will allow you to tell the script what image extensions to include for the upload. if there is no config file then you'll need to find the code responsible for the upload and find where it is filtering out what image files can be uploaded, you'll need to modify it so it includes psd images You'll need to use the psdreaderclass I linked to.
  16. Are you wanting to display the actual adobe psd image on a webpage like you can with other image files such as .gif, .png, .jpg files? You cant as psd's are not actual images supported by web browsers, as it is a proprietary image format owned by Adobe. However there are converts which can compile the psd into a image that can be used within a webpage. One such converter I found from a simple google search was http://www.catswhocode.com/blog/php-display-adobe-psd-files-on-a-web-page Maybe try and incorporate that class into your existing PHP script.
  17. The foreach loop is looping over the results of the select query. $image contains the data for the current row (id, path, message, date,... etc) . $image->id will contain the post id you need to use in your delete link foreach($image->results() as $image) { ?> <div id="image-1"> <a href="delete.php?id=<?php echo $image->id; ?>">Delete Post</a><br> <div class="images"> <?php echo '<img src="', $image->path, '">'; ?> </div> </div> <?php }
  18. You most likely have a setting enabled called magic_quotes. You need to call stripslashes to undo its affects. Or if you can disable it completely.
  19. yes with PHP5.4 ereg is deprecated. Instead you need to use preg_replace. When changing ereg_replace to preg_replace you need to add delimiters to your regex patterns. However with the code snippet you posted, it is replacing newlines with paragraph tags you could use str_replace instead $bio = str_replace("\n", "</p><p>", $row["bio"]);
  20. To add a file attachmment you'll need to use the file input field <input type="file" name="attachment" /> Make sure you add enctype="multipart/form-data" attribute to your <form> tag <form method="post" action="My_db_Mailer.php" enctype="multipart/form-data"> Now use $_FILES['attachment'] instead of $_POST['attachment'] Example $mail->AddAttachment($_FILES['attachment']['tmp_name'], $_FILES['attachment']['name']); // attachment
  21. Well obviously you need to define the $post_id variable with the posts id. I do not know what variable that is so I gave you an example. You should know what that variable is if you understand what the code here does $image = DB::getInstance()->query("SELECT * FROM guestbook"); ... foreach($image->results() as $image) { ... }
  22. You are using wrapping quotes around the $_POST vars. Remove '". and ."' from around it . You should use it like $varname = $_POST['fieldname']; // or passing to a function function($_POST['fieldname'])
  23. What is that? What are these tables? Can we see example queries for each table
  24. Are you only want to display the table if they are logged in? You'd wrap the whole table in a if statement, example pseudo code if( user is logged in ) { // display table }
  25. Pass the post id in the url, eg echo '<a href="delete.php?id='. $post_id . '">Delete Post</a>'; Then use $_GET['id'] in delete.php to get the posts id. Example if(isset($_GET['id'])) { $id = intval($_GET['id']); // delete file $get = DB::getInstance()->get('guestbook', array('id', '=', $id)); unlink($get->path); // delete post $delete = DB::getInstance()->delete('guestbook', array('id', '=', $id)); } However this will allow anyone to delete a post. If you only want to allow the person that created the post then you'll need to check for that.
×
×
  • 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.