DAcre Posted May 27, 2007 Share Posted May 27, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/53141--/ Share on other sites More sharing options...
marksie1988 Posted May 27, 2007 Share Posted May 27, 2007 shouldnt this be in php help?? anyway wouldnt it help a bit if there was some code for people to take a look at to see where its wrong? Quote Link to comment https://forums.phpfreaks.com/topic/53141--/#findComment-262568 Share on other sites More sharing options...
andy75180 Posted May 27, 2007 Share Posted May 27, 2007 You need to post the code on here so we can find problem. I've used PHP in my chess site loads, so I should be able to fix it. Probably...... :-\ Quote Link to comment https://forums.phpfreaks.com/topic/53141--/#findComment-262570 Share on other sites More sharing options...
OilSheikh Posted May 27, 2007 Share Posted May 27, 2007 Had 10 weeks to do it and I started a couple of days ago You are quite frankly screwed. These kinds of Projects take Months. I am in uni and thats why I know these things. Quote Link to comment https://forums.phpfreaks.com/topic/53141--/#findComment-262619 Share on other sites More sharing options...
MadTechie Posted May 27, 2007 Share Posted May 27, 2007 Months to pass a variable !! humm thats one complex variable then..! Quote Link to comment https://forums.phpfreaks.com/topic/53141--/#findComment-262623 Share on other sites More sharing options...
AndyB Posted May 27, 2007 Share Posted May 27, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/53141--/#findComment-262626 Share on other sites More sharing options...
DAcre Posted May 27, 2007 Author Share Posted May 27, 2007 $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 Quote Link to comment https://forums.phpfreaks.com/topic/53141--/#findComment-262786 Share on other sites More sharing options...
DAcre Posted May 27, 2007 Author Share Posted May 27, 2007 woops look like i didn't remove my pasword and shit for the mysql its ok tho you first need to log into socweb1 with a different username and pass first. If anyones testing it, it wont work because the database server only accepts connections from within the university. Quote Link to comment https://forums.phpfreaks.com/topic/53141--/#findComment-262789 Share on other sites More sharing options...
AndyB Posted May 27, 2007 Share Posted May 27, 2007 <?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 Quote Link to comment https://forums.phpfreaks.com/topic/53141--/#findComment-262799 Share on other sites More sharing options...
DAcre Posted May 27, 2007 Author Share Posted May 27, 2007 oh wait, thats not a problem I want to make sure that I can just echo the values first before i write the stuff that'll use the variables within an INSERT query. Quote Link to comment https://forums.phpfreaks.com/topic/53141--/#findComment-262805 Share on other sites More sharing options...
AndyB Posted May 27, 2007 Share Posted May 27, 2007 Fine. Specifically, what are the problems that you need help resolving? Quote Link to comment https://forums.phpfreaks.com/topic/53141--/#findComment-262807 Share on other sites More sharing options...
DAcre Posted May 27, 2007 Author Share Posted May 27, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/53141--/#findComment-262809 Share on other sites More sharing options...
AndyB Posted May 27, 2007 Share Posted May 27, 2007 Then retrieve newsid from the passed URL (via $_GET) and add ?newsid=the_value to the clickable link to the next page Quote Link to comment https://forums.phpfreaks.com/topic/53141--/#findComment-262819 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.