Jump to content

Recommended Posts

I flipped the closing tag

<?php
/* put your database connection here */
$query = "SELECT * FROM images";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
?>
<a href="<?php echo $row['url']; ?>"><img src="<?php echo $row['image_path']; ?>" alt=""></a><hr>
<?php
}
?>

  • Replies 84
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

What am i doing wrong here, it says 'Parse error: syntax error, unexpected ',' in /home/a2221438/public_html/test.php on line 2'

 

Heres the code:

<?php
('__HOST', ''); //localhost = database host name (normaly this won't need changing)
('__USER', '');    //xxx = database username
('__PASS', '');    //xxx = database password
('__DEF_DB', ''); //xxx = database name
$query = "SELECT * FROM images";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
?>
<a href="<?php echo $row['url']; ?>"><img src="<?php echo $row['image_path']; ?>" alt=""></a><hr>
<?php
}
?>

 

Thanks

Sorry ignore the above post, yeah I have done it and it shows the image but when I click it, it gives me a error page.

 

check the link here: http://www.mumtazproperties.hostei.com/test.php

 

Its weird cuz when I click the browser i see the correct link appear in the web address but then quickly changes and goes to the error page as though the page is not recognised.

 

And in the web browser source it shows this:

<a href="http://www.hosting24.com/">

So this works in this test page here:

<?php
$connect = mysql_connect("","","") or die("Couldn't connect!");
mysql_select_db("") or die("Couldn't find db");

$query = "SELECT * FROM images";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
?>
<a href="<?php echo $row['url']; ?>"><img src="<?php echo $row['image_path']; ?>" alt=""></a><hr>
<?php
}
?>

 

but doesn't work on this page where I need it to work, this is the main line here:

echo "<a href=\"{$row['url']}\"><img class='image1' src=\"{$row['image_path']}\" alt=\"{$row['summary']}\"> </a> <br />";

help is appreciated.

but doesn't work on this page where I need it to work, this is the main line here:

 

 

Then go over your code(not just the echo statement) very carefully after you move it, something is missing.

for the moment, replace this

 

echo "<a href=\"{$row['url']}\"><img class='image1' src=\"{$row['image_path']}\" alt=\"{$row['summary']}\"> </a> <br />";

 

with this...

 

?>
<a href="<?php echo $row['url']; ?>"><img src="<?php echo $row['image_path']; ?>" alt=""></a><hr>
<?php

There must be something wrong with the code, i really don't understand why it doesn't seem to work. here is all the php code on the page:


<?php
require_once 'mstr_ref.php';
function san($input){
if(get_magic_quotes_gpc()){
	$input=stripcslashes($input);
}
$output = mysql_real_escape_string($input);
return $output;
}
if(isset($_POST['submit'])){
$pVars = array('area'=>$_POST['areas'], 'propType'=>$_POST['prop_type'], 'saleType'=>$_POST['ptype'], 'minB'=>$_POST['min_bedrooms'], 'maxB'=>$_POST['max_bedrooms'], 'minP'=>$_POST['min_price'], 'maxP'=>$_POST['max_price']);
foreach ($pVars as $k=>$v){
	$v = san($v);
}
$sql = new makeQuery();
$sql->manAdd('location_id', $pVars['area']);
if($pVars['propType'] != 'Any'){
	$sql->manAdd('catagory_id', $pVars['propType']);
}
if ($pVars['maxB'] > 0){
	$sql->manAdd('bedrooms', $pVars['maxB'], '<=');
}
if($pVars['minB'] > 0){
	$sql->manAdd('bedrooms',$pVars['minB'],'>=');
}
if($pVars['saleType'] != 'Any'){
	if($pVars['saleType'] == "forsale"){
		$sql->manAdd('market_type', 'sale');
		if($pVars['minP'] != 0){
			$pVars['minP'] = $pVars['minP'] * 1000;
		}
		if($pVars['maxP'] != 0){
			$pVars['maxP'] = $pVars['maxP'] * 1000;
		}
	}
	if($pVars['saleType'] == 'forrent'){
		$sql->manAdd('market_type', 'rent');
	}
}

$qry = $sql->sqlStart.$sql->stmt.'Group By property.id';
$results = mysql_query($qry) or die (mysql_error()."<br />|-|-|-|-|-|-|-|-|-|-|-|-<br />$qry");
if(mysql_num_rows($results) < 1){
	die ("Sorry, No Results Match Your Search.");
}
while($row = mysql_fetch_assoc($results)){
	echo '<div class="container" style="float:left;">';
	echo '<div class="imageholder" style="float:left;">';
	echo "<a href=\"{$row['url']}\"><img class='image1' src=\"{$row['image_path']}\" alt=\"{$row['summary']}\"> </a> <br />";
	echo '</div>';
	echo '<div class="textholder" style="font-family:helvetica; font-size:14px; float:left; padding-top:10px;">';
	echo "{$row['summary']}";
	echo "<span style=\"color:#63be21;\"><br><br><b>{$row['bedrooms']} bedroom(s) {$row['bathrooms']} bathroom(s) {$row['receptions']} reception room(s)</b></span>";
	if($row['parking'] != null){
		echo "<span style=\"color:#63be21;\"><b> {$row['parking']} parking space(s)</b></span>";
	}

	echo '</div>';
	echo '<div style="clear:both"></div>';
}

}
else{
echo "There was a problem, please click<a href='index.php'> Here </a>to return to the main page and try again";
}
?>

 

This beginning line of this code is the one that doesn't seem to work (the url of the image):

echo "<a href=\"{$row['url']}\"><img class='image1' src=\"{$row['image_path']}\" alt=\"{$row['summary']}\"> </a> <br />";

What is this foreach loop used for?

foreach ($pVars as $k=>$v){
	$v = san($v);
}

I don't see $v used anywhere.

 

What is the point of building the $pVars array when you have the $_POST array available?  Seems like you've got some unneeded code in there.

Also, try this...

 

replace this:

$qry = $sql->sqlStart.$sql->stmt.'Group By property.id';

 

with this...

$qry = $sql->sqlStart.$sql->stmt.'Group By property.id';
echo $qry;
exit();

 

and tell us the results

That displays this on screen and the images and text is not there no more:

SELECT property.id, image_path, area_name, cat_name, bedrooms, bathrooms, receptions, parking, market_type, asking_price, summary, pay_interval FROM property INNER JOIN catagorys ON property.catagory_id = catagorys.id INNER JOIN locations ON property.location_id = locations.id LEFT JOIN images ON property.id = images.property_id WHERE (location_id = '1') AND(catagory_id = '2') AND(market_type = 'rent') Group By property.id

 

i dont know to be honest drummin but would that have a effect on the images links?

Can you hard code the image into the results display and get an image to show?

 

Modify your image path line so it duplicates this hard coded line.

 

Again, can you hard code the link so it goes where you want?

 

Does $row['url'] show the same?

 

Seems like some simple tests are in order.

Somewhere along the line you've also lost your multiple="multiple" for the areas.  Seems like a foreach loop would bring this back.  Not sure if this example will work for you but something like this.

 

foreach ($_POST['areas'] as $location_id){
$sql->manAdd('location_id', $location_id);
}

Iv already done a test using this, and it works fine, the link takes me to the correct page. This is what I used:

<?php
$connect = mysql_connect("mysql10.000webhost.com","a2221438_usman","usman1") or die("Couldn't connect!");
mysql_select_db("a2221438_homes") or die("Couldn't find db");

$query = "SELECT * FROM images";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
?>
<a href="<?php echo $row['url']; ?>"><img src="<?php echo $row['image_path']; ?>" alt=""></a><hr>
<?php
}
?>

 

and the multiple for the areas works fine mate, its hooked up with the mySQL database so when I add a new entry in there it will also be added on the page.

That above post was when I tested it on another thing, but its still not working on the page where I want it. can anyone please assist me somehow on what it is and why it is not working? I have been on this for nearly 3 days now, just to get a link working.

Sorry ignore the above post, yeah I have done it and it shows the image but when I click it, it gives me a error page.

 

check the link here: http://www.mumtazproperties.hostei.com/test.php

 

Its weird cuz when I click the browser i see the correct link appear in the web address but then quickly changes and goes to the error page as though the page is not recognised.

 

And in the web browser source it shows this:

<a href="http://www.hosting24.com/">

Just tested the link on this page and it took me to the http://www.mumtazproperties.hostei.com/propertyinfo.html page.  Seems to be working well.

Ya I was looking at your actual site just now as see what you're talking about.

Are you wanting the link to go to properyinfo.php and pass the property ID to display details? OR is the "Details view" incorporated into your "insert.php" page?  Something else?  The link is currently going to insert.php but as far as I know, the only identifier you have is POST from your form.  The property ID needs to be passed along with the link to the page where you are showing the details.  A new query is made based on this ID and details are shown. 

Yeah i want the page to go to the 'propertyinfo.html' page. Im not sure with all the technical way, but what I want it when viewing the website is, when your results come up, to click the image of a property then it takes you directly to that page.

 

And when I view the source code in the browser it just has:

href=""

the href is just empty, so i dont know why that is?

 

How could I get it to work?

 

I thought it would be so simple, but has taken me nearly 3 days and still not working.

Well change the page to php.  hard code propertyinfo.php as your link.  And add a GET value for the property id, something like <a href="propertyinfo.php?id=$propertyid">

 

Then on propertyinfo.php pick up this GET['id'] and query to show details.

Well how are the details being called on the test page propertyinfo.html?  Must be hard coded.  You need to make it dynamic so it will show whatever property is selected.  This entails making propertyinfo a php page, somehow passing the property ID to this page (via GET) and doing a DB query.  As I assume insert.php will show a bunch of properties, the best way I can think of is hard coding the link as I explained and passing the ID.

The details are being called to the test page like this and iv tried using the same method to the page I want it in but the same problem still remains:

<?php
$connect = mysql_connect("","","") or die("Couldn't connect!");
mysql_select_db("") or die("Couldn't find db");

$query = "SELECT * FROM images";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
?>
<a href="<?php echo $row['url']; ?>"><img src="<?php echo $row['image_path']; ?>" alt=""></a><hr>
<?php
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


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