shows nothing

Hi, I’m new to learning php. When I view this page in my browser it shows nothing and the page source is nothing. I would’ve thought it should at least show the html outside of the php, no? The table contains data since I created it and put it in with phpMyAdmin. I’ve deleted the parameters on the connection function and changed the table name since it’s prefixed with username info etc.

Here’s where the page is http://samcoles.gofreeserve.com/venue_list.php

Can anyone tell me what’s wrong? Cheers.

[code]

Venues register | venues <?php $con = mysql_connect(); if (!$con) { die('Could not connect: ' . mysql_error()); }

$dbselect = mysql_select_db(“test_site”, $con);
if(!$dbselect) {
die("Cannot select database " . mysql_error());
}

$result = mysql_query(“SELECT * FROM venue”);

echo “

    ”;
    while($row = mysql_fetch_array($result))
    {
    echo “
  • <a href=“venue.php?id=” . $row[‘user_id’] . “”>” . $row[‘name’] .
    “”;
    }
    echo “
”;

?>

[/code]

As far as I can tell, it’s probably a configuration issue. The code looks like it should at LEAST produce a source code. Contact your host with this problem and ask them for support.

You’re right. I changed host and it worked. Thankyou very much. I should set up php/sql on my own computer if I’m planning to learn all this jazz… Any simple step-by-step guides out there?

Also this, outputs "title for id x is " but not the actual name which is irritating, yet again can’t see why…

<?php $id = $_GET["id"]; $sql = "SELECT venue_id, name FROM venue WHERE venue_id='$id'"; $result = mysql_query($sql); $title = mysql_fetch_object($result); echo "title for id " . $id . " is " . $title->name; ?>

How silly of me… no connection isn’t it? Funny the idiots mistakes you notice immediately upon posting but couldn’t work out for half an hour sat there in the editor… :stuck_out_tongue:

I have another question,

say I have a page called “add_review.php” which is a form for adding a review for a venue. The venue that it is for is put into the address bar so for instance “add_review.php?venueid=2”. How do I post this to “insert_review.php” with the rest of the form? Cheers. I have considered having a dropdown box with all the venues in it that defaults to the one mentioned which is the only way I would know how to do it though this would be unneccessary.

Another problem then once I’ve solved this… I have finished my little project thing. I was wondering if there is anyway I can kind of step-through a php script and find out where the error happens?? Yet again this shows as nothing but this time it doesn’t appear to be a missing semi-colon etc. I used to do some programming when I was younger and I remember the majority of silly errors of the kind I am making with this php were easily picked up by the compiler which made life a lot easier…

Here’s the problem code and I wouldn’t mind if anyone does spot the problem(s) but also being pointed in the direction so I can solve them myself now and/or in the future would be appreciated.

Cheers.

[code]<?php
//connection
include(“connect.php”);

//create header escape string thing
$returntoform = “Location: add_review.php?id=” . $_POST[“venue_id”];

if(isset($_POST[“submit”]) {

if(empty($_POST["email"]) || empty($_POST["password"]) ||
	empty($_POST["title"]) || empty($_POST["body"])) {
	echo "Form not completed.";
	header($returntoform);
	exit;
	}

//check user details	 
$email = $_POST["email"];
$password = $_POST["password"];

$sql = "SELECT user_id, password FROM user WHERE email='$email'";
$result = mysql_query($sql);

if(!$result) {
	echo "email address not found!";
	header($returntoform);
	exit;
	}
	
$user = mysql_fetch_object($result);
if($user->password != $password) {
	echo "Password incorrect!";
	header($returntoform);
	exit;
	}
	
$user_id = $user->user_id;
$title = $_POST["title"];
$body = $_POST["body"];
$venue_id = $_POST["venue_id"];
	
//email and password, OK. Insert review
$sql = "INSERT INTO review (venue_id, post_date, title, body, user_id)
		 	 VALUES ('$venue_id', NULL, '$title', '$body', '$user_id')";
$result = mysql_query($sql);

if(!$result) {
echo "Failed to add review!";
} else {
	echo "Thankyou for your review. Please click <a href="venue.php?id=" . 
			 $venue_id . "">here</a> to return to the venue's page and see your review.";
	}

}
?>[/code]

Well that’s the kind of attitude we’re looking for :wink:

Cheers man…

Look at the brackets on the first if statement. :roll: :roll:

Sponsor our Newsletter | Privacy Policy | Terms of Service