Author Topic: What's wrong?  (Read 579 times)

0 Members and 1 Guest are viewing this topic.

Offline Pi_MastuhTopic starter

  • Enthusiast
  • Posts: 233
  • Gender: Female
    • View Profile
What's wrong?
« on: August 26, 2006, 11:16:29 PM »
I'm making a page where when you click on a picture a page pops up with the info about the item. i'm using
$itemName
and
echo '<img src=../images/items/'.$image.'.jpg>';
When the page comes up for an item with spaces in the name it just shows up as the first word and none of the data is displayed because it's an invalid item name. What's wrong? ???
Schroedinger's Cat walks into a bar.
And doesn't.

Offline AndyB

  • back from the North Pole ... and retired!
  • Staff Alumni
  • Freak!
  • *
  • Posts: 8,521
  • php 5.2.3 / MySQL 5.0.27
    • View Profile
    • halfadot smallwebs
Re: What's wrong?
« Reply #1 on: August 27, 2006, 01:09:32 AM »
Without code to look at, it's anybody's guess as to what's wrong.

Is this some kind of database question?

Possibly solution if it is, would be to pass the database record ID instead of name. Alternatives are to use urlencode() and urldecode() [check the manual for details] so that the spaces in names can be handled.
Legend has it that reading the manual never killed anyone.
My site

Offline Pi_MastuhTopic starter

  • Enthusiast
  • Posts: 233
  • Gender: Female
    • View Profile
Re: What's wrong?
« Reply #2 on: August 27, 2006, 01:15:59 AM »
I don't know what you mean...
Schroedinger's Cat walks into a bar.
And doesn't.

Offline AndyB

  • back from the North Pole ... and retired!
  • Staff Alumni
  • Freak!
  • *
  • Posts: 8,521
  • php 5.2.3 / MySQL 5.0.27
    • View Profile
    • halfadot smallwebs
Re: What's wrong?
« Reply #3 on: August 27, 2006, 01:19:54 AM »
I don't know what you mean...

OK, we're even.

You have some kind of problem with some kind of code and neither I nor anyone else can solve it without seeing some code. You already have my best guesses as to what the solution might be. Did you look at the manual pages for the urlencode() and urldecode() functions?
Legend has it that reading the manual never killed anyone.
My site

Offline Pi_MastuhTopic starter

  • Enthusiast
  • Posts: 233
  • Gender: Female
    • View Profile
Re: What's wrong?
« Reply #4 on: August 27, 2006, 01:22:04 AM »
What manual? And I posted the code up there. The rest is just the borders and stuff for the table.
Schroedinger's Cat walks into a bar.
And doesn't.

Offline AndyB

  • back from the North Pole ... and retired!
  • Staff Alumni
  • Freak!
  • *
  • Posts: 8,521
  • php 5.2.3 / MySQL 5.0.27
    • View Profile
    • halfadot smallwebs
Re: What's wrong?
« Reply #5 on: August 27, 2006, 01:34:15 AM »
The manual - www.php.net - has explanations and examples of 'everything' relating to php.  Here's an example - http://ca.php.net/manual/en/function.urlencode.php

As for posting all your code, no you haven't. You posted one img tag and a disconnected variable.  You don't show the code for what get's clicked and you show nothing whatsoever relating to details not showing when something is clicked.

If you want people to devote their time to your problems you need to develop two good habits.  #1 fully explain and illustrate the problem; #2 look at the manual references people offer in their replies.

Good luck with your problem.
Legend has it that reading the manual never killed anyone.
My site

Offline kenrbnsn

  • Guru
  • Freak!
  • *
  • Posts: 9,708
  • Gender: Male
    • View Profile
Re: What's wrong?
« Reply #6 on: August 27, 2006, 10:26:29 AM »
If people would get into the habit of enclosing values of attributes in quotes (double or single depending on the situation), problems like this wouldn't happen.

In your case:
Code: [Select]
<?php echo '<img src="../images/items/'.$image.'.jpg">'?>
Ken