Jump to content

[SOLVED] Picture Specific Size


Solar

Recommended Posts

Oh my, I feel so newbish! But this is not working out. This is for the user's picture on their profile page and I want a specific height and width, I will use 150x150 to deminstrate.

 

This code does not work..

 

<?php
echo "<img src=http://72.38.175.121/photo/".$req_user_info['username']." width="150" height="150">";
?>

 

I have to echo it to make; ".$req_user_info['username']." to work. Then the width and height becomes the problem.

 

Error:

Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';' in C:\xampp\htdocs\userinfo.php on line 81

Link to comment
Share on other sites

use backslashes on all double quotes that are inside double qoutes

 

<?php
echo "<img src=\"http://72.38.175.121/photo/".$req_user_info['username']." width=\"150\" height=\"150\" >";
?>

 

you can put brackets in double quotes as well just put them inside {}

 

<?php
echo "<img src=\"http://72.38.175.121/photo/{$req_user_info['username']}\" width=\"150\" height=\"150\" >";
?>

Link to comment
Share on other sites

Thank you for your help so far and I see where you are getting with this. But what you just wrote for the second time would be the exactly the same as your first code. I can't substitute $username = $username because that wont work, I can't substitute $username = ".$req_user_info['username']."  because I recieve the same error as the first time.

 

I think this is a tricky one :)

Link to comment
Share on other sites

What do you get if you use:

 

<?php
echo "<img src=\"http://72.38.175.121/photo/".$req_user_info['username']." width=\"150\" height=\"150\" >";
?>

 

Same error posted above. :P I added;

<?php
echo "<img src=\"http://72.38.175.121/photo/".$req_user_info['username']."\ width=\"150\" height=\"150\" >";
?>

 

Gives me;

"http://72.38.175.121/photo/Steven\%20width="

 

Some reason its thinking that the width and height is part of the URL and stops at the first quotation mark. :P I'll play with it untilll we figure it out :)

Link to comment
Share on other sites

if the image source is http://72.38.175.121/photo/Steven then you won't see anything on screen only in your source code.

 

It is strange how your getting no space between the username and width though.

 

Haha, I know thats why I thought I'd ask.

 

I'm working this on a different page;

http://72.38.175.121/userinfo2.php?user=Steven

 

It will be a pain if people upload there big pictures ;)

Link to comment
Share on other sites

I got it man..

 

echo "<img src=\"http://72.38.175.121/photo/".$req_user_info['username']."\"\width=\"150\" height=\"150\" >";

 

I added an extra "\

 

That way there the width and the height are not acting like links.

 

Thanks for all your help!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.