?
Solved

MySQL data not displaying on website

Posted on 2008-11-15
8
Medium Priority
?
148 Views
Last Modified: 2012-05-05
Hello,

My website is updated by entering data into a MySQL database through PHPMyAdmin.

Frustratingly, i am frequently plagued with problems using this approach and today is no exception! I have added several new records to my database and now when i view my site - none of the database records are displayed.

www.globexposure.net

Records are displayed as markers on my Google Map. You can see the individual markers/record data that is extracted from my database here:

www.globexposure.net/includes/read.php

Please can you help me diagnose the problem - i suspect there is special character or some such which is causing this problem but i can't see what exactly. I use a str_replace to try and pick these up but obviously something is missing (please see the attached script).


Many thanks
read.php.txt
0
Comment
Question by:Daniish
  • 4
  • 2
  • 2
8 Comments
 
LVL 17

Expert Comment

by:psimation
ID: 22967916
start by making sure your sql is actually returning values.

I usually echo the query if there are variables that needs substitution, but in your case, just run the query in your script in phpmyadmin and see if it returns rows.

Then, wrt "special" characters, use functions like stripslashes() and htmlspecialchars() as well as htmlentities() on your output.

0
 
LVL 17

Expert Comment

by:psimation
ID: 22967919
scrap the last part of my comment, I see u already do that - but do check your sql as a starting point.
0
 
LVL 39

Assisted Solution

by:Roger Baklund
Roger Baklund earned 2000 total points
ID: 22967970
I think there is something wrong with the function parseToXML() and how you use it.

You do some stuff with $xmlStr in this function, but in the end you return

return(htmlspecialchars(str_replace("#","<br /><br />",$htmlStr), ENT_QUOTES));

htmlspecialchars() translates < and > to < and >, but also translates & to &amp;

In line 65 you call this function like this:

parseToXML(htmlentities(...))

This applies to $row['exchange_rate'] and $row['national_dish']

htmlentities() does the same thing as htmlspecialchars. If these columns contains any html tags, they will be escaped twice, i.e. < becomes &amp;lt; and so on.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 39

Expert Comment

by:Roger Baklund
ID: 22967973
EE escapes these characters also, so it is hard to write this correctly...

htmlspecialchars() translates < and > to & lt; and & gt; (without the space between & and lt/gt !)
0
 

Author Comment

by:Daniish
ID: 22967994
Thanks CXR i shall have a good look at that.

My site was working properly a few hours ago and the only thing that has changed, is that i deleted 2 fields and added 6 new records.
Presumably its possible to export my newly added records to confirm they are not the cause - any idea how this is done (obviously i'll want to be able to import them again too)?
0
 
LVL 39

Accepted Solution

by:
Roger Baklund earned 2000 total points
ID: 22968029
create table temp_backup select * from TheTable where ...
delete from TheTable where ...

...and later:

insert into TheTable select * from temp_backup
0
 

Author Comment

by:Daniish
ID: 22968205
OK i did:

create table locations_backup select * from locations where id=166

How do i backup another record to locations_backup ?

e.g. i want to back up id = 167, 168, 171, 172, 173


Thanks again CXR
0
 
LVL 39

Assisted Solution

by:Roger Baklund
Roger Baklund earned 2000 total points
ID: 22968230
Like this:

insert into locations_backup select * from locations where id in (167, 168, 171, 172, 173)
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses
Course of the Month16 days, 22 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question