Urgent: Need Script Made...

Pages: 1, 2
free web hosting

Read Latest Entries..: (Post #19) by cragllo on Feb 13 2005, 03:49 PM. (Line Breaks Removed)
I use this script on my site hosted at Trap17 wothoit any problems, my other site is hosted elsewhere, and global vars it turned off for security reasopn, and nothing seems to work...
Read the FIRST post of this Topic. - Express your Opinion! Contribute Knowledge :-).

Open Discussion > CONTRIBUTE > Computers > Programming Languages > PHP Programming

Urgent: Need Script Made...

cragllo
I need a sort of simple content managment script...

So, I need a mySQL database with the following fields:

Field : example of use

ID : 1
Name : Orange Distster
Description : The best
Image : http://sponk......file.png
Location : http://sponk......file.zip

And I need to be able to display this in a tabel
CODE
<table border="1" cellpadding="0" cellspacing="0">
               <tr>
                 <td align="center" valign="top">
<img src="(IMAGE)">
                 </td>
                 <td width="397" align="left" valign="top">
<font size="2" face="Arial"><strong>(NEME)</strong><br>
(DESCRIPTION)<br>
<a href="(LOCATION)">DOWNLOAD</a></font>
                 </td>
               </tr>
</table>

And will display these in order, newest to olders, 5,4,3,2,1...


That sort of thing, you get me? if someone could do this for me, I would be that happiers person in the world...

Thank you,
Craig.

 

 

 


Reply

FaLgoR
<?
$query = mysql_query("SELECT * FROM table ORDER BY id DESC");
?>
<table border="1" cellpadding="0" cellspacing="0">
<?
while($var = mysql_fetch_array($query)){
?>
<tr>
<td align="center" valign="top">
<img src="<?=$var[image]?>">
</td>
<td width="397" align="left" valign="top">
<font size="2" face="Arial"><strong><?=$var[name]?></strong><br>
<?=$var[description]?><br>
<a href="<?=$var[location]?>">DOWNLOAD</a></font>
</td>
</tr>
<?
}
?>
</table>


Try to do it, if its not in the order u want, try to change "DESC" for "ASC".

smile.gif

 

 

 


Reply

cragllo
ok, im kind of new to mySQL, how does it connect to the database? and what fields do I need to put in?


Also, how can I sho how many times it has been downloaded or how many times the link has been clicked?

Reply

FaLgoR
Connecting to database:
$dbhost = 'localhost';
$dbuser = 'user';
$dbpass = 'password';
$dbname = 'name';

mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname);

You will have to add the fields name, image, description... just like we have used above.

Note: I have user vars to define the database info, but its not needed.

If you have any other question, post again and I'll try to help you :)

Reply

cragllo
Ive put it all in and it works fine, other things i wish to know is,

How to dhow how many times the file had been downloaded or the dwnload link clicked... and hoe to display 10 per page...

Reply

FaLgoR
OK, put this code on your page:

<?
$query = mysql_query("SELECT * FROM table ORDER BY id DESC");
?>
<table border="1" cellpadding="0" cellspacing="0">
<?
while($var = mysql_fetch_array($query)){
?>
<tr>
<td align="center" valign="top">
<img src="<?=$var[image]?>">
</td>
<td width="397" align="left" valign="top">
<font size="2" face="Arial"><strong><?=$var[name]?></strong><br>
<?=$var[description]?><br>
<a href="download.php?id=<?=$var[id]?>">DOWNLOAD</a></font>
</td>
</tr>
<?
}
?>
</table>

And now, lets do download.php:

<?
if(!$id)
return;

$query = mysql_query("SELECT * FROM table WHERE id=$id;");
$download = mysql_fetch_array($query);

if(!file_exists($download[location])){
print "Download file not found.";
exit;
}

mysql_query("UPDATE table SET clicks=(clicks+1) WHERE id=$id;");

header("Location: $download[location]");
?>

Don't forget to connect with database and add the column "id" to your database (with auto_increment). If it doesn't work, please post again and i'll look for the problem.

Reply

cragllo
When I click the link to download it shows the error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/cragllo/public_html/download.php on line 15
File not found.


Also Ive added two more fields:
Preview: for large image preview
creator: to show the author

Does that make a difference?

Also I need a page with a form to add new data...

Reply

FaLgoR
QUOTE(cragllo @ Jan 6 2005, 06:03 PM)
When I click the link to download it shows the error:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/cragllo/public_html/download.php on line 15
File not found.
Also Ive added two more fields:
Preview: for large image preview
creator: to show the author

Does that make a difference?

Also I need a page with a form to add new data...
*



Are you sure you have conected to the database on download.php?

Reply

cragllo
My mistake, I fogot to change:

$query = mysql_query("SELECT * FROM templates WHERE id=$id;");


How can I make a form to ad records to the database?



You can see what im doing here: http://sponkindustries.co.uk/templatesfree2.php

Reply

FaLgoR
let's make insert.php (or something else):

<?
if($go){ // if var $go is set
mysql_query("INSERT INTO table(name,description,image,location) VALUES ('$name','$desc','$image','$location') or die (mysql_error());
print "Done!";
exit;
} else { // not really required at this case but...
?>

<form action="insert.php" method="post">
Name: <input type="text" name="name"><br>
Description: <input type="text" name="desc"><br>
Image: <input type="text" name="image"><br>
Location: <input type="text" name="location"><br>
<input type="submit" name="go" value="Submit">
</form>
<?
}
?>

But don't forget to connect this page with the database. I suggest that you make a new page called conection.php with all the details and connections, and put: include("conection.php"); at the top of the pages which requires an connection.

Reply

Latest Entries

cragllo
I use this script on my site hosted at Trap17 wothoit any problems, my other site is hosted elsewhere, and global vars it turned off for security reasopn, and nothing seems to work...

Reply

Deaths Aprentice
QUOTE(FaLgoR @ Jan 7 2005, 09:06 PM)
let's make insert.php (or something else):

<?php
if($go){ // if var $go is set
mysql_query("INSERT INTO table(name,description,image,location) VALUES ('$name','$desc','$image','$location') or die (mysql_error());
echo "Done!";
exit;
} else { // not really required at this case but...
?>

<form action="insert.php" method="post">
Name: <input type="text" name="name"><br>
Description: <input type="text" name="desc"><br>
Image: <input type="text" name="image"><br>
Location: <input type="text" name="location"><br>
<input type="submit" name="go" value="Submit">
</form>
<?php
}
?>

But don't forget to connect this page with the database. I suggest that you make a new page called conection.php with all the details and connections, and put: include("conection.php"); at the top of the pages which requires an connection.
*



My changes are in bold, some of them are not really needed, but this way it's better wink.gif

EDIT: Heh, sorry, thought there was only 1 page ^.^, didn't see the other replys.

PS Have you been trying out with this script, is MySQL down because of this xD?

Reply

bjrn
You can do it without the global vars turned on, just instead of having $id in the code you use $_GET['id'].

If you think it's too bulky just have
$id = $_GET['id'];
somewhere at the top of your code.

Reply

cragllo
Thank you FaLgoR, I may be moving all my sites onto one server soon, to save time and hastle, and so global vars will be turned on then.... Not sure yet tho, may cost too much...

If and when I do, Ill tell you (If you havent already found a solution that is)


Craig.

Reply

FaLgoR
QUOTE(cragllo @ Jan 23 2005, 11:04 AM)
the download page is not working on my sims website...

global vars is turned off, does that effect the download page?

here it is, download.php
CODE
<?
$dbhost = 'localhost';
$dbuser = ''; // removed for this
$dbpass = ''; // removed for this
$dbname = 'toxicsims';

mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname);
?>
<?
if(!$id)
return;

$query = mysql_query("SELECT * FROM objects WHERE id=$id;");
$download = mysql_fetch_array($query);

if(!file_exists($download[location])){
print "File not found.";
exit;
}

mysql_query("UPDATE templates SET clicks=(clicks+1) WHERE id=$id;");

header("Location: $download[location]");
?>


Would anything need to be added, I had some help off my bros m8 to do the insert page. he added the $_POST bits in for me...
*



well man, I think the globals have to be turned on because the page sent an url: download.php?id=1, so, if the globals are turned off it doesn't work. I'll try to found an solution for your problem, and I'll send u another msg if I find it.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.

Pages: 1, 2
Recent Queries:-
  1. ajax php demo download insert record add - 117.70 hr back. (1)
  2. while $var=mysql_fetch_array - 775.47 hr back. (1)
Similar Topics

Keywords : urgent, script, made

  1. How Romantic Are You ?
    what is the most romantic thing you have ever made for the person you (0)
  2. Need Help With Javascript Drag And Drop Script
    Having trouble with javascript drag and drop script. (2)
    hi, i have been trying to create a drag and drop menu for my new website, so that the navigation
    menu can be moved around the site. This is the code i have: CODE <html> <head>
    <title>Test run - Right click menu</title> <script
    type="text/javascript"> function coordinates(event) { if
    (event.button==2)   { var x=event.x; var y=event.y; }
    document.getElementById("element").style.left=x;
    document.getElementById("element").style.top=y;
    document.getElementById("eleme....
  3. Java Script To Hide The Url In Address Bar
    Does any one know about this ? (6)
    Hello friends , just now i came accross a particular type of script which is capable of masking the
    URL which is seen in the Address bar of the webpage , that is by implementing the particular Java
    Script when the user visits a page eg. www.mysite.com , then it is possible for the admin of
    www.mysite.com to mask this site and display some other website in the viewers address bar. I came
    to know that such a script can be written using Java Scripts , Can any one get me the Script ??....
  4. [request] Avatar For Trap17 Users
    Nice one... for my avatar rotator script (0)
    As per the description above, I would like to challenge the GFX people here on the Trap17 to design
    a nice, bright, clear, professional looking 'avatar' for me and other members to use. I
    plan on including it in my Rotator Script, which I think can be found in the Tutorial Section here
    on the Trap17. (If not, I must write that one soon). /laugh.gif" style="vertical-align:middle"
    emoid=":lol:" border="0" alt="laugh.gif" /> I'm thinking that we need to open this up as a
    Competition so all Members can contribute and then the Admins can start a new section in ....
  5. Should Sex Education Be Made Compulsary In Schools?
    (6)
    I had this idea years ago that young secondary school/high school students should be taught about
    sex by their contemporaries. Where a much older student, whom the younger students respected, gave
    them advice and an insight into what to expect as they sexually mature. It evades the whole problem
    of rebellion against authority figures like parents and teachers and replaces it with one of a more
    respectful and more to the point relevant discussion as to sexual health. You would also use it as
    a tool for teaching the older students about social responsibility and it could....
  6. Seeking Help With Javascript
    Need help with drag and drop type script (1)
    What i want to make is a script that has a table, which is a menu for my site, and when you click
    the top of the table you can drag it to another place in the page. This is the code: Test
    run - Right click menu - ©Jack McCrea 2008 <script type="text/javascript"> function
    coordinates(event) { if (event.button==2) { var x=event.x; var y=event.y;
    document.getElementById("element").style.left=x; document.getElementById("element").style.top=y;
    document.getElementById("element").style.visibility="visible"; var oldx=x; var oldy=y; } }
    <script type="....
  7. Browser Compatibility Problem With Firefox - Javascript + Css
    Having trouble making a script work right - any suggestions? (3)
    Hi, Im working on a website, and im trying to make a right-click menu, which opens on right click,
    wherever the cursor is, and closes on mouse out. I wrote the code below, and when i ran it in IE it
    ran fine, just how i wanted it to work. However in firefox, the menu just opened in the top left. im
    presuming this is because it doesnt like my style changing in the javascript. Any ideas, and
    suggestions? If i cant make this work, i will just make it so it works slightly differently when
    viewev in firefox so that it can just open in one place. All ideas appreciated. ....
  8. Internet Explorer - The Worst Standards Compatible Browser Ever Made
    (13)
    I hate that peace of junk web-browser, and I don't know what THE HELL were Microsoft's
    devs thinking when they made it and decided it to be bundled with the OS and not making it nearly
    good enough as other variants. I can say, yes, I understand that a browser needs to be
    incorporated into the OS, otherwise how could a man go and surf the web or download other browser?
    /smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> But I can't
    understand on what crack were the devs when they created IE 4 (and higher browsers, though....
  9. Help Regarding Phpbb2
    URGENT PLEASE ! ! ! ! ! (5)
    Hello Friends, I Need an Urgent help.I had installed a phpbb2 forum onto my website and i was
    having it perfectly alright.But Unfortunately i found that many of the users who have joined are
    because of spam , those spammed users post all pornographic content and so on.The thing which puts
    me down is that inspite of the code verification in the signup page of the forum how come these spam
    enter into my forums ? Moreover now i have ennabled admin approval during registration but still
    even though i dont approve them i see their names in the board and their profiles are av....
  10. Made These Many Months Ago
    (1)
    Border stinks, I know - Back when Samus sigs were the shiz
    http://32-gfx.deviantart.com/art/Space-78421203 - Too large to show, 56K be warned.....
  11. I Made It, But I Don't Like It
    (2)
    This is the first signature I have made in a long, long time so yeah I'm rusty. I don't like
    it myself, what do you think?: Rambo FTW!!....
  12. How To Make Php Newsletter Script
    (3)
    I have seen a post on here somewhere which shows how to make a simple newsletter php script. I
    cvant find it anywhere and I wanted to ask some questions of the author. Does anyone know the one I
    mean? Cheers ....
  13. Php Guest Online Script
    (3)
    make an index.php copy and paste this code CODE <?php $db_host = "localhost";
    $db_user = "root"; $db_pass = ""; $db_name = "test";
    $dbc = mysql_connect($db_host, $db_user, $db_pass); $dbs =
    mysql_select_db($db_name); $tm = time(); $timeout = $tm -
    (30*60);
    if($_SERVER["REMOTE_ADDR"]){$ip=$_SERVER["REMOTE_ADDR
    "];} else{$ip=$_SERVER["HTTP_X_FORWARDED_FOR"];}....
  14. Guessing Php Script
    (2)
    I am looking for: freeware php quess the person in the photo game script....
  15. My 2 Best Sigs I've Ever Made
    (7)
    Here you go, I worked really hard on these to make them right /biggrin.gif"
    style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> In my opinion they are my 2
    best Sorry about same font, I couldn't find a better one LOL....
  16. What If Marijuana Was Legal?
    What would happen? Should it be made legal? (28)
    Recently I did a school report on Marijuana, in my paper I'm supporting the fact that Marijuana
    should be made legal. I thought "some" people would like to read my work, and maybe talk about it
    some. Please, tell me what you think! /wink.gif" style="vertical-align:middle" emoid=";)"
    border="0" alt="wink.gif" /> Also, sorry if there's some typos and misspellings. For I am
    really tired, and this isn't fully done yet. Also, you should know I spend some time comparing
    weed to tobacco, that's all I'll say =) QUOTE Marijuana 1 ou....
  17. Php Downloads Script
    (4)
    I've been looking all over the net for a PHP script which can provide an interface to browse a
    downloads database. The database could be powered by MySQL. If you know a script like this, please
    post it here. Thanks in advance, Ironchicken.....
  18. What Made You Switch To Linux?
    (47)
    I first tried Linux a few years ago, not because I was completely against Windows or anything like
    that, but just because I had some free time on my hands. I started off with Mandrake 9.0 which was
    very user friendly and Windows-like. After reading through a bunch of message boards and learning
    which distros are good for what, I soon realized my current distro was great for Linux noobs. So
    then I decided to try something a little more advanced like Slackware which I knew had a steep
    learning curve. Since then I've been using Slackware as my main OS and couldn't ....
  19. Adsense Earning Is Just Made Easy
    (3)
    Many people have been thinking that just registering with adsense and place the ads on your website
    you will earn money.I know many people thinking them will earn lots of money by just having there
    ads on.I will give you some advice about adsense. You get your adsense approved them when you put
    your ads on your website it is the best the use the 336 x 280 rectangle between your text.Many
    people say its the best adsense format to earn money.Don't forget to melt to ads with your
    template of your blog or website.Its best.Then after that you make some directory promotion....
  20. Very Simple Online Now Script
    This is a very simple online now script. (4)
    Hi all, Its Aldo. anyways, I wont be using the method of pagination, i will just tell you how to
    make a basic online now script. When someone logs in, now take into consideration that the name of
    the username input is username ( First ,create a table in your database saying online now and add 2
    fields to it. id and username CODE id type=integer(INT) , auto increment, length =255
    and username = VARCHAR length=the limit a username should be in your site now from there we take
    off : CODE <?php //logged.php //authentication script //connection scri....
  21. Jsp Or Java Chat Script Like Mig33
    (5)
    so most of you guys know mig33. its a wap application,probaly java.most kindly to be java. does
    anyone have java knowlege or knows where i can get a chat script like mig33? i also know this server
    supports jsp so im planing to use it for my application. i was hosted here last year but moved
    because i found a better host. now im back just to use the jsp on this server. Im planing to run
    chat applictions so if any one wants to help me in my project let me know.....
  22. How Many Rodent Kills Have We Made So Far This Year?
    Not all rodents are bad, consider the hare, but some... (5)
    So, as some of you know, I do a bit if varmint shooting and I don't have to go far. There is a
    little balcony on the third floor of my house which is where I spend much of my time in front of the
    computer unless it just gets too damn hot. Many people who see the balcony think of it as a tree
    stand like a hunter would use to stay up and away from deer (apparently they never look up). I have
    a good view to the garden and in the afternoons I sometimes count as many as four chipmunks in the
    garden harvesting sunflower seeds for the winter. I suppose I should thank them f....
  23. Trap17 Link Exchange Script Introduced
    (28)
    Hi, We have introduced a link Exchange Script at Trap17. http://www.addlivelinks.com/ The
    categories are yet to be setup. It will be done as we receive link requests. Thanks. -OpaQue....
  24. Watermark Your Image With Simple Php Script
    found it on the net (35)
    This script was found on the net http://tips-scripts.com/?tip=watermark#tip B&T's Tips &
    Scripts site. Just in case the site may not show, I will include the code here: List of things
    needed: 1. your image in any format 2. watermark image--in gif format with transparent background 3.
    script below with name (i.e. watermark.php) CODE <?php // this script creates a watermarked
    image from an image file - can be a .jpg .gif or .png file // where watermark.gif is a mostly
    transparent gif image with the watermark - goes in the same directory as this script // ....
  25. Verifying Email Addresses
    Using a simple PHP script (9)
    This simple script will allow you to run some basic checks to make sure that any email address
    entered is actually an email address. There is no guarantee offered that this will stop every single
    fake email address, but it'll provide some protection. Now, the code! First we need to get
    the email address to verify. Here, I get it using POST from an HTML form. CODE <?php //Load
    email address from web form $email = $_POST['email']; Now, we move on
    to our first check. Does the text that has been entered look like it could b....
  26. Delay X Seconds In Flash
    how to action script that (1)
    How do i have to do, to tell a frame to wait x seconds after it continues playing? In Macromedia
    Flash, of course... Like: CODE stop(); "wait  x seconds"; play();
    Thanks....
  27. Guestbook (cgi-script) Problems
    Do u know much bout chmod and cgi-cripts? (5)
    Hi! I'd like to make a guestbook with a cgi-script I found at Lissa Explains it All .
    There were instruction bout how to install this gbook: click here QUOTE Active Guestbook
    Unzip the file, you'll find 4 separate files: guestbook.cgi mail.gif url.gif readme.txt 1.
    Open guestbook.cgi in a plain text editor like notepad. Find out your path to perl from your Web
    host, and change the first line to reflect that. The default setting, #!/usr/bin/perl, usually
    works for most servers. If not, you can try #!/usr/local/bin/perl. Save your changes. ....
  28. Web Surfing- Script Needed
    (2)
    We all know of anonymouse web surfing, Sites like http://anonymouse.ws/cgi-bin/anon-www.cgi Offer
    peope to surf the internet anonymousely, The site has baners and ads showing up and does not support
    all links. Does anyone know what script they use or where i could get one from, What script do they
    use? Also if anyone jnows how to make my own? I really want this as a addon for my site, So all help
    would be appriciated. Thanks, Mbd5882....
  29. [help] Java Script: Window.open
    Works with Firefox, not IE (10)
    CODE <HEAD> var popUpWin=0; function popUpWindow(URLStr) {
     if(popUpWin)  {    if(!popUpWin.closed) popUpWin.close();  }
     popUpWin = open(URLStr, 'GunBound Tactics: Screenshots',
    'width=820,height=550,menubar=no,resizable=yes,scrollbars=yes,toolbar=no,top=90,left=90')
    ;; } </HEAD> <BODY> <a
    href="javascript:popUpWindow('/f11/clipped.php');"><b>Clips&
    #60;/b></a> This is a script for opening a new window. It works ....
  30. Many Php Script Sites
    (16)
    Hi I find many sites has PHP scripts :: http://www.proxy2.de/scripts.php http://www.free-php.net
    http://knubbe.t35.com/ http://www.ngcoders.com/ http://www.oxyscripts.com/
    http://www.phparena.net/ http://www.1phpstreet.com/ http://px.sklar.com/
    http://www.scoznet.com/ http://php.resourceindex.com/ /blink.gif' border='0'
    style='vertical-align:middle' alt='blink.gif' /> ....

    1. Looking for urgent, script, made

*RANDOM STUFF*





*SIMILAR VIDEOS*
Searching Video's for urgent, script, made

*MORE FROM TRAP17.COM*
Similar
How Romantic Are You ? - what is the most romantic thing you have ever made for the person you
Need Help With Javascript Drag And Drop Script - Having trouble with javascript drag and drop script.
Java Script To Hide The Url In Address Bar - Does any one know about this ?
[request] Avatar For Trap17 Users - Nice one... for my avatar rotator script
Should Sex Education Be Made Compulsary In Schools?
Seeking Help With Javascript - Need help with drag and drop type script
Browser Compatibility Problem With Firefox - Javascript + Css - Having trouble making a script work right - any suggestions?
Internet Explorer - The Worst Standards Compatible Browser Ever Made
Help Regarding Phpbb2 - URGENT PLEASE ! ! ! ! !
Made These Many Months Ago
I Made It, But I Don't Like It
How To Make Php Newsletter Script
Php Guest Online Script
Guessing Php Script
My 2 Best Sigs I've Ever Made
What If Marijuana Was Legal? - What would happen? Should it be made legal?
Php Downloads Script
What Made You Switch To Linux?
Adsense Earning Is Just Made Easy
Very Simple Online Now Script - This is a very simple online now script.
Jsp Or Java Chat Script Like Mig33
How Many Rodent Kills Have We Made So Far This Year? - Not all rodents are bad, consider the hare, but some...
Trap17 Link Exchange Script Introduced
Watermark Your Image With Simple Php Script - found it on the net
Verifying Email Addresses - Using a simple PHP script
Delay X Seconds In Flash - how to action script that
Guestbook (cgi-script) Problems - Do u know much bout chmod and cgi-cripts?
Web Surfing- Script Needed
[help] Java Script: Window.open - Works with Firefox, not IE
Many Php Script Sites
advertisement



Urgent: Need Script Made...



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute your information that might help someone here.
Ask your Doubts & Queries to get answers.. "Together, We enlight each other!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE