Doug Posted February 27, 2011 Share Posted February 27, 2011 <a href=pictures1.php?user_id= ' . $row['user_id'] . '>' . $row['name'] . '</a>'; The program ignores ' . $row['user_id'] . ' so does not go to the correct page. Why would this be? ' . $row['name'] . ' works. Any answers greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/229007-what-is-wrong-with-this-line/ Share on other sites More sharing options...
Altrozero Posted February 27, 2011 Share Posted February 27, 2011 The line seems fine, are you sure there is data in $row['user_id']? Could it by null? Quote Link to comment https://forums.phpfreaks.com/topic/229007-what-is-wrong-with-this-line/#findComment-1180280 Share on other sites More sharing options...
trq Posted February 27, 2011 Share Posted February 27, 2011 We need to see more code. Quote Link to comment https://forums.phpfreaks.com/topic/229007-what-is-wrong-with-this-line/#findComment-1180282 Share on other sites More sharing options...
hyster Posted February 27, 2011 Share Posted February 27, 2011 why have u got . before and after the vars? think it should be <a href=pictures1.php?user_id= $row['user_id'] >'$row['name']</a>'; and if its not allready in php then u need to do <a href=pictures1.php?user_id= <?php echo $row['user_id'] ?>> <?php echo $row['name'] ?></a>'; Quote Link to comment https://forums.phpfreaks.com/topic/229007-what-is-wrong-with-this-line/#findComment-1180294 Share on other sites More sharing options...
joshbedo Posted February 27, 2011 Share Posted February 27, 2011 try this <a href=pictures1.php?user_id=" ' . $row['user_id'] . '">' . $row['name'] . '</a>'; if your echoing that line otherwise, and i think its better practice <a href=pictures1.php?user_id="<?php echo $row['user_id']; ?>"><?php echo $row['name']; ? ></a> Quote Link to comment https://forums.phpfreaks.com/topic/229007-what-is-wrong-with-this-line/#findComment-1180324 Share on other sites More sharing options...
silkfire Posted February 27, 2011 Share Posted February 27, 2011 You can echo the whole line like this: echo "<a href=\"pictures1.php?user_id=$row[user_id]\">$row[name]</a>"; Quote Link to comment https://forums.phpfreaks.com/topic/229007-what-is-wrong-with-this-line/#findComment-1180327 Share on other sites More sharing options...
Doug Posted February 27, 2011 Author Share Posted February 27, 2011 Thanks but none of those lines seem to work. Here is the whole code. [code<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>OneSevenoaks - latest pictures</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" href="onesevenoaks2.css" type="text/css" media="screen" /> </head> <body> <div id="pictures"> <?php require_once('appvars.php'); require_once('connectvars1.php'); // Connect to the database $dbc = mysqli_connect(DB_Host, DB_User, DB_Password, DB_Name); // Retrieve the user data from MySQL $query = "SELECT picture, name, user_id FROM pictures order by join_date desc"; $data = mysqli_query($dbc, $query); // Loop through the array of user data, formatting it as HTML echo '<h4>Pictures:</h4>'; echo '<table>'; while ($row = mysqli_fetch_array($data)) { if (is_file(MM_UPLOADPATH . $row['picture']) && filesize(MM_UPLOADPATH . $row['picture']) > 0) { echo '<img src="' . MM_UPLOADPATH . $row['picture'] . '" alt="' . $row['name'] . '" style="width:150px; maxheight=110px; margin: 5px; padding: 5px" /> <a href=pictures1.php?user_id= ' . $row['user_id'] . '>' . $row['name'] . '</a>'; } } echo '</table>'; mysqli_close($dbc); ?> </div> <hr> <p><a href="addpicture.php">Add pictures of your own!</a><br /> <a href="pictures.php">Go back to pictures page</a><br /> <a href="index5.php">Go to the Homepage</a></p> </body> </html> ] Quote Link to comment https://forums.phpfreaks.com/topic/229007-what-is-wrong-with-this-line/#findComment-1180418 Share on other sites More sharing options...
silkfire Posted February 27, 2011 Share Posted February 27, 2011 What errors do you get then? Quote Link to comment https://forums.phpfreaks.com/topic/229007-what-is-wrong-with-this-line/#findComment-1180503 Share on other sites More sharing options...
ardesigns Posted February 27, 2011 Share Posted February 27, 2011 Try replacing that whole echo statement with this: echo '<img src="' . MM_UPLOADPATH . $row["picture"] . '" alt="' . $row["name"] . '" style="width:150px; maxheight=110px; margin: 5px; padding: 5px" /> <a href="pictures1.php?user_id=' . $row["user_id"] .'"> '. $row["name"] . '</a>'; Quote Link to comment https://forums.phpfreaks.com/topic/229007-what-is-wrong-with-this-line/#findComment-1180513 Share on other sites More sharing options...
Doug Posted February 28, 2011 Author Share Posted February 28, 2011 Solved! Thank you very much. I was very close with the answer...just confused with ' and ". Quote Link to comment https://forums.phpfreaks.com/topic/229007-what-is-wrong-with-this-line/#findComment-1180925 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.