TapeGun007 Posted March 19, 2010 Share Posted March 19, 2010 I need help converting something very simple from ASP (classic). Here is the ASP code: <% DO While NOT recordset.EOF %> <tr><td colspan="3">Posted On: <%=recordset("NewsDate") %></td></tr> (Populate a table from Access Database here) <% Recordset.MoveNext Loop %> Basically, instead of using SQL to access the db, I used a recordset. Why? Because this is a memo field that stores news information. In the news memo field, it stores apostrophies, and quotation marks. Thus, using SQL to retrieve that information causes a problem on output. What is the PHP equivalent? As a recap, I have a memo field that stores lots of text with apostrophies and quotes. I need to be able to pull the information out of the memo field without using SQL. How can I do this? Quote Link to comment https://forums.phpfreaks.com/topic/195764-from-asp-recordsets-to-php/ Share on other sites More sharing options...
The Little Guy Posted March 19, 2010 Share Posted March 19, 2010 This is using mysql: <?php $sql = mysql_query("SELECT * FROM tbl_name"); while($row = mysql_fetch_array($sql)){ ?> <tr><td colspan="3">Posted On: <?=$row["NewsDate"]; ?></td></tr> (Populate a table from Access Database here) <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/195764-from-asp-recordsets-to-php/#findComment-1028399 Share on other sites More sharing options...
TapeGun007 Posted March 19, 2010 Author Share Posted March 19, 2010 ARG, I should've posted what I already have: $result = mysql_query("SELECT * FROM News WHERE ShowNews='Yes' ORDER BY News.NewsDate DESC , News.NewsID DESC"); while($row = mysql_fetch_array($result)) { echo "<tr><td background='images/news_header.gif' class='ContentWhite'> <b>".$row['NewsTitle']."<b></td><td background='images/news_date.gif'>".$row['NewsDate']."</td></tr>"; echo "<tr><td background='images/news_main.gif' colspan='2'>".$row['News']."</td></tr>"; echo "<tr><td colspan='2'><b>-".$row['NewsWriter']."</b></td></tr>"; } This is the output that I get: �The breath isn�t that important.� �are you still reading? Good. Now let me explain my reasoning for saying such a blasphemous thing. See those funny characters? They are quotes and apostrophies stored in $row['News']. This is why in .asp I used recordsets instead of SQL to pull that information from the memo field. Quote Link to comment https://forums.phpfreaks.com/topic/195764-from-asp-recordsets-to-php/#findComment-1028402 Share on other sites More sharing options...
trq Posted March 19, 2010 Share Posted March 19, 2010 See those funny characters? They are quotes and apostrophies stored in $row['News']. This is why in .asp I used recordsets instead of SQL to pull that information from the memo field. A recordset is essentially the same thing as a result resource in php. Which is exactly what mysql_query() returns. Quote Link to comment https://forums.phpfreaks.com/topic/195764-from-asp-recordsets-to-php/#findComment-1028406 Share on other sites More sharing options...
The Little Guy Posted March 19, 2010 Share Posted March 19, 2010 how did you encode the values when you put them into the database? Quote Link to comment https://forums.phpfreaks.com/topic/195764-from-asp-recordsets-to-php/#findComment-1028412 Share on other sites More sharing options...
TapeGun007 Posted March 19, 2010 Author Share Posted March 19, 2010 In .asp (classic) I used this code: sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("\db\Choir.mdb") Set recordset = Server.CreateObject("ADODB.Recordset") IF Request.QueryString("NewsID") <> "" THEN intID = Request.QueryString("NewsID") Recordset.Open "News", sConnString, 1,2,2 Recordset.Filter = "NewsID = '" & intID & "'" Recordset("NewsDate") = Request.Form("fNewsDate") Recordset("NewsTitle") = Request.Form("fNewsTitle") Recordset("News") = Request.Form("fNews") Recordset("NewsWriter") = Request.Form("fNewsWriter") Recordset("ShowNews") = Request.Form("fShowNews") sMessage = "News Article Succesfully Updated!" Quote Link to comment https://forums.phpfreaks.com/topic/195764-from-asp-recordsets-to-php/#findComment-1028416 Share on other sites More sharing options...
The Little Guy Posted March 19, 2010 Share Posted March 19, 2010 what "Collation" are you using for that field? Quote Link to comment https://forums.phpfreaks.com/topic/195764-from-asp-recordsets-to-php/#findComment-1028420 Share on other sites More sharing options...
andrewgauger Posted March 19, 2010 Share Posted March 19, 2010 Check your database to see if it is encoded there. I believe the database has those characters stored. It looks to me you went from access db to mssql and that might be where the strange encoding happened. Look into a way to sanitize your stored data if it is encoded with those characters. PHP handles both ' and " appropriately by encoding them with a "\". Quote Link to comment https://forums.phpfreaks.com/topic/195764-from-asp-recordsets-to-php/#findComment-1028421 Share on other sites More sharing options...
TapeGun007 Posted March 19, 2010 Author Share Posted March 19, 2010 Collation is utf8_general_ci Using MyPHPAdmin, I checked the data and cut and pasted right out of the db: “The breath isn’t that important.” <p> …are you still reading? Good. Now let me explain my reasoning for saying such a blasphemous thing. So... the data in there is fine. Quote Link to comment https://forums.phpfreaks.com/topic/195764-from-asp-recordsets-to-php/#findComment-1028435 Share on other sites More sharing options...
The Little Guy Posted March 19, 2010 Share Posted March 19, 2010 I think your quotes are of the wrong format... You have: “ and ’ Try this: " and ' Quote Link to comment https://forums.phpfreaks.com/topic/195764-from-asp-recordsets-to-php/#findComment-1028437 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.