php problem

Status
Not open for further replies.

SyncViews

New Member
Messages
37
Reaction score
0
Points
0
For some reason it just seems to get empty strings from the data base. I have no idea if it's because of my data base or an error in my code though :(

The php code:
Code:
<html>
<?php 
    $con = mysql_connect("localhost:3306","syncview_site","*yeah the pass is set but i'm not telling:)*");
    if (!$con)
    {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("site", $con);
    
    $data = mysql_query("SELECT * FROM files
    WHERE Index='0'");
?>
<head>
 <title>
  <?php echo $data['Name']; ?>
 </title>
</head>
<body bgcolor="#cccccc">

<h2><?php echo $data['Name']; ?></h2>

<?php $data['File_Decription'] ?>
<br><br>
<table>
 <tr><td>File Size:        </td><td>15kb</td></tr>
 <tr><td>File Name:        </td><td><?php echo $data['File_Name']; ?></td></tr>
 <tr><td>Last Updated:    </td><td>24/11/07</td></tr>
</table>
<a href="./images/explosion_1a.png"><img border="0" src="./images/explosion_1a.png" width="400" height="300"></a>
<a href="./images/explosion_1b.png"><img border="0" src="./images/explosion_1b.png" width="400" height="300"></a>
<h2><a href="<?php echo $data['File_Name']; ?>">PRIMARY DOWNLOAD</a></h2>
<?php include("../main_footer.htm"); ?>

</body>
</html>

what i got from exporting the data base (I hope this is whats needed to see if it's set up correcdtly)
Code:
-- phpMyAdmin SQL Dump
-- version 2.10.0.2
-- http://www.phpmyadmin.net
-- 
-- Host: localhost
-- Generation Time: Nov 27, 2007 at 04:35 PM
-- Server version: 4.1.22
-- PHP Version: 4.4.4

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

-- 
-- Database: `syncview_site`
-- 

-- --------------------------------------------------------

-- 
-- Table structure for table `files`
-- 

CREATE TABLE `files` (
  `Index` int(10) unsigned NOT NULL default '0',
  `Name` varchar(64) NOT NULL default '',
  `File_Name` varchar(32) NOT NULL default '',
  `File_description` text NOT NULL,
  PRIMARY KEY  (`Index`),
  KEY `Index` (`Index`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

-- 
-- Dumping data for table `files`
-- 

INSERT INTO `files` VALUES (0, 'Explosion Particle Effect Download', 'explosion_1.zip', 'The description');
 
Last edited:

Blazer9131

New Member
Messages
411
Reaction score
0
Points
0
this part :
INSERT INTO `files` VALUES (0, 'Explosion Particle Effect Download', 'explosion_1.zip', 'The description');

says you have a file named explosion_1.zip on your server.

If you do have it, then I don't know what's wrong.. butttt

If you don't have that file, then your scrip is getting no files to download o.o....

So add that file exactly as seen in the SQL... xD
 

SyncViews

New Member
Messages
37
Reaction score
0
Points
0
I do have that file. But my script is getting nothing from the data base. It's not displaying the download name, discription etc which it should even if the zip file isn't there... :(

and yeah the file is there all correct as I can download it if I replace the php with a html link.
The php vars are all just complety blank it seems :(
 
Last edited:

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
205
Points
63
PHP:
<html>
<?php 
    $con = mysql_connect("localhost:3306","syncview_site","*yeah the pass is set but i'm not telling:)*");
    if (!$con)
    {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("site", $con);
    
    $data = mysql_query("SELECT * FROM files
    WHERE Index='0'");
?>
<head>
 <title>
  <?php echo $data['Name']; ?>
 </title>
</head>
<body bgcolor="#cccccc">

<h2><?php echo $data['Name']; ?></h2>

<?php $data['File_Decription'] ?>
<br><br>
<table>
 <tr><td>File Size:        </td><td>15kb</td></tr>
 <tr><td>File Name:        </td><td><?php echo $data['File_Name']; ?></td></tr>
 <tr><td>Last Updated:    </td><td>24/11/07</td></tr>
</table>
<a href="./images/explosion_1a.png"><img border="0" src="./images/explosion_1a.png" width="400" height="300"></a>
<a href="./images/explosion_1b.png"><img border="0" src="./images/explosion_1b.png" width="400" height="300"></a>
<h2><a href="<?php echo $data['File_Name']; ?>">PRIMARY DOWNLOAD</a></h2>
<?php include("../main_footer.htm"); ?>

</body>
</html>

Change to:
PHP:
<html>
<?php 
    $con = mysql_connect("localhost:3306","syncview_site","*yeah the pass is set but i'm not telling:)*");
    if (!$con)
    {
        die('Could not connect: ' . mysql_error());
    }
    mysql_select_db("site", $con);
    $data = mysql_query("SELECT * FROM `files` WHERE `Index` = 0");
		$dataArr = mysql_fetch_array($data);
?>
<head>
 <title>
  <?php echo $dataArr['Name']; ?>
 </title>
</head>
<body bgcolor="#cccccc">

<h2><?php echo $dataArr['Name']; ?></h2>

<?php $dataArr['File_Decription'] ?>
<br><br>
<table>
 <tr><td>File Size:        </td><td>15kb</td></tr>
 <tr><td>File Name:        </td><td><?php echo $dataArr['File_Name']; ?></td></tr>
 <tr><td>Last Updated:    </td><td>24/11/07</td></tr>
</table>
<a href="./images/explosion_1a.png"><img border="0" src="./images/explosion_1a.png" width="400" height="300"></a>
<a href="./images/explosion_1b.png"><img border="0" src="./images/explosion_1b.png" width="400" height="300"></a>
<h2><a href="<?php echo $dataArr['File_Name']; ?>">PRIMARY DOWNLOAD</a></h2>
<?php include("../main_footer.htm"); ?>

</body>
</html>
 
Status
Not open for further replies.
Top