Jump to content

36pixels

Members
  • Posts

    15
  • Joined

  • Last visited

36pixels's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. But are the buttons displaying as it should?
  2. How can that be possible!!Either you are joking with me or you must have changed the code somewhere!!Then give me your code please
  3. Yes I am getting parse error!!I already mentioned the error right in the begining of this post,still i repeat itParse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in I:\xampp\htdocs\..\..\button\make_button.php on line 21Also line 21 is this code above - putenv('GDFONTPATH=c:\windows\fonts');
  4. Birbal your explnations are always a little vague and insuffiecient.Can you pls elucidate more detail?I will be vry greatful if you or someone else can help me.
  5. Hi birbal,Thanks for reply but that is not where i am getting error from.In fact I already tried this out- header("content-type:image/png"); But still I am getting the error and specifically the line is - putenv('GDFONTPATH=c:\windows\fonts');
  6. Hi, I am trying to learn php and when I feel i understand a concept I like to try it out by writing a script or two. I am currently attempting to create an image on the fly, like a button. I kept receiving the message:Warning: imagecreatefrompng(red-button.png) [function.imagecreatefrompng]: failed to open stream: No such file or directory. Then I commented line no. 15 and line no. 43 and added the line 44:header("content-type:image/png.jpeg."); But now I get the error : Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in I:\xampp\htdocs\test\button\make_button.php on line 21Could someone please take a look at this for me and tell me what you think I've done wrong?? I would really appreciate it, I've looked at it until my eyes have about gone on strike. Here is the code: <form name ="button" action ="make_button.php" method="post"><input type ="text" name = "button_text"> <p><label><input type="radio" name="color" value="red" id="red">Red</label> <label><input type="radio" name="color" value="green" id="green">Green</label> <input type="radio" name="color" id="blue" value="blue">Blue</label></p> <input type ="submit" name ="submit" value ="CREATE!"></form> <?php$button_text=$_POST['button_text'];$color=$_POST['color']; if(empty($button_text)||empty($color)){echo 'Could not create image - form not filled out correctly';exit;} $im=imagecreatefrompng('\button'.$color.'-button.png'); $width_image=imagesx($im);$height_image=imagesx($im); $width_image_wo_margins=$width_image-(2*18);$height_image_wo_margins=$height_image-(2*18); $font_size=33; //putenv('GDFONTPATH=C:\WINDOWS\Fonts');$fontname='arial';do{ $font_size--; $bbox=imagettfbbox($font_size,0,$fontname,$button_text); $right_text=$bbox[2]; $left_text=$bbox[0]; $width_text=$right_text - $left_text; $height_text=abs($bbox[7]-$bbox[1]);}while($font_size>8 && ($height_text>$height_image_wo_margins||$widht_text>$width_image_wo_margins));if($height_text>$height_image_wo_margins||$widht_text>$width_image_wo_margins){ echo 'Text given will not fit on button.<br>';}else{ $text_x=$width_image/2.0-$width_text/2.0; $text_y=$height_image/2.0-$height_text/2.0; if($left_text<0) $text_x+=abs($left_text); $above_line_text=abs($bbox[7]);$text_y +=$above_line_text;$text_y -=2;$white=imagecolorallocate($im,255,255,255);imagettftext($im,$font_size,0,$text_x,$text_y,$white,$fontname,$button_text);//header('Content-type:image/png');header("content-type:image/png.jpeg."); imagepng($im);}imagedestroy($im);?>
  7. Ok I thanked both of you.
  8. Hi :)Thanks Everybody for their helpful answers.I tried the Error Console as per Ingolme's advice, and here is what i get-"Error: img1 is not definedLine: 1" Now the effect is coming but I dont know why the " img1 is not defined" error is given! Can anyone pls tell me? Also,I dont understand what Line 1 is because the code is not in line no 1 of my program!!Can anyone tell me what line number in the error console indicates?
  9. Hi Ingolme,Thanks for the reply but I tried this code as per your suggestions and it still donot work!!Code: <HTML><HEAD> <TITLE> New Document </TITLE><script type="text/JavaScript">function ch(img1){ document.getElementById('a').src="2.jpg";}function ch1(img1){ document.getElementById('a').src="3.jpg";}</SCRIPT></HEAD><BODY> <A onmouseover="ch(img1)" onmouseout="ch1(img1)"><IMG SRC="1.jpg" WIDTH="140" HEIGHT="160" BORDER="0" id='a'></A></BODY></HTML> BTW, "a" here is id name and not string name!!
  10. HiI am trying to create a webpage using two image files,which switch between one another as the mouse pointer moves over the images.I am using the onMouseover and onMouseout event handlers.I tried the following code but it is not working!!Please tell me how can I make this code work.Please dont tell me about jquery or anything else. <HTML><HEAD> <TITLE> New Document </TITLE><script type="text/JavaScript">ch(img1){ document.getElementById(a).src=2.jpg;}ch1(img1){ document.getElementById(a).src=3.jpg;}</SCRIPT></HEAD><BODY> <A onmouseover="ch(img1)" onmouseout="ch1(img1)"><IMG SRC="1.jpg" WIDTH="140" HEIGHT="160" BORDER="0" ALT="" id=a></A></BODY></HTML>
  11. HiI have a typical problem where I want to sort a table on a field which is in another table but the foreign key is different.What I mean is this-I have a table called 'staff ' with 2 fields -1)"id"(primary key) and 2)"staff_cat" as the 2nd field.Now I have another table called "stf_cat" where it has 3 fields -1)id(Primary key) ie it is auto-incremented and hence it is acting as a serial number.2)sid(short for Serial ID which represents the 'id' field of the 'staff' table.Basically this is kind of a foreign key as I mentioned above .ie. 'id' of staff table=='sid' of stf_cat table)3)The last field of this table is named "sub_cat"(short for sub category). Basically staff_cat field has values like "Teacher","Staffs","Game Teacher" etc etc like this on..And sub_cat field has values like Arts,Science,Commerce etc etc for the staff_cat "Teacher",similarly sub_cat field has values like Hockey,Cricket,BasketBall,Tennis etc etc for the staff_cat "Game Teacher",similarly for staff there is Grade 1,Grade2 "sub_cat" under the staff_cat -"staff".Now my problem is I am to display a table on the browser with the fields "sid","staff_cat","sub_cat" but it should be sorted either in ascending/desc order by staff_cat names.I have tried a lot of ways but i cannot manage to get the sub_cat names in the table.How to do that?Any help would be greatly appreciated.
  12. Ya I already expected thee answer. I realized that body is the parent here and all other are childs!! Thanks all of you. Topic is closed
  13. Hi CodeName,You replied .But here the parent element is the <p> tag and so accordingly <p>The first paragraph.</p> will be the first child i.e. nth-child(1),and <p>The second paragraph.</p> .How can <h1> be a child of <p>??Plz explain to me.How come you take <h1> as a child of the <p> tag?? I dont understand at all your explanation is not OK!!Please see that the parent element is <p> tag and not <h1> tag in my posted code. p:nth-child(2){background:#ff0000;} Lastly can you tell me who is the parent here?
  14. Hi disonesuk,I think this will work - nth-of-type(2){background:#ff0000;} But like you I also wonder why nth-cild doesn't work here!!Anyone has any explanation to these?
  15. I found this code in w3schools for nth child- <!DOCTYPE html><html><head><style type="text/css">p:nth-child(2){background:#ff0000;}</style></head><body><h1>This is a heading</h1><p>The first paragraph.</p><p>The second paragraph.</p><p>The third paragraph.</p><p>The fourth paragraph.</p><p><b>Note:</b> Internet Explorer does not support the :nth-child() selector.</p></body></html> My question is, why this line- p>The first paragraph.</p> assigned the 2nd child and why not the value=1?If I replace the code p:nth-child(2){background:#ff0000;} with the code- p:nth-child(1){background:#ff0000;} it doesn't color the line -"The first paragraph". Why is this anamoly?IThe above line should be the first child or n=1,isn't it??
×
×
  • Create New...