Help with PHP/MYSQL script

  • T
  • Beginner
  • Beginner
  • User avatar
  • Joined: Jul 14, 2006
  • Posts: 35
  • Loc: Springfield, Mo
  • Status: Offline

Post January 18th, 2008, 1:25 pm

I created a php script which pulls data from my mysql database and dsiplays it. When the title and description fields are displayed there are + signs instead of spaces.
What can I do to get my spaces back? I am sure this is a simple problem.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post January 18th, 2008, 1:25 pm

  • TsX
  • Graduate
  • Graduate
  • User avatar
  • Joined: Oct 09, 2004
  • Posts: 161
  • Status: Offline

Post January 18th, 2008, 3:45 pm

Seeing some code could help some to see how you are approaching to complete the task.

A plus sign in place of a space is commonly a result of url encoding. As url's cannot read certain characters they are converted to hex and spaces are converted to + signs.

I don't really see why this is happening the way you describe it because of the lack of information, but this function should help: urldecode($string)
  • T
  • Beginner
  • Beginner
  • User avatar
  • Joined: Jul 14, 2006
  • Posts: 35
  • Loc: Springfield, Mo
  • Status: Offline

Post January 22nd, 2008, 7:09 am

while($row = mysql_fetch_array($data))
{
echo '
<item>
<link>http://www.findapetonline.com/index/listings/page'.$row['id'].'.htm</link>
<title>'.$row['title'].'</title>
<description>'.$row['description'].'</description>
</item>';
}
// The "while" statement loops and grabs the
//last 50 items as we stated in our $data query.
// The <link> provides us with an anchor to the post
//on the main page. It is using the post ID from the database.
echo '


The above is the main part of the code! Hopefully this helps you figure out my problem, it is greatly appreciated! The problem is only in the title and description data. There are no spaces, + signs have replaced them.
  • spork
  • HB
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 5485
  • Loc: Rochester, NY
  • Status: Online

Post January 22nd, 2008, 7:26 am

Try using mysql_fetch_assoc() instead of mysql_fetch_array(). Have you tried TsX's suggestion?
How to Maintain Simple, Static Pages in a CakePHP Application
EEEEEEEEE! It's here!!
  • T
  • Beginner
  • Beginner
  • User avatar
  • Joined: Jul 14, 2006
  • Posts: 35
  • Loc: Springfield, Mo
  • Status: Offline

Post January 22nd, 2008, 8:12 am

The mysql_fetch_assoc() did not fix the prob.

As for the urlcode function I am unfamiliar with this one.
  • spork
  • HB
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 5485
  • Loc: Rochester, NY
  • Status: Online

Post January 22nd, 2008, 8:43 am

Familiarize yourself.

Where is the data coming from before it ends up in the database?
How to Maintain Simple, Static Pages in a CakePHP Application
EEEEEEEEE! It's here!!
  • T
  • Beginner
  • Beginner
  • User avatar
  • Joined: Jul 14, 2006
  • Posts: 35
  • Loc: Springfield, Mo
  • Status: Offline

Post January 22nd, 2008, 9:20 am

The data is entered by people who login and fill out a form.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 199 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© Unmelted Enterprises 1998-2009. Driven by phpBB © 2001-2009 phpBB Group.