Announcement

Collapse
No announcement yet.

php flash portal. help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • php flash portal. help

    I have been trying to add a flash portal to my site, it isn’t easy. I am stuck on the code that sends all the info from the forum, to the mysql database. So then that info can be displayed next to the flash in the flash portal. If you can spot what I am doing wrong please tell. Here is the php code. :)

    $fileuploaded = 'upload/'.$file_name.'.swf';
    //unlike the file upload script this does not need to be the full path to the directory

    $date = date('F jS, Y'); //gets the date added by simple PHP date function
    $date = addslashes($date); //we must add slashes to everything before entering it into the database

    //add slashes to other variables
    if ($website){$website = addslashes($website);}

    if ($description)
    {
    $description = addslashes($description);
    }
    else
    {
    $description = 'N/A';
    }
    $name = addslashes($name);
    $title = addslashes($title);
    $width = addslashes($width);
    $height = addslashes($height);
    $category = addslashes($category);

    //enter information into database creating a new row
    $query = "insert into flash
    set author='".$name."',
    title='".$title."',
    website='".$website."',
    email='".$email."',
    width='".$width."',
    height='".$height."',
    description='".$description."',
    userfile='".$fileuploaded."',
    category='".$category."',
    date='".$date."'";

    $result = mysql_query($query);

  • #2
    Re: php flash portal. help

    Your insert query is wrong. Insert should look like this

    $query = "INSERT INTO flash (author, title, website, email, width, height, *the rest*) VALUES ('$author', '$title', '$website', '$email', '$width', '*the rest*')";

    just change *the rest* to the rest of the values, sorry im lazy

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

    Comment


    • #3
      Re: php flash portal. help

      I changed the code to this but it’s still not working. Did I enter it in right? Sorry am new to php coding.

      $fileuploaded = 'upload/'.$file_name.'.swf';
      //unlike the file upload script this does not need to be the full path to the directory

      $date = date('F jS, Y'); //gets the date added by simple PHP date function
      $date = addslashes($date); //we must add slashes to everything before entering it into the database

      //add slashes to other variables
      if ($website){$website = addslashes($website);}

      if ($description)
      {
      $description = addslashes($description);
      }
      else
      {
      $description = 'N/A';
      }
      $name = addslashes($name);
      $title = addslashes($title);
      $width = addslashes($width);
      $height = addslashes($height);
      $category = addslashes($category);

      //enter information into database creating a new row
      $query = "INSERT INTO flash (author, title, website, email, width, height, description, userfile, category, date,) VALUES ('$author', '$title', '$website', '$email', '$width', '$height', '$description', '$userfile', '$category', '$date',)";

      $result = mysql_query($query);

      Comment


      • #4
        Re: php flash portal. help

        Did you first perform connection to the database ? If not. it will not work ofcourse. And, delete the "," after date and $date. Anyway, you should be recieving some error message from MySQL. It would help to debug.
        Navaldesign
        Logger Lite: Low Cost, Customizable, multifeatured Login script
        Instant Download Cart: a Powerfull, Customized, in site, DB driven, e-products Cart
        DBTechnosystems.com Forms, Databases, Shopping Carts, Instant Download Carts, Loggin Systems and more....
        Advanced BlueVoda Form Processor : No coding form processor! Just install and use! Now with built in CAPTCHA!

        Comment


        • #5
          Re: php flash portal. help

          yeah I first connected to the database and I tried deleting the "," after date and $date but it's still not working. Though I really appreciate the help, thanks. :)

          Maybe its one of the other pages. I will list all the pages of my site so you may see what could be wrong.


          here is my submit.htm page

          <html>
          <head>
          <title>Submit Flash</title>
          </head>
          <body>
          <p><strong><font size="5">Submit Flash</font></strong></p>
          <p><strong><font size="3">Agreement:</font></strong><br>
          <textarea name="textarea" cols="40" rows="2">Type the user agreement here, however this is optional).</textarea>
          </p>
          <form action="upload.php" method="post" enctype="multipart/form-data" name="uploadform">
          <p><strong><font size="3">Your Name:</font></strong>
          <input name="name" type="text" id="name" size="26" maxlength="26">
          </p>
          <p><strong><font size="3">Your Email:
          <input name="email" type="text" id="email" size="26" maxlength="26">
          </font></strong></p>
          <p><strong><font size="3">Website:
          <input name="website" type="text" id="website" size="26" maxlength="26">(Optional)
          </font></strong></p>
          <p><strong><font size="3">Title:
          <input name="title" type="text" id="title" size="26" maxlength="26">
          </font></strong></p>
          <p><strong><font size="3">Category:
          <!--You may change these values if you want-->
          <select name="category" id="category">
          <option value="">--------Select---------</option>
          <option value="Humor">Humor</option>
          <option value="Violence">Violence</option>
          <option value="Action">Action</option>
          <option value="Music">Music</option>
          <option value="Game/Interactive">Game/Interactive</option>
          <option value="Other">Other</option>
          </select>
          </font></strong></p>
          <p><strong><font size="3">Width:
          <input name="width" type="text" id="width" value="550" size="4" maxlength="4">
          (Default is 550)</font></strong></p>
          <p><strong><font size="3">Height:
          <input name="height" type="text" id="height" value="400" size="4" maxlength="4">
          (Default is 400) </font></strong></p>
          <p><strong><font size="3">Description:<br>
          <textarea name="description" cols="40" rows="5" id="description"></textarea>
          (Optional)
          </font></strong></p>
          <p><strong><font size="3">File (.swf):
          <input type="hidden" name="MAX_FILE_SIZE" value="5000000">
          <input name="userfile" type="file" id="userfile">
          </font></strong></p>
          <p><strong><font size="3">
          <input type="submit" name="Submit" value="Submit">
          </font></strong></p>
          </form>
          <p><strong></strong></p>
          </body>
          </html>



          and here is the code that goes in the MySQL database



          CREATE TABLE flash
          (
          flashid INT(5) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
          title VARCHAR(26) NOT NULL,
          author VARCHAR(26) NOT NULL,
          email VARCHAR(26),
          website VARCHAR(26),
          category VARCHAR(20) NOT NULL,
          width INT(4) UNSIGNED NOT NULL,
          height INT(4) UNSIGNED NOT NULL,
          description TEXT NOT NULL,
          userfile VARCHAR(26) NOT NULL,
          views INT(5) UNSIGNED DEFAULT '0' NOT NULL,
          date VARCHAR(30) NOT NULL,
          score FLOAT(2, 1) DEFAULT '5.0' NOT NULL,
          votes INT(5) UNSIGNED DEFAULT '1' NOT NULL
          );



          and here is the code for the database connect



          <?php
          @ $db = mysql_pconnect('dbhost', 'username', 'password');
          if (!$db)
          {
          echo("Could not connect to database");
          exit;
          }
          mysql_select_db('databasename'); //the name of your database
          ?>


          note: where it says dbhost, username, password, and databasename, i had enterd my info.



          here is my upload.php page



          <html>
          <head>
          <title>Submit Flash</title>
          </head>
          <body>
          <?php


          // $userfile is where file went on webserver
          $userfile = $_FILES['userfile']['tmp_name'];

          // $userfile_name is original file name
          $userfile_name = $_FILES['userfile']['name'];

          // $userfile_size is size in bytes
          $userfile_size = $_FILES['userfile']['size'];

          // $userfile_type is mime type e.g. image/gif
          $userfile_type = $_FILES['userfile']['type'];

          // $userfile_error is any error encountered
          $userfile_error = $_FILES['userfile']['error'];

          if ($userfile_error > 0)
          {
          echo 'Error: ';
          switch ($userfile_error)
          {
          case 1: echo 'File exceeded upload_max_filesize'; break;
          case 2: echo 'File exceeded max_file_size'; break;
          case 3: echo 'File only partially uploaded'; break;
          case 4: echo 'No file uploaded'; break;
          }
          exit;
          }

          if ($userfile_type != 'application/x-shockwave-flash')
          {
          echo 'Error: file must be SWF';
          exit;
          }

          require ("dbconnect.php");
          $query = "select * from flash";
          $result = mysql_query($query);

          //this makes the userfile_name the same as its flashid
          $userfile_name = (mysql_num_rows($result))+1;

          $upfile = 'upload/'.$userfile_name.'.swf';

          if (is_uploaded_file($userfile))
          {
          if (!move_uploaded_file($userfile, $upfile))
          {
          echo 'Error: Could not move file to destination directory';
          exit;
          }
          }
          else
          {
          echo 'Error: Possible file upload attack. Filename: '.$userfile_name;
          exit;
          }

          $fileuploaded = 'upload/'.$file_name.'.swf';
          //unlike the file upload script this does not need to be the full path to the directory

          $date = date('F jS, Y'); //gets the date added by simple PHP date function
          $date = addslashes($date); //we must add slashes to everything before entering it into the database

          //add slashes to other variables
          if ($website){$website = addslashes($website);}

          if ($description)
          {
          $description = addslashes($description);
          }
          else
          {
          $description = 'N/A';
          }
          $name = addslashes($name);
          $title = addslashes($title);
          $width = addslashes($width);
          $height = addslashes($height);
          $category = addslashes($category);

          //enter information into database creating a new row
          $query = "INSERT INTO flash (author, title, website, email, width, height, description, userfile, category, date) VALUES ('$author', '$title', '$website', '$email', '$width', '$height', '$description', '$userfile', '$category', '$date')";

          $result = mysql_query($query);
          echo("File uploaded sucessfully!");
          ?>
          </body>
          </html>


          here is my view.php page




          <html>
          <head>
          <title>View Flash</title>
          </head>
          <body>
          <?php
          require("dbconnect.php");

          /add slashes to flashid (passed via view.php?id=$id)
          $id = addslashes($id);

          //selects database row with passed flashid
          $query = "select * from flash where flashid = $id";
          $result = mysql_query($query);
          $row = mysql_fetch_array($result);

          //declare variables
          $views = stripslashes($row['views']);
          $score = stripslashes($row['score']);
          $score = $score.' / 10';
          $title = stripslashes($row['title']);
          $author = stripslashes($row['author']);
          $email = stripslashes($row['email']);
          $website = stripslashes($row['website']);
          $height = stripslashes($row['height']);
          $width = stripslashes($row['width']);
          $description = stripslashes($row['description']);
          $userfile = stripslashes($row['userfile']);
          $date = stripslashes($row['date']);
          $category = stripslashes($row['category']);
          $flashid = stripslashes($row['flashid']);

          echo("<font size="4"><strong>Movie Stats</strong></font><br>");
          echo ("<strong>Title: </strong>$title<br>");
          echo ("<strong>Author: </strong>$author<br>");
          echo ("<a href='mailto:$email'>Email</a> | <a href='$website' target='_blank'>Website</a><br>");

          echo ("<strong>Category: </strong>$category<br>");
          echo ("<strong>Date Added: </strong>$date<br>");
          echo ("<strong>Views: </strong>$views<br>");
          echo ("<strong>Score: </strong>$score<br>");

          //make rate form so user can rate submission (we will create the rate.php file later)
          echo("<form name='form1' method='post' action='rate.php?id=");");
          echo($flashid);
          echo("'><div align='center'>
          <select name='rate' id='rate'>
          <option value='1'>1</option>
          <option value='2'>2</option>
          <option value='3'>3</option>
          <option value='4'>4</option>
          <option value='5'>5</option>
          <option value='6'>6</option>
          <option value='7'>7</option>
          <option value='8'>8</option>
          <option value='9'>9</option>
          <option value='10'>10</option>
          </select>
          <input type='submit' name='Submit' value='Rate'>");

          echo("<p><font size="4"><strong>$title</strong></font></p>");
          echo("<div align='left'><strong><font style='text-decoration=underline'>Author's Discription:</font></strong><br>");
          echo ($description);

          //echo link that opens movie in new non-resizeable window
          echo("<br>
          <a href=\"javascript:void(0)\" onClick=\"window.open('");
          echo ($userfile);
          echo ("','miniwin','toolbar=0,location=0,directories=0, status=1,menubar=0,scrollbars=0,resizable=0,");
          echo ("width=");
          echo ($width);
          echo (", height=");
          echo ($height);
          echo ("')\">");

          //checks if submission is a movie or a game
          if ($category == 'Game/Interactive')
          {
          echo("Play Game");
          }
          else
          {
          echo("Play Movie");
          }
          echo("</a>");

          //Read/Write reviews link (opens reviews window)
          $query = "select * from flash_reviews where flashid = $id";
          $result = mysql_query($query);
          $numreviews = mysql_num_rows($result);
          echo("<a href=\"javascript:void(0)\" onClick=\"window.open('review.php?id=$id','miniwin ','toolbar=0,location=0,directories=0,status=1,men ubar=0,scrollbars=0,resizable=0,width=470, height=510')\">Write/Read Reviews(");

          //prints number of reviews already written
          echo ($numreviews);
          echo (")</a>");

          $views++;
          $viewquery = "update flash set views = '".$views."' where flashid = $id";
          $viewresult = mysql_query($viewquery);

          ?>
          </body>
          </html>


          And finally here is the portal.php




          <html>
          <head>
          <title>Flash Portal</title>
          </head>
          <body>
          <?php
          require("dbconnect.php");

          echo("<font size='4'><strong>15 Most Recent</strong></font>");
          //displays most recent flash using a while loop
          $query = "SELECT * FROM flash ORDER BY flashid DESC LIMIT 15";
          $result = mysql_query($query);
          $i = 0;
          while ($row = mysql_fetch_array($result))
          {
          //increases printed number for flash by one
          $i++;
          //declare varibles
          $score = stripslashes($row['score']);
          $title = $row['title'];
          $flashid = stripslashes($row['flashid']);

          //print flash submission
          echo($i);
          echo(" - ");
          echo("<a href='view.php?id=");
          echo($flashid);
          echo(">$title</a>");

          //tells if submission is excellent (score higher than 7.0), okay (score between 3.0 and 7.0), or bad (score lower than 3.0)
          if ($score <= 3.0)
          {
          echo("(Bad!)");
          }
          else if ($score > 3.0 && $score <= 7.0)
          {
          echo("(Okay)");
          }
          else if ($score > 7.0)
          {
          echo("(Excellent!)");
          }
          echo("<br>");
          }

          echo("<font size='4'><strong>15 Most Viewed</strong></font>");
          //displays 15 most viewed flash
          $query = "SELECT * FROM flash ORDER BY views DESC LIMIT 15";
          $result = mysql_query($query);
          $i = 0;
          while ($row = mysql_fetch_array($result))
          {
          //increases printed number for flash by one
          $i++;
          //declare varibles
          $score = stripslashes($row['score']);
          $title = $row['title'];
          $flashid = stripslashes($row['flashid']);

          //print flash submission
          echo($i);
          echo(" - ");
          echo("<a href='view.php?id=");
          echo($flashid);
          echo(">$title</a>");
          echo("<br>");
          }

          echo("<font size='4'><strong>Top 15</strong></font>");
          //displays 15 top flash (ordered by highest score)
          $query = "SELECT * FROM flash ORDER BY score DESC LIMIT 15";
          $result = mysql_query($query);
          $i = 0;
          while ($row = mysql_fetch_array($result))
          {
          //increases printed number for flash by one
          $i++;
          //declare varibles
          $score = stripslashes($row['score']);
          $title = $row['title'];
          $flashid = stripslashes($row['flashid']);

          //print flash submission
          echo($i);
          echo(" - ");
          echo("<a href='view.php?id=");
          echo($flashid);
          echo(">$title</a>");
          echo("<br>");
          }

          //finish up page by adding end tags
          ?>
          </body>
          </html>

          Comment

          Working...
          X