String help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

String help

Post by Addos »

When I mouse over the link on this page the URL parameter returns http://www.mysite.com/\”admin_images_insert.php\” can anyone help me clean up this string?
Below is the little big of code I’m using to produce the link.
Thanks

Code: Select all

"$file_name uploaded successfully." .'<a href="admin_images_insert.php">'. "Upload main image now and details" .' </a>'
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Code: Select all

echo "$file_name uploaded successfully.";
?>
<a href="admin_images_insert.php">Upload main image now and details</a>
<?php
// whatever comes next
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Post by Addos »

Code: Select all

$message = ($result)?"$file_name uploaded successfully." .'<a href="admin_images_insert.php">'. "Upload main image and details" .' </a>' : "Something is wrong with uploading a file."; 
  	return $message;
Hi,
This is the entire string.
Thanks
Brian
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

That's ugly code man. Don't use ? : for anything other than the smallest statements.
In fact forget it exists altogether.

Code: Select all

if ($result) {
	$message = $file_name . 'uploaded successfully. <a href="admin_images_insert.php">Upload main image and details</a>';
} else {
	$message = 'Something is wrong with uploading a file.';
}
return $message;
Addos
Forum Contributor
Posts: 305
Joined: Mon Jan 17, 2005 4:13 pm

Post by Addos »

Hi ya,
Thanks for this help. My only problem is that I still get the “ and \ showing up (see below) when I mouse over the link and I’ve no idea where these are coming from?
Any ideas?
Thanks a mil
Brian

http://www.mysite.com/\”admin_images_insert.php”\
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Well that's because that output isn't coming the code you gave me.
Read about strings and learn how to fix these things yourself or you will forever be coming back here.
Post Reply