Jump to content

:( :( :( :(


DAcre

Recommended Posts

Second year university student in Edinburgh. Got a piece of PHP work due in for web technologies tommorrow.

 

http://www.dcs.napier.ac.uk/~05013885/TEST/viewmember.php?memberID=2

 

Click submit and you'll discover the problem. The page isn't valid so it displays the error class from my validationfunctions file.

 

its the memberID variable not being passed over again? Is there anyway to stop this I've been working my ass off to to do this. Had 10 weeks to do it and I started a couple of days ago

 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/53141--/
Share on other sites

Click submit and you'll discover the problem.

 

Come on. Is that the best description you can come up with to describe a problem you want us to help you solve?  Unless I misunderstood, you want our help and my crystal ball is broken because I can't discover the problem.

 

What's it do? What doesn't it do? What code where?

Link to comment
https://forums.phpfreaks.com/topic/53141--/#findComment-262626
Share on other sites


  
$newsid = $_GET['newsid'];  
$query = "SELECT * FROM news JOIN members ON (news.newsAuthor=members.memberID) WHERE newsID='$newsid'";
$query2 = "SELECT * FROM comments JOIN members ON (comments.commentAuthor=members.memberID) WHERE newsID='$newsid'";
$result = mysql_query($query);
$result2 = mysql_query($query2);

while ($list = mysql_fetch_array($result)) {  
echo "<table width=\"500\">";
echo "<tr>";
echo "<th>DateTime</th>";
echo "<th>Author</th>";
echo "<th>Title</th>";
echo "</tr>";
echo "<tr>";
echo "<td>{$list['newsDateTime']}</td>";
echo "<td class=\"tdwidth\"><a href=\"..\memberpages\viewmember.php?memberID=$list[memberID]\">{$list['name']}</a></td>";
echo "<td>{$list['newsTitle']}</td>";
echo "</tr>";
echo "<tr>";
echo "<th colspan=\"3\">News Item</th>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=\"3\">{$list['newsItem']}</td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=\"3\"><a href=\"viewcomments.php?newsid=$list[newsID]\">View Comments</a></td>";
echo "</tr>";
echo "</table>";
echo "<br/>";
}
while ($list2 = mysql_Fetch_array($result2)) {
echo "<table width=\"500\">";
echo "<tr>";
echo "<th>Comment From</th>";
echo "<th>Date/Time</th>";
echo "</tr>";
echo "<tr>";
echo "<td><a href=\"..\memberpages\viewmember.php?memberID=$list2[memberID]\">{$list2['name']}</a></td>";
echo "<td>{$list2['commentDateTime']}</td>";
echo "</tr>";
echo "<tr>";
echo "<th colspan=\"2\">Comment</th>";
echo "</tr>";
echo "<tr>";
echo "<td colspan=\"2\">{$list2['comment']}</td>";
echo "</tr>";
echo "</table>";
echo "<br/>";
}




include 'addnewscomment-form.php';
  ?>

 

Above GETS the memberID from a previous page fine.

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

addnewscomment-form.php

 

<?php session_start();?>
      <form action="addnewscomment-process.php" method="post">
	<p>
    			<label for="newscomment">Comment On This News Item:</label><br/><br/>
    			<textarea rows="5" cols="30" name="newscomment" id="newscomment"></textarea>   			
	</p>
	<p>
		<input type="submit" value="submit" name="submit"/>
	</p>
</form>

 

the process form - adds stuff to the db

 

<?php

mysql_connect('socweb1.napier.ac.uk', 'a5013885', '3ball');

$db_selected = mysql_select_db('a5013885');

if (!$db_selected) {
   die('Can\'t use a5013885 : ' . mysql_error());
}

if (!empty($_POST['newscomment'])){
$newscomment = $_POST['newscomment'];
}


echo $newscomment;





mysql_query($query) or die('Insert Failed - Probably dodgy coding at the mo.');
echo "<p>News comment added!</p><br/>";
echo "<p>Click <a href=\"index.php\">Here</a> to return to the main page</p>";

?>

 

I'm echoing $newscomment to make sure it goes across (it does).

I want to chuck the $memberID through too so I can add it to the database table comments under a field called commentAuthor.

 

Any help would be appreciated as this problem is throwing me out a few times in similar situations. Then thats me finished apart from one other problem.

 

A session problem but i'm gonna go ask Andrew Cumming in the morning (work doesn't have to be in till 3 pm) about that.

 

Thank youuuuuu xx

Link to comment
https://forums.phpfreaks.com/topic/53141--/#findComment-262786
Share on other sites

<?php
mysql_connect('socweb1.napier.ac.uk', 'xxxxxx', 'xxxx');
$db_selected = mysql_select_db('a5013885');
if (!$db_selected) {
   die('Can\'t use a5013885 : ' . mysql_error());
}

if (!empty($_POST['newscomment'])){
    $newscomment = $_POST['newscomment'];
}

echo $newscomment;

mysql_query($query) or die('Insert Failed - Probably dodgy coding at the mo.');
echo "<p>News comment added!</p><br/>";
echo "<p>Click <a href=\"index.php\">Here</a> to return to the main page</p>";
?>

 

Well, one obvious problem is that $query is never defined.  Presumably it's meant to be something like:

 

$query = "INSERT into some_tablename (fields) VALUES (values) ....";

 

You probably also need an ELSE { } to do something constructive when there's no newscomment

Link to comment
https://forums.phpfreaks.com/topic/53141--/#findComment-262799
Share on other sites

http://www.dcs.napier.ac.uk/~05013885/EVERYTHING%20PRESENT%20NEED%20SESSIONS%20AND%20REMOVE-EDIT%20USERS/newspages/viewcomments.php?newsid=1

 

the 'newsid' is in the address bar there (as i put it there)

 

When some one clicks submit! at the bottom of the page I want that newsid to be followed on to the next page in the address bar.

Link to comment
https://forums.phpfreaks.com/topic/53141--/#findComment-262809
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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