Jump to content

[SOLVED] help plz


jonny5771

Recommended Posts

I am trying to make a flash portal but there is something wrong with my php code. when I go to the flash portal and click on the submitted flash, a blank screen with nothing on appears. Maybe the vew.php or the portal.php page is coded wrong. could ya please take a look?

 

 

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>

Link to comment
https://forums.phpfreaks.com/topic/67790-solved-help-plz/
Share on other sites

taking quick look at view.php you have syntax errors, mainly the echo statements. You have them formatted incorrectly.

 

Change this block:

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 ("')\">");

To:

echo <<<EOF
<font size="4"><strong>Movie Stats</strong></font><br>
<strong>Title: </strong>$title<br><strong>Author: </strong>$author<br>
<a href='mailto:$email'>Email</a> | <a href='$website' target='_blank'>Website</a><br>
<strong>Category: </strong>$category<br><strong>Date Added: </strong>$date<br>
<strong>Views: </strong>$views<br><strong>Score: </strong>$score<br>

<form name='form1' method='post' action='rate.php?id=$flashid'>
<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'>
<p><font size="4"><strong>$title</strong></font></p>
<div align='left'><strong><font style='text-decoration=underline'>Author's Discription:</font></strong><br>
$description

<br><a href="javascript:void(0)" onClick=\"window.open('$userfile','miniwin','toolbar=0,location=0,directories=0,
status=1,menubar=0,scrollbars=0,resizable=0,width=$width, height=$height')\">"
EOF;

Link to comment
https://forums.phpfreaks.com/topic/67790-solved-help-plz/#findComment-340676
Share on other sites

Try this for view.php:

<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']);

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

<strong>Category: </strong><?php echo $category; ?><br><strong>Date Added: </strong><?php echo $date; ?><br>
<strong>Views: </strong><?php echo $views; ?><br><strong>Score: </strong><?php echo $score; ?><br>

<form name="form1" method="post" action="rate.php?id=<?php echo $flashid; ?>"><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">

<p><font size="4"><strong><?php echo $title; ?></strong></font></p>
<div align="left"><strong><font style="text-decoration=underline">Author's Discription:</font></strong><br>
<?php echo $description; ?>
<br><a href="javascript:void(0)" onClick="window.open('<?php echo $userfile; ?>','miniwin','toolbar=0,location=0,directories=0,
status=1,menubar=0,scrollbars=0,resizable=0,width=<?php echo $width; ?>, height=<?php echo $height; ?>')">
<?php

//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>

Re-coded some parts of it.

Link to comment
https://forums.phpfreaks.com/topic/67790-solved-help-plz/#findComment-341388
Share on other sites

sort of worked but still cant view the flash... here is my test website so you may see what happened http://gameworld.byethost13.com/portal.php there are no links so just type e.g. /submit.php... for the other pages.

 

The title, author... comes up as $title, $author instead of the original flash title... and when you make a review it says "The review field was left blank."

 

Link to comment
https://forums.phpfreaks.com/topic/67790-solved-help-plz/#findComment-341587
Share on other sites

Ohh! Sorry did a few errors in my code. Try the following:

view.php

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

if(isset($_GET['id']) && is_numeric($_GET['id']))
{
    $id = $_GET['id'];
}


//selects database row with passed flashid
$query = "SELECT * FROM flash WHERE flashid='$id'";
$result = mysql_query($query);

if(mysql_num_rows($result) == 1)
{
    $row = mysql_fetch_assoc($result);

    //declare variables
    $views       = stripslashes($row['views']);
    $score       = stripslashes($row['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>
<strong>Title: </strong>' . $title . '<br>
<strong>Author: </strong>' . $author . '<br>
<a href="mailto:' . $email . '">Email</a> | <a href="' . $website . '" target="_blank">Website</a><br>
<strong>Category: </strong>' . $category . '<br>"
<strong>Date Added: </strong>' . $date . '<br>
<strong>Views: </strong>' . $views . '<br>
<strong>Score: </strong>' . $score . "<br>\n";

//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=' . $flashid . '">
  <div align="center">
    <select name="rate" id="rate">';

    for($i = 0; $i <= 10; $i++)
    {
        echo "\n      <option value=\"$i\">$i</option>";
    }

    echo "\n" . '    </select>
    <input type="submit" name="Submit" value="Rate">
  </div>
</form>

<p><font size="4"><strong>' . $title . '</strong></font></p>

<div align="left" style="text-decoration:underline;font-weight:bold;">
  Author\'s Discription:<br />' . $description .'
</div>';

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

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

     echo '</a><br /><br />';

     //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 . ")</a>";

     $numreviews++;
     $viewquery = "UPDATE flash SET views = '".$views."' WHERE flashid=$id";
     $viewresult = mysql_query($viewquery);

}
else
{
    echo 'ID not found';
}

?>
</body>
</html>

I also noticed a few syntax errors in portal.php too.

portal.php

<html>
<head>
<title>Flash Portal</title>
</head>
<body>

<h1>15 Most Recent<h1>
<?php
require "dbconnect.php" ;

//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 .' - <a href="view.php?id=' . $flashid . '">' . $title . "</a>\n";

    //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!)';
    }
    elseif ($score > 3.0 && $score <= 7.0)
    {
        echo '(Okay)';
    }
    elseif ($score > 7.0)
    {
        echo '(Excellent!)';
    }

    echo "<br>\n";
}

echo "<h1>15 Most Viewed</h1>\n";

//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 .' - <a href="view.php?id=' . $flashid . '">' . $title . "</a><br />\n";
}

echo "<h1>Top 15</h1>\n";
//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 . ' - <a href="view.php?id=' . $flashid . '">' . $title . "</a>\n";
}

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

Link to comment
https://forums.phpfreaks.com/topic/67790-solved-help-plz/#findComment-342237
Share on other sites

ok were getting closer, it has fixed the title and author prob. and the portal is fixed, in witch I am very grateful :)... but I still cant view the submitted flash when I click "play movie". Maybe this is a problem with my upload.php page. I will post it here so you may see.

 

upload.php

<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 = $_POST['description']; // retrieve from POSTed variables array
}
else
{
$description = $_POST['description'];
}
$name = $_POST['name'];
$title = $_POST['title'];
$width = $_POST['width'];
$height = $_POST['height'];
$category = $_POST['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);

echo("File uploaded sucessfully!");
?>
</body>
</html> 

 

Link to comment
https://forums.phpfreaks.com/topic/67790-solved-help-plz/#findComment-342307
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.