Jump to content

wee493

Members
  • Posts

    87
  • Joined

  • Last visited

Everything posted by wee493

  1. I'm wanting to get table results from a database and put them in an array. I've tried using the below code which is a very poor way of doing this and it doesn't work correctly. Any ideas? $sql = mysql_query("SELECT feed_url FROM sc_feeds"); $feed = 'array('; while ($r = mysql_fetch_array($sql)){ $feed .= '"'.$r['feed_url'].'", '; } $feed .= ')'; echo $feed;
  2. Thanks, does it matter that my images are in folders like, http://example.com/uploads/2009/09 ? I currently working on this code, not having any luck
  3. I need to replace all <a href tags linking to an an image because my images are hosted on a different site. For example. I have two links http://example.com/cool.jpg http://example.com/file.pdf Currently I use (Something similar to this, this is just to give you an idea) $link[0] = 'http://example.com/cool.jpg'; $link[1] = 'http://example.com/file.pdf'; str_replace ('http://example.com','http://remotesite.com', $links); I need it to only replace the link for images linking to a picture. My links are not in a array they are in a chunk of text so I don't know how to separate out the link. Does anyone have any ideas?
  4. I have a table similar the the one below. Countryurl United States125 Canada300 Canada125 United States125 Currently I use the query below to get all the distinct countries. SELECT DISTINCT country FROM log WHERE url= '$url' But, I try to count the number of rows WHERE the url = 125. It only does it for the first row. This is the whole script $sql = mysql_query("SELECT DISTINCT country FROM log WHERE url = '$url'"); while ($r = mysql_fetch_array($sql)){ $country = $r['country']; //$sql = mysql_query("SELECT COUNT(country) FROM log WHERE url = '$url' AND country = '$country'"); $sql = mysql_query("SELECT * FROM log WHERE url = '$url' AND country = '$country'"); //$visits = mysql_result($sql, 0); echo $country; echo " - $visits Visits"; echo "<br>"; } Any help would be amazing!
  5. That script is good, but can it change the name of the file you are set to download? I dont see how it would do that
  6. I have an upload script that, well obviously lets you upload files. Once the file is uploaded the name is changed to the date,time,and second the file was uploaded to prevent from duplicate file names. The only thing is that users dont want to download a file called 09072015230.zip (the date is numeric). Is there a way for the server to "rename" the file so the client would download kittycat.zip instead of 09072015230.zip. I dont want the file to actually be renamed, just for the clients computer to download and save it as that.
  7. I have a URL Shorter and I want to prevent users from spamming by clicking on a link over and over again. Every time a link is clicked it is logged into a sql db with a timestamp, referrer, username (if their logged in otherwise its guest), and IP. I want to read the timestamps of their most recent visits to that url and subtract them from each other to get the time in seconds from the last visit. the if the time is under 90 seconds then they are displayed a page that says "Stop Spamming". Here is what i have so far. What I need help in is an sql query that will get the two most recent timestamps FROM log WHERE url = '$url' AND ip = '$ip' I just don't know how to get the two most recent ** Also sorry for any bad coding, I'm 15 and obviously new to PHP ** <?PHP // SQL Query HERE // // This is just incase the SQL Query turns up blank // if ($timestamp2 == '') { $timestamp1 = '1'; $timestamp2 = '100'; } if (($timestamp2 - $timestamp1) <= 90) { echo "Please Stop Spamming!"; } else { // Rest of Script // } ?>
  8. Basically my code is stoping after the while command *Sorry I could not find the edit post button*
  9. I have an array that I'm trying to display from an sql db. The array is displaying fine, but it messes with the html code. <? $user = $session->username; $sql = "SELECT * FROM `url` WHERE `user`='$user' ORDER BY `url`.`id` ASC"; $result = mysql_query($sql); if(mysql_num_rows($result) == '0') { echo "<font color='#000'>You have not created any URL's yet. You can do so from the home screen.</font>"; } while($row = mysql_fetch_array($result) or die(mysql_error())) { $url = stripslashes($row[url]); $dest = stripslashes($row[destination]); echo "<tr bgcolor='#fff'> <td width='200' valign='bottom'> <a href=\"http:\//wiurl.com/$url\">http://wiurl.com/$url</a></td> <td width='200' align='left' valign='bottom'><br>$dest</tr>"; } ?> If i put the closing } from the while command at the very end of the page some of the html is repeated, but if i put it where it is displayed currently the page does not display the html after the php code. you can see the messed up page here http://wiurl.net/myurls.php If you want to see the entire page i have attached it below, <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>WiURL - Make any URL a Wi one</title> <link rel="stylesheet" type="text/css" href="style.css" media="screen" /> </head> <body> <table border="0" align="center"> <tr> <td height="10" bordercolor="#CCCCCC"> </td> </tr> <tr> <td> <div id="wrapper"> <div id="header"> <div id="logo"> <h1><a href="#">WiURL</a></h1> <p>Make any URL a Wi one</p> </div> <!-- end #logo --> <div id="menu"> <ul> <li class="active"><a href="http://wiurl.com">Home</a></li> <li class="active2"><a href="total.php">Top URL's</a></li> <li class="active2"><a href="download.htm">Download</a></li> <li class="active2"><a href="templates/construction.htm">Support</a></li> </ul> </div> <!-- end #menu --> </div> <!-- end #header --> <div id="page"> <div id="content"> <div class="post"> <h1 class="title">Create a WiURL</h1> <table border="0" bgcolor="#FFFFFF" width="400"> <? $user = $session->username; $sql = "SELECT * FROM `url` WHERE `user`='$user' ORDER BY `url`.`id` ASC"; $result = mysql_query($sql); if(mysql_num_rows($result) == '0') { echo "<font color='#000'>You have not created any URL's yet. You can do so from the home screen.</font>"; } while($row = mysql_fetch_array($result) or die(mysql_error())) { $url = stripslashes($row[url]); $dest = stripslashes($row[destination]); echo "<tr bgcolor='#fff'> <td width='200' valign='bottom'> <a href=\"http:\//wiurl.com/$url\">http://wiurl.com/$url</a></td> <td width='200' align='left' valign='bottom'><br>$dest</tr>"; } ?> </table> </div> <br /><br /></div> <!-- end #content --> <div id="sidebar"> <div id="sidebar-bgtop"></div> <div id="sidebar-content"> <div id="sidebar-bgbtm"> <ul> <? include("sidebar.php"); ?> </ul> </div> </div> </div> <!-- end #sidebar --> </div> <!-- end #page --> </div> <div id="footer"> <p>© 2009. Base Design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a>. Other Modifications by <u>Wee493</u></p> </div> </td></tr></table> <!-- end #footer --> </body> </html>
×
×
  • 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.