0
<? ob_start(); ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  <title>Guitar Wars - Add Your High Score</title> 
  <link rel="stylesheet" type="text/css" href="style.css" /> 
</head> 
<body> 
  <h2>Guitar Wars - Add Your High Score</h2> 
 
<?php 
 
  
  require_once('appvars.php'); 
  require_once('connectvars.php'); 
 
  if (isset($_POST['submit'])) { 
    // Grab the score data from the POST 
    $name = $_POST['name']; 
    $score = $_POST['score']; 
    $screenshot = $_FILES['screenshot']['name']; 
    $screenshot_type = $_FILES['screenshot']['type']; 
    $screenshot_size = $_FILES['screenshot']['size'];  
 
    if (!empty($name) && !empty($score) && !empty($screenshot)) { 
      if ((($screenshot_type == 'image/gif') || ($screenshot_type == 'image/jpeg') || ($screenshot_type == 'image/pjpeg') || ($screenshot_type == 'image/png')) 
        && ($screenshot_size > 0) && ($screenshot_size <= GW_MAXFILESIZE)) { 
        if ($_FILES['screenshot']['error'] == 0) { 
 
          // Move the file to the target upload folder 
          $target = GW_UPLOADPATH . $screenshot; 
          if (move_uploaded_file($_FILES['screenshot']['tmp_name'], $target)) { 
 
            // Connect to the database 
//            $cxn = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);if (!$cxn) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_select_db(alpha); 
 
 
            // Connect to the database 
            $cxn = mysql_connect('xxx.powwebmysql.com', 'yyy', 'zzz'); if (!$cxn) { die('Could not connect: ' . mysql_error()); } echo 'Connected successfully'; mysql_select_db(alpha); 
             
 
 
            // Write the data to the database 
            $sql = "INSERT INTO giutarwars VALUES (0, NOW(), '$name', '$score', '$screenshot')"; 
            mysql_query($sql, $cxn); 
            $result = mysql_query($sql,$cxn) 
               or die("Couldn't execute ? query: " . mysql_error());  
 
  
 
 
            // Confirm success with the user 
            echo '<p>Thanks for adding your new high score! It will be reviewed and added to the high score list as soon as possible.</p>'; 
            echo '<p><strong>Name:</strong> ' . $name . '<br />'; 
            echo '<strong>Score:</strong> ' . $score . '<br />'; 
//61 
 
            //my improv script 
            echo "<strong>target 1:</strong> ' . $target . '<br />"; 
            echo "<strong>screenshot 2:</strong> ' . $screenshot . '<br />"; 
            echo "<strong>gw_uploadpath 3:</strong>".GW_UPLOADPATH." <br />"; 
            echo "<strong>gw_uploadpath with screenshot 4:</strong><img src=GW_UPLOADPATH". $screenshot."><br />"; 
            echo "<strong>images with gif 5:</strong><img src=images".$screenshot."><br />"; 
             
            //end of improv 
 
           //back to proper script 
           // echo '<img src="' . GW_UPLOADPATH . $screenshot . '" alt="high Score image" /></p>'; 
            echo '<p><a href="index.php">&lt;&lt; Back to high scores</a></p>'; 
 
            // Clear the score data to clear the form 
            $name = ""; 
            $score = ""; 
            $screenshot = ""; 
 
            mysql_close($cxn); 
          } 
          else { 
            echo '<p class="error">Sorry, there was a problem uploading your screen shot image.</p>'; 
          } 
        } 
      } 
      else { 
        echo '<p class="error">The screen shot must be a GIF, JPEG, or PNG image file no greater than ' . (GW_MAXFILESIZE / 1024) . ' KB in size.</p>'; 
      } 
 
      // Try to delete the temporary screen shot image file 
      @unlink($_FILES['screenshot']['tmp_name']); 
    } 
    else { 
      echo '<p class="error">Please enter all of the information to add your high score.</p>'; 
    } 
  } 
?> 
 
  <hr /> 
  <form enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> 
    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo GW_MAXFILESIZE; ?>" /> 
 
    <label for="name">Name:</label> 
    <input type="text" id="name" name="name" value="<?php if (!empty($name)) echo $name; ?>" /><br /> 
 
    <label for="score">Score:</label> 
    <input type="text" id="score" name="score" value="<?php if (!empty($score)) echo $score; ?>" /><br /> 
 
    <label for="screenshot">Screen shot:</label> 
    <input type="file" id="screenshot" name="screenshot" /> 
    <hr /> 


 
    <input type="submit" value="Add" name="submit" /> 
  </form> 
</body>  
</html> 
<? ob_flush(); ?>

can anyone tell me why my pics dont display, when i echo pathways everything seems to be in order, when i click on pix in images folder it displays....help

3
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by ronysios
0

I don't believe it will output the GW_UPLOADPATH constant when it is in quotes on line 64.

echo "<strong>gw_uploadpath with screenshot 4:</strong><img src=GW_UPLOADPATH". $screenshot."><br />";

Should be:

echo '<strong>gw_uploadpath with screenshot 4:</strong><img src="'.GW_UPLOADPATH.$screenshot.'"><br />';

Edited by effu: n/a

0

I don't believe it will output the GW_UPLOADPATH constant when it is in quotes on line 64.

echo "<strong>gw_uploadpath with screenshot 4:</strong><img src=GW_UPLOADPATH". $screenshot."><br />";

Should be:

echo '<strong>gw_uploadpath with screenshot 4:</strong><img src="'.GW_UPLOADPATH.$screenshot.'"><br />';

i made the changes..still no pics...can this be a php ini or permissions issue?...the code is lifted directly from a php book i have...i am completely miffed on this...thanks

0

i made the changes..still no pics...can this be a php ini or permissions issue?...the code is lifted directly from a php book i have...i am completely miffed on this...thanks

if i relocate the pic within the same folder as the php, the picture displays...when the picture is located in a folder for just images, the picture will not display...

0

just spit balling here but does GW_UPLOADPATH include the new directory? for example the file your pictures are in?

And i would do it like

echo "<strong>gw_uploadpath with screenshot 4:</strong><img src='.GW_UPLOADPATH.$screenshot.'><br />";

cause i'm also having a kind of similar problem in my thread.../threads/388028

0

just spit balling here but does GW_UPLOADPATH include the new directory? for example the file your pictures are in?

And i would do it like

echo "<strong>gw_uploadpath with screenshot 4:</strong><img src='.GW_UPLOADPATH.$screenshot.'><br />";

cause i'm also having a kind of similar problem in my thread.../threads/388028

this is my appvars..hope that helps
<?php
// Define application constants
define('GW_UPLOADPATH', $_SERVER . "/images/");
define('GW_MAXFILESIZE', 32768); // 32 KB
?>

by the way, if i locate my pictures within the same folder as my script, they appear..go figure

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.