Jump to content

lauren_etherington

Members
  • Posts

    55
  • Joined

  • Last visited

Everything posted by lauren_etherington

  1. Thank you for the help but it is still displaying a white screen when the page loads.....
  2. Hello, I am trying to write a bit of code that will open a different page url depending on whether the value in my 'newsimage' table is set to left, right or centre. There is a news page which contains a list of news snippets and when you click 'read more' it should direct to one of three pages depending on where the 'image' should sit. The PHP is in a seperate file to the news page. This is the code that should display the news snippets. <div id="sectionright"> <div class="sectionhead"> <h2 class="sect editable" id="h2top">Media</h2> </div> <div class="padder18"></div> <?php newsform(); top10news($s,$t,$u,$w); ?> </div> This is the code in the seperate PHP file that displays the content. function top10news($s, $t, $u, $w) { $con = mysqli_connect("ip", "server", "password", "database name"); if (mysqli_connect_errno($con)) { echo "<p class='sect'>Could not connect to DB</p>"; // echo "<p class='sect'>Could not connect to DB " . mysqli_connect_error() . "</p>"; } else { // echo "<p class='sect'>Connected to DB</p>"; $q = "SELECT DISTINCT newsitem.niid,newstitle,newssnippet,sitename,newsimage FROM newsitem,newsbusiness WHERE newsitem.niid=newsbusiness.niid AND newsstatus='enabled' "; if ("$u" == "Any") { } else { $q = $q . "AND sitename='$u' "; } if ("$s" == "Any") { } else { $parts = explode('-', $s); $y = $parts[0]; $m = $parts[1]; $q = $q . "AND YEAR(newsdate) = $y AND MONTH(newsdate) = $m "; } $q = $q . "ORDER BY newsdate DESC LIMIT 0,10"; // echo "<p class='news'>$s</p>"; // echo "<p class='news'>$q</p>"; $result = mysqli_query($con, $q); while ($tnrow = mysqli_fetch_array($result)) { echo " <div class='newssummary'>"; if ("" . $tnrow['newsimage'] . "" == "none") { echo <p class = 'newsmore' > < a href = 'newsitem.php?i=" . $tnrow['niid'] . "' > Read More</a > </p>; }else $radio = mysqli_query("SELECT imageposition FROM newsimage WHERE imageposition EQUALS newsitem.niid=newsimage.niid"); $qresult = mysqli_query($con, $radio); while (($tnrow = mysqli_fetch_array($qresult)); { if ($radio == 'Centre') { echo "<p class='newsmore'> <a href='newsitem3.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; }else if ($radio == 'Right') { echo "<p class='newsmore'> <a href='newsitem2.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; }else if ($radio == 'Left') { echo "<p class='newsmore'> <a href='newsitem.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; } } echo "<div class='newspic'><img src='http://www.nortech.org.uk/news/" . $tnrow['newsimage'] . "' alt='" . $tnrow['newstitle'] . "' /></div>"; } echo " <p><strong>" . $tnrow['newstitle'] . "</strong></p> <p class='news'>" . $tnrow['newssnippet'] . "</p> </div> <div class='padder1'></div> <div class='rtgreengp'></div> "; } } mysqli_close($con); } My problem is that whenever I load the page it just produces a blank page. When I look at the source code on the web all that is displayed is "<!doctype html>" However, when I remove the second query from the file and re-upload it, it all works fine, so from what I can gather there is a problem some where in this bit of code: }else $radio = mysqli_query("SELECT imageposition FROM newsimage WHERE imageposition EQUALS newsitem.niid=newsimage.niid"); $qresult = mysqli_query($con, $radio); while (($tnrow = mysqli_fetch_array($qresult)); { if ($radio == 'Centre') { echo "<p class='newsmore'> <a href='newsitem3.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; }else if ($radio == 'Right') { echo "<p class='newsmore'> <a href='newsitem2.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; }else if ($radio == 'Left') { echo "<p class='newsmore'> <a href='newsitem.php?i=" . $tnrow['niid'] . "'>Read More</a></p>"; } } echo "<div class='newspic'><img src='http://www.nortech.org.uk/news/" . $tnrow['newsimage'] . "' alt='" . $tnrow['newstitle'] . "' /></div>"; } echo " <p><strong>" . $tnrow['newstitle'] . "</strong></p> <p class='news'>" . $tnrow['newssnippet'] . "</p> </div> <div class='padder1'></div> <div class='rtgreengp'></div> "; } } mysqli_close($con); } I just can't see why it isn't working.... Whenever I run the debugger I am only receiving this error message "Parse error: syntax error, unexpected '<' in C:\pathway\filename.php on line 32" which isn't really useful because when I look at line 32 there are no added '<' Advice would be much appreciated before I start tearing my hair out lol!
  3. Thank you, I've been at a loss all day, think I had been looking at it for too long so I just couldn't see where I had gone wrong!
  4. I'm using radio buttons for the image position whereby the client selects the radio button to position the image - the radio button value is then stored in the database on a news image table which links into the actual newsitems table. For the WHERE clause that would be a case of stating where the newsitem id is equal to news image id wouldn't it? That would then return the image position where the news item id is equal to x?
  5. I can't have anymore edits: I have changed the radio query from $radio= "SELECT imageposition FROM newsimage"; to $radio= mysqli_query("SELECT DISTINCT imageposition FROM newsimage")"; And the only error message I seem to get when I debug the file is this: Parse error: syntax error, unexpected '<' in C:\Users\pathway.php on line 32
  6. Hello. I am having some trouble and I'm not sure if its my code or logic haha. Basically, my company has commissoned a website for one of our clients and used an outside developer to actually build the site. Now the initial development is complete I have been put in charge of the support and maintenance of the site. However the client has now decided they would like to decide the position of an image on the news pages. To display a news article, they enter the information in a form, which is saved in the database, this is then recalled through a php script when a user clicks 'read more' on the website. I have added a set of radio buttons to the form where the client can select if the image is Right, Left of Centre. When they save the form this information is saved in the database. I then want to create a script that will open the 'newsitem' 'newsitem2' or 'newsitem3' page depending on the value of the radio button. This is the code I am using: function top10news($s, $t, $u, $w) { $con = mysqli_connect("ip", "host", "password", "databasename"); if (mysqli_connect_errno($con)) { echo "<p class='sect'>Could not connect to DB</p>"; // echo "<p class='sect'>Could not connect to DB " . mysqli_connect_error() . "</p>"; }else { // echo "<p class='sect'>Connected to DB</p>"; $q = "SELECT DISTINCT newsitem.niid,newstitle,newssnippet,sitename,newsimage FROM newsitem,newsbusiness WHERE newsitem.niid=newsbusiness.niid AND newsstatus='enabled' "; if ("$u" == "Any") { }else { $q = $q . "AND sitename='$u' "; } if ("$s" == "Any") { }else { $parts = explode('-', $s); $y = $parts[0]; $m = $parts[1]; $q = $q . "AND YEAR(newsdate) = $y AND MONTH(newsdate) = $m "; } $q = $q . "ORDER BY newsdate DESC LIMIT 0,10"; // echo "<p class='news'>$s</p>"; // echo "<p class='news'>$q</p>"; $result = mysqli_query($con, $q); while ($tnrow = mysqli_fetch_array($result)) { echo " <div class='newssummary'>"; if ("" . $tnrow['newsimage'] . "" == "none") { <p class='newsmore'> <a href='newsitem.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } else { $radio= "SELECT imageposition FROM newsimage"; if ($radio == 'Centre') { <p class='newsmore'> <a href='newsitem3.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } if ($radio == 'Right') { <p class='newsmore'> <a href='newsitem2.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } if ($radio == 'Left') { <p class='newsmore'> <a href='newsitem.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } echo "<div class='newspic'><img src='http://www.nortech.org.uk/news/" . $tnrow['newsimage'] . "' alt='" . $tnrow['newstitle'] . "' /></div>"; } echo " <p><strong>" . $tnrow['newstitle'] . "</strong></p> <p class='news'>" . $tnrow['newssnippet'] . "</p> </div> <div class='padder1'></div> <div class='rtgreengp'></div> "; } } mysqli_close($con); } The problem I am facing is when I then go to load the news page. Nothing loads on the webpage. but if I remove this bit of code, it works fine: if ("" . $tnrow['newsimage'] . "" == "none") { <p class='newsmore'> <a href='newsitem.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } else { $radio= "SELECT imageposition FROM newsimage"; if ($radio == 'Centre') { <p class='newsmore'> <a href='newsitem3.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } if ($radio == 'Right') { <p class='newsmore'> <a href='newsitem2.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } if ($radio == 'Left') { <p class='newsmore'> <a href='newsitem.php?i=" . $tnrow['niid'] . "'>Read More</a></p> } Can anyone see where I am going wrong? I have spent that long looking at it I just can't see where I am wrong!! Any help would be vastly appreciated!
×
×
  • 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.