[thelist] simple (?) php question

Andrew Maynes andrew at humanbehaviour.co.uk
Sat Aug 17 06:22:01 CDT 2002


I will have a look at the code in the meantime, when you put " (quotes) in a
database you should use something like of that:

$text = "Some text with \\\"quotes\\\" that I'll insert into a database";

In fact PHP will strip 2 back-shlashes (the first and the third) and MySQL will
strip the last one and in the field you'll have just ".


-----Original Message-----
From: thelist-admin at lists.evolt.org
[mailto:thelist-admin at lists.evolt.org]On Behalf Of Duncan O'Neill
Sent: Saturday, August 17, 2002 11:52
To: thelist at lists.evolt.org
Subject: Re: [thelist] simple (?) php question


Andrew Maynes wrote:
> can you post the code that is pulling the records?
>

here's the code in its entirety. Copied and pasted, so
wraps may be wray. The most pertinent lines are these;

<h2><? print($row["heading"]); ?></h2>
           <? print($row["storyText"]); ?>

thanks for any help you can offer.
<?

// connect to database
if (!@mysql_connect("localhost","*****","*******")){

echo("<p>Unable to connect to the database server at this time</p>");

}

//select the rumours table
if (!@mysql_select_db("dbo")){
           echo("<p>Unable to connect to the rumours database at this
time</p>");
}


//select a random value in case the story variable has not been set
if (!isset($story)){
$storyIds = mysql_query("SELECT storyId from rumours");

$stories = array();

$j=0;
while ($row_rand=mysql_fetch_array($storyIds)){

          $stories[$j] = $row_rand["storyId"];					        $j++;
                                               }
$story = $stories[rand(0,$j-1)];
}


// now get the chosen story information out of the db
$result = mysql_query("SELECT heading,plugline,storyText from rumours
WHERE storyId='$story'");

  if(!$result){

	 echo("<p>Unable to connect to the rumours database at this time</p>");
      exit();
  }

  $row=mysql_fetch_array($result);

// Inlcude all information down to the H2 tag
  if (!@require_once("header.html")){

       print("<html><head><title>Rumours | The Urban Legend
magazine</title>" .
		    "</head><body><h2>Error</h2><a href='rumours.php'>Try Again</a> or <a
href='http://homepages.ihug.co.nz/~dbaxo/'>back to The Urban Legend
magazine</a>");

			}
?>


            <h2><? print($row["heading"]); ?></h2>
           <? print($row["storyText"]); ?>
		  <p class="copyright">&copy; Carl Wyant</p>

<?

//footnote bottom links and hitbox
if (!@require_once("footer.html")){

	print("</body></html>");

}


--
=====================================================
Duncan O'Neill
"Smith The Reporter"
http://homepages.ihug.co.nz/~dbaxo/urban_legend.htm
=====================================================

--
For unsubscribe and other options, including
the Tip Harvester and archive of thelist go to:
http://lists.evolt.org Workers of the Web, evolt !

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/02

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.381 / Virus Database: 214 - Release Date: 8/2/02




More information about the thelist mailing list