Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: MySQL error

  1. #1
    Cat
    Cat is offline
    Junior Member Cat's Avatar
    Join Date
    Jul 2006
    Location
    Finland
    Posts
    20
    Member #
    13537
    Hello, everyone! I have a PHP/MySQL script that shows how many times a file has been downloaded and it also changes my file.zip to an ID. I moved to another host a few days ago and now I can't run the script on my new site. I'm getting these errors when I try to install the script:

    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/username/public_html/download/downloadpro.php on line 25

    Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/username/public_html/download/downloadpro.php:25) in /home/username/public_html/download/restrict.php on line 3

    Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/username/public_html/download/downloadpro.php:25) in /home/username/public_html/download/restrict.php on line 3


    I used DirectAdmin as my Control Panel before and now I'm using cPanel. My PHP version is 4.4.2 Also, everytime I try to install a new PHP or MySQL script, I get a lot of errors. Do you think it's because of my PHP version? And can anyone help me to fix the errors? Sorry, I'm not very good at PHP/MySQL, I just tried to use a custom script...

    Here's the code for my downloadpro.php file:

    PHP Code:
    <?php
    /***************************************************************************
     *                                DownloadPro 1.x
     *                            -------------------
     *   created:                : Monday, 16th Feb 2004
     *   copyright               : (C) 2004 Blue-Networks / Exploding Panda
     *   email                   : neil@explodingpanda.com
     *   web                     : http://www.explodingpanda.com/
     *
     ***************************************************************************/

    /***************************************************************************
     *
     *   This program is free software; you can redistribute it and/or modify
     *   it under the terms of the GNU General Public License as published by
     *   the Free Software Foundation; either version 2 of the License, or
     *   (at your option) any later version.
     *
     ***************************************************************************/
     
        
    include('db.php');
        
    dbConnect();
        
    $sql "select filename from dlcount";
        
    $result mysql_query($sql);
        
    $rows mysql_num_rows($result);
        
        
    $sql1 "select filecode from dlcount";
        
    $result1 mysql_query($sql1);
        
        
    $sql2 "select totalhits from dlcount";
        
    $result2 mysql_query($sql2);
        
        for (
    $x=0;$x<$rows;$x++) {
        
    $array[$x] = mysql_result($result,$x);
        
    $array1[$x] = mysql_result($result1,$x);
        
    $array2[$x] = mysql_result($result2,$x);
        }
        
    //array is filenames
        //array1 is fileids
        //array2 is totalhits

    include("restrict.php");
    echo(
    '
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>DownloadPro Admin Area ::</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="style.css" rel="stylesheet" type="text/css">
    </head>
    <body>

    <img src="header.gif">
    <table border="0" cellpadding="2" cellspacing="1" bgcolor="#000000">
    <tr bgcolor="#FFFFFF">
    <td width="145"><B>Filename</B></td>
    <td width="100"><B>File ID</B></td>
    <td width="100"><B>Hits</B></td>
    <td width="70"><B>Edit</B></td>
    </tr>'
    );
    for (
    $x=0;$x<$rows;$x++) {
        echo(
    '<tr bgcolor="#FFFFFF">
                <td width="145">'
    .$array[$x].'</td>
                   <td width="100">'
    .$array1[$x].'</td>
                <td width="100">'
    .$array2[$x].'</td>
                   <td width="70"><a href="modify.php?delete='
    .$array1[$x].'">Delete</A> <a href="modify.php?modify='.$array1[$x].'">Modify</A></td>            
               </tr>'
    );
    }
    echo(
    '</table><BR>
    - <a href="modify.php?insert=1">Create New</A>
    <BR>
    - <a href="displaystat.php">Show Full Download Stats</A>
    <BR><BR>
    <a class="dlp" href="Http://www.explodingpanda.com" TARGET="_BLANK">DownloadPro 1.x</A>
    </body>
    </html>
    '
    );

    ?>
    And my restrict.php file:

    PHP Code:
    <?php

    session_start
    ();

    if(!isset(
    $uid)) {
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>

    <head>
    <title>Please Login:</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    </head>
    <BODY>
    <p class="style2"><form method="post" action="<?=$_SERVER['PHP_SELF']?>">
                    <table width="285" border="0" cellpadding="2" cellspacing="1">
                      <tr> 
                        <td width="91"><span class="style3"><font size="2">User 
                          ID:</font></span></td>
                        <td width="187"><span class="style3"><font size="2"> 
                          <input type="text" name="uid" size="10">
                          </font></span></td>
                      </tr>
                      <tr> 
                        <td><span class="style3"><font size="2">Password: 
                          </font></span></td>
                        <td class="style1"><span class="style3"><font size="2"> 
                          <input type="password" name="pwd" size="10">
                          </font></span></td>
                      </tr>
                      <tr> 
                        <td><span class="style3"><font size="1">
                          <input name="Submit" value="Submit" type="submit" id="Submit">
                          </font> </span></td>
                        <td><span class="style3"></span></td>
                      </tr>
                    </table>
                  </form> </p>
                  </body>
                  </html>

    <?php
    exit;
    }

    session_register("uid");
    session_register("pwd");

    $pwd str_replace'$'"$"$pwd);
     
    if ( 
    get_magic_quotes_gpc() )
    {
     
    $pwd stripslashes($pwd);
    }

    $luser strtolower($uid);
    $pwd strtolower($pwd);

    if(
    $luser !== strtolower($scriptuser) or $pwd !== strtolower($scriptpass)) {

      
    session_unregister("uid");  
      
    session_unregister("pwd");
      
      unset(
    $uid);
      unset(
    $pwd);
      
    session_start();
    ?>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Error:</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body>
    Wrong Pass.
    </body>
    </html>
    <?php
      
    exit;
    }
    ?>
    Thanks for reading!

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    First of all, try this script.

    PHP Code:
    <?php
     
    // save me as something.php

        
    $location "localhost";
        
    $username "";
        
    $password "";
        
    $database "";
        
    $conn mysql_connect("$location","$username","$password");

         if (
    $conn
            { 
                echo 
    "Could connect MySQL<br />\n";
            }
         else
            {
                echo 
    "error connecting.";
            }
        
    mysql_select_db($database,$conn) or die ("Could not open database");
    ?>
    Change $username, $password and $database to match your details, these details should be somewhere in your host's cpanel (or similar).

    If you get a "Could connect to mysql" message, then see if you have the appropiate tables.

  4. #3
    Cat
    Cat is offline
    Junior Member Cat's Avatar
    Join Date
    Jul 2006
    Location
    Finland
    Posts
    20
    Member #
    13537
    Thanks! It said Could connect MySQL. And what do you mean by appropiate tables? Sorry, as I said before, I'm bad at PHP.

  5. #4
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    What I mean is, do you have a table called dlcount on that particular database?

    And does that table have fields called filename, filecode and totalhits?

  6. #5
    Cat
    Cat is offline
    Junior Member Cat's Avatar
    Join Date
    Jul 2006
    Location
    Finland
    Posts
    20
    Member #
    13537
    Nope, it doesn't! I just checked my PHPMyAdmin and it doesn't! Cos when I installed the script it said nothing about adding tables to MySQL database. It only said that I need to enter my database, username and password and run the script. It should create the tables automatically. But the tables aren't there!

  7. #6
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    In that case you have some options/to do list.

    1: Check db.php - it may be that this file tries to create a table
    2: If 1 does not happen, try and create the table yourself, which will not be too hard, as long as you know all the fields the table needs
    3: Or go to the creators of the script and ask for the query to create the table

    IMO, step 2 is your best bet.

  8. #7
    Cat
    Cat is offline
    Junior Member Cat's Avatar
    Join Date
    Jul 2006
    Location
    Finland
    Posts
    20
    Member #
    13537
    Thanks, but I don't know which tables... I can't see them in any files... I tried contact the guy who created the script, but he didn't reply. And his forums are inactive.

  9. #8
    Cat
    Cat is offline
    Junior Member Cat's Avatar
    Join Date
    Jul 2006
    Location
    Finland
    Posts
    20
    Member #
    13537
    Sorry for double posting, but I downloaded my old MySQL backup and uploaded it to my new MySQL database and everything works fine, BUT it won't accept my username and password, the page just reloads and nothing happens. I wonder if someone could remove the login and password from the script, I could post the files here. Or maybe someone can tell me why it won't accept my username and password? Please, please, please I'm stuck!!!!! :'(

  10. #9
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Hey ahain.

    I am presuming this username and password is stored in a database table?

    In which case, although the table exists, the row which matches the data you attempt to log on with, does not exist in that table.

    So, you will need to go into phpMyAdmin and add a row with the details you enter.

    However, your password is probably encrypted, so you may have to find a password generator for the type of encrpytion that your script uses.

    Most likely md5 or sha1

    Here is a md5 password generator - http://www.trilug.org/~jeremy/md5.php

    You would enter your password into that and it would give you the md5 version, then you would insert a new row with your username and the password.

  11. #10
    Cat
    Cat is offline
    Junior Member Cat's Avatar
    Join Date
    Jul 2006
    Location
    Finland
    Posts
    20
    Member #
    13537
    Thanks so much for your reply!!! But, I don't even know how to create a row and where. I have 2 tables - dlcount and dlstats, so what do I do next? Sorry for the stupid questions, I know I'm annoying, cos you guys are profs and I'm just a beginner... :ermm:


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:04 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com