Solar Posted January 24, 2009 Share Posted January 24, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/ Share on other sites More sharing options...
nuttycoder Posted January 24, 2009 Share Posted January 24, 2009 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\" >"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/#findComment-745036 Share on other sites More sharing options...
Solar Posted January 24, 2009 Author Share Posted January 24, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/#findComment-745041 Share on other sites More sharing options...
nuttycoder Posted January 24, 2009 Share Posted January 24, 2009 yeah I noticed mistakes in my code I've updated it Quote Link to comment https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/#findComment-745042 Share on other sites More sharing options...
Solar Posted January 24, 2009 Author Share Posted January 24, 2009 Both show as "http://72.38.175.121/photo/Steven%20width="" Quote Link to comment https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/#findComment-745043 Share on other sites More sharing options...
nuttycoder Posted January 24, 2009 Share Posted January 24, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/#findComment-745050 Share on other sites More sharing options...
Solar Posted January 24, 2009 Author Share Posted January 24, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/#findComment-745056 Share on other sites More sharing options...
nuttycoder Posted January 24, 2009 Share Posted January 24, 2009 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\" >"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/#findComment-745059 Share on other sites More sharing options...
Solar Posted January 24, 2009 Author Share Posted January 24, 2009 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. 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. I'll play with it untilll we figure it out Quote Link to comment https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/#findComment-745063 Share on other sites More sharing options...
nuttycoder Posted January 24, 2009 Share Posted January 24, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/#findComment-745068 Share on other sites More sharing options...
Solar Posted January 24, 2009 Author Share Posted January 24, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/#findComment-745070 Share on other sites More sharing options...
nuttycoder Posted January 24, 2009 Share Posted January 24, 2009 you can restrict the actual file size or better yet resize their image on upload. Quote Link to comment https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/#findComment-745072 Share on other sites More sharing options...
Solar Posted January 24, 2009 Author Share Posted January 24, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/#findComment-745073 Share on other sites More sharing options...
nuttycoder Posted January 24, 2009 Share Posted January 24, 2009 your welcome glad you got it working. Quote Link to comment https://forums.phpfreaks.com/topic/142215-solved-picture-specific-size/#findComment-745091 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.