Jump to content

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
https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/
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\" >";
?>

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\xampp\htdocs\userinfo.php on line 82

 

I think I allready tried that. Seems like there are to many slashes.

 

 

Backslashes shows my picture as..

 

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

 

Nothing else :P

I've just ran this code

 

$name = 'dave';
echo "<img src=\"http://72.38.175.121/photo/{$name}\" width=\"150\" height=\"150\" >";

 

Outputs

<img src="http://72.38.175.121/photo/dave" width="150" height="150" >

 

won't show in the page as there is no image there.

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 :)

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 :)

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 ;)

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.