Advertisement

02.11.2008 at 02:07PM PST, ID: 23154562
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.4

Problem displaying HTML stored in SQL Server 2005

Asked by thearniec in PHP and Databases, PHP for Windows, SQL Server 2005

Tags:

I am running PHP5 under Windows Server 2003 with SQL Server 2005 as my back-end database.

I have the PHP pages communicating successfully with the server when I do manual inserts, so I'm moving on to form data inserts and programmatic data pulls.

I have implemented FCKeditor as a GUI front-end for my users to see so they can format the data easily.  

On the user's page they have two form fields, a text field for article title, and the FCKeditor window to enter their text.  This is stored in a SQL Server table called testArticles.

To prevent injection attacks and problems with apostrophes I use this code for my insert statement:

function mssql_real_escape_string($string) {
    return str_replace("'", "''", $string);
}
$tValue = mssql_real_escape_string($_POST['title']);
$sValue = mssql_real_escape_string($_POST['FCKeditor1']);
$query = "INSERT INTO testArticles (ArticleTitle, ArticleText) ";
$query .= "VALUES ('$tValue', '$sValue') ";


This is working very well for storing data of all sorts and pulling the data back out.  However I wanted to test the limits so I did something a user might do--I copied a bunch of Excel data and pasted it in the editor window.  It took a while but the editor sent the data to SQL Server and it stored correctly.  The HTML is sort of dirty, but it took.

Now to the crux of my problem:  When I pull the record it does not display properly.  I took the contents of the cell and pasted it into an HTM document, and the entire contents display.  However when I use this code:

<body>
<?php

 //connection to the database
$dbhandle = mssql_connect($myServer, $myUser, $myPass)
  or die("Couldn't connect to SQL Server on $myServer - error was " . msql_error()  );

 //select a database to work with
$selected = mssql_select_db($myDB, $dbhandle)
  or die("Couldn't open database $myDB");

 //declare the SQL statement that will query the database
$query = "SELECT ArticleTitle, ArticleText ";
$query .= "FROM testArticles ";


//execute the SQL query and return records
$result = mssql_query($query);

$numRows = mssql_num_rows($result);
echo "<h1>" . $numRows . " Row" . ($numRows == 1 ? "" : "s") . " Returned </h1>";

$rowNum = 0;

//display the results

while($row = mssql_fetch_array($result))
{
       $rowNum++;
       echo "<B>" . $row["ArticleTitle"] . "</B><P>" .
       $row["ArticleText"] . "</li>";
}

//close the connection
mssql_close($dbhandle);


?>
</body>

It does not display the entire contents of the cell.  In fact, some HTML tags (<tr style="height: 11.25pt) are visible in the output.

I cannot determine what would be different.  Again, the contents of the cell work if saved to an HTML file, but they don't work when pulled using the above code.

Any suggestions?Start Free Trial
[+][-]02.11.2008 at 04:31PM PST, ID: 20871670

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 07:00AM PST, ID: 20875275

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 07:44AM PST, ID: 20875768

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 07:54AM PST, ID: 20875870

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 10:42AM PST, ID: 20877451

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 11:06AM PST, ID: 20877651

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 11:27AM PST, ID: 20877838

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 11:40AM PST, ID: 20877966

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 11:50AM PST, ID: 20878103

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 12:17PM PST, ID: 20878419

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 01:19PM PST, ID: 20879141

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.12.2008 at 02:31PM PST, ID: 20879910

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02.13.2008 at 11:11AM PST, ID: 20887082

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02.13.2008 at 12:22PM PST, ID: 20887762

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP and Databases, PHP for Windows, SQL Server 2005
Tags: PHP SQL Server 2005
Sign Up Now!
Solution Provided By: dr_dedo
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628