Jump to content


Photo

PHP and HTML Help


  • Please log in to reply
6 replies to this topic

#1 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 13 March 2006 - 01:27 AM

<?php
require_once "maincore.php";
require_once "subheader.php";
require_once "side_left.php";
$imageid= $_GET["id"];
$result = mysql_query("SELECT * FROM files WHERE id=$imageid"); 
$myrow = mysql_fetch_array($result); 
?>
<html><center>
<img src="<?php echo $myrow["idpath"]; ?>"/></center>
<br /><center>
<table width="551" height="54" border="1">
  <tr>
    <td><?php echo $myrow["description"];?></td>
    </center>Description: 
  </tr>
</table></center>
<a href="nfndf">dndnf</a><br />
<br />
<center>
  <p>&nbsp;</p>
  <p>Share With Your Friends!</p>
</center>
HTML: <input type="text" name="thetext" size="80" value="<a href="http://starcraftarena.roxr.com/fusion/"><img src="<?php echo $myrow["idpath"]; ?></a>"><Br />
BBCODE: <input type="text" name="thetext" size="80" value="[url=http://starcraftarena.roxr.com/fusion/][img]<?php echo $myrow["idpath"]; ?>[/img][/url]"><br />
AIM Profile: 
<input name="thetext" type="text" value="<a href="http://starcraftarena.roxr.com/fusion/viewimage.php?id=<?php echo $myrow["id"]?>">HELLO</a>" size="80" />
<Br />
</html>
<?php
require_once "side_right.php";
require_once "footer.php";
?>

Before I even tried testing the script, I know its not gonna work.

AIM Profile: 
<input name="thetext" type="text" value="<a href="http://starcraftarena.roxr.com/fusion/viewimage.php?id=<?php echo $myrow["id"]?>">HELLO</a>" size="80" />

There are 2 quotes ( " ) so it obviously wont work. Same with line 25. Is there any way around this?


#2 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 13 March 2006 - 01:43 AM

You should have tried it before posting because I don't see any syntax problems. Why do you think there's a problem with double quotes?

The code shown is primarily in HTML mode with occasionally echoing PHP data. You're fine.


#3 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 13 March 2006 - 01:49 AM

Thats not the problem. I am trying to make a "imageshack" clone, where after you upload the file the html code or bbcode appears.

The bbcode comes out fine, but the ones with 2 quotes come out like this: [a href=\"http://starcraftarena.roxr.com/fusion/viewimage.php?id=30\" target=\"_blank\"]http://starcraftarena.roxr.com/fusion/viewimage.php?id=30[/a]

#4 sgb162

sgb162
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 13 March 2006 - 02:26 AM

Try changing

<input name="thetext" type="text" value="<a href="http://starcraftarena.roxr.com/fusion/viewimage.php?id=<?php echo $myrow["id"]?>">HELLO</a>" size="80" />

to

<input name="thetext" type="text" value="<a href="http://starcraftarena.roxr.com/fusion/viewimage.php?id=<?php echo $myrow["id"]; ?>">HELLO</a>" size="80" />

and see what happens.

#5 lpxxfaintxx

lpxxfaintxx
  • Members
  • PipPipPip
  • Advanced Member
  • 181 posts

Posted 13 March 2006 - 02:58 AM

Nope, same exact thing.

#6 toplay

toplay
  • Staff Alumni
  • Advanced Member
  • 973 posts

Posted 13 March 2006 - 03:07 AM

Use single quotes:
[!--html--][div class=\'htmltop\']HTML[/div][div class=\'htmlmain\'][!--html1--]<input name="thetext" type="text" size="80" value='<[span style=\'color:blue\']a href="http://starcraftarena.roxr.com/fusion/viewimage.php?id=<?php echo $myrow["id"]; ?>[/span]">HELLO</a>'/>[!--html2--][/div][!--html3--]

#7 phporcaffeine

phporcaffeine
  • Members
  • PipPipPip
  • Advanced Member
  • 361 posts
  • LocationOhio, USA

Posted 13 March 2006 - 05:26 AM

Ahhh PHP and quotes - they play so nice together

General Rules Of Thumb

In PHP:

When echoing you should always try to use echo " " The dbl quotes allow for variable evaluation inside the echo whereas echo ' ' would return a literal echo.

If your echo requires the echoing of a dbl quote you MUST precced it with a '\' deliminator.

When echoing an array element outside of an echo use single quotes $my_array['element']

When echoing an array element inside an echo you don't want ANY quotes echo "$my_array[element]"

If your array is keyed with an int Vs. text then you NEVER use quotes of any type.


Thanks,

Ryan Huff
President & Founder, MyCodeTree
support@mycodetree.com | http://mycodetree.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users