943,621 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 829
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Jul 27th, 2009
0

this as apposed to [this]

Expand Post »
Hows it going. Im brand spanking new to PHP and just lost my virginity to it today. The experience has been also similar, Awkward, and just going the wrong way about it, not to mention premature emotional ejacutlation after the installation and finding out that it wasnt satisfied with the work that I did, and refused to co-operate.
Anyway, long story short XAMMP saved the day. and I decided to test the PHP with a task from the dummies guide. Heres the sample code,
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<p>This is an HTML line<p>

<?php echo “This is a PHP line”; phpinfo();?>

</body></html>

The highlited text contained a Parse error when I viewed it in firefox on my local host, so remembering that the word "this" is a function or something like that, I cut the word out and the page worked perfectly in firefox.
So my question is, how can you get php to read function texts as normal content text. Im sure its as simple as adding a character before the word and if so which one? and if not, how do you work around this?
Thanks in advance and sorry if the code isnt in exact format ie []
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vtek is offline Offline
7 posts
since Jul 2009
Jul 27th, 2009
0

Re: this as apposed to [this]

You haven't used standard single or double quotes around the phrase (“This is a PHP line”; ) If you replace the quotes with standard ones (Vertical not angled) you won't have an error.
Last edited by chrishea; Jul 27th, 2009 at 8:40 pm.
Reputation Points: 210
Solved Threads: 228
Nearly a Posting Virtuoso
chrishea is offline Offline
1,389 posts
since Sep 2008
Jul 27th, 2009
0

Re: this as apposed to [this]

Thanks for the info. I have another code as part of the exercise for dummies, though I should get my hands on the retards guide to php =D
It contains errors also and was wondering if you could give it a quick lookover. I copied and pasted the text straight from the e-book so I think the author has sold everyone who has read it short.
example
<?php
/* Program: mysql_up.php
* Desc: Connects to MySQL Server and
* outputs settings.
*/
echo; <html>
<head><title>Test MySQL</title></head>
<body>;
$host=”localhost”;
$user=”root”;
$password=””;
$cxn = mysqli_connect($host,$user,$password);
$sql=”SHOW STATUS”;
$result = mysqli_query($cxn,$sql);
if($result == false)
{
echo “<h4>Error: “.mysqli_error($cxn).”</h4>”;
}
else
{
/* Table that displays the results */
echo “<table border=’1’>
<tr><th>Variable_name</th>
<th>Value</th></tr>”;
for($i = 0; $i < mysqli_num_rows($result); $i++)
{
echo “<tr>”;
$row_array = mysqli_fetch_row($result);
for($j = 0;$j < mysqli_num_fields($result);$j++)
{
echo “<td>”.$row_array[$j].”</td>\n”;
}
}
echo “</table>”;
}
?>
</body></html>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vtek is offline Offline
7 posts
since Jul 2009
Jul 27th, 2009
0

Re: this as apposed to [this]

Replace ” or “ with " (just a regular quotation).

Replace ’ with ' (just an apostrophe)
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Jul 27th, 2009
0

Re: this as apposed to [this]

Please use the CODE tags, found here http://www.daniweb.com/forums/misc-e...=400&width=680
It will help us examine your code.

php Syntax (Toggle Plain Text)
  1. <?php
  2. /* Program: mysql_up.php
  3. * Desc: Connects to MySQL Server and
  4. * outputs settings.
  5. */
  6. //echo; <html><head><title>Test MySQL</title></head><body>;
  7. echo "<html><head><title>Test MySQL</title></head><body>";
  8. //$host=”localhost”;
  9. $host = "localhost";
  10. //$user=”root”;
  11. $user = "root";
  12. //$password=””;
  13. $password = "";
  14. $cxn = mysqli_connect($host,$user,$password);
  15. //$sql=”SHOW STATUS”;
  16. $sql = "SHOW STATUS";
  17. $result = mysqli_query($cxn,$sql);
  18. if($result == false)
  19. {
  20. //echo “<h4>Error: “.mysqli_error($cxn).”</h4>”;
  21. echo "<h4>Error: ".mysqli_error($cxn)."</h4>";
  22. }
  23. else
  24. {
  25. /* Table that displays the results */
  26. //echo “<table border=’1’>
  27. //<tr><th>Variable_name</th>
  28. //<th>Value</th></tr>”;
  29. echo "<table border=\"1\"><tr><th>Variable_name</th>
  30. <th>Value</th></tr>";
  31.  
  32. for($i = 0; $i < mysqli_num_rows($result); $i++)
  33. {
  34. //echo “<tr>”;
  35. echo "<tr>";
  36. $row_array = mysqli_fetch_row($result);
  37. for($j = 0;$j < mysqli_num_fields($result);$j++)
  38. {
  39. //echo “<td>”.$row_array[$j].”</td>\n”;
  40. echo "<td>”.$row_array[$j].”</td>\n";
  41. }
  42. }
  43. //echo “</table>”;
  44. echo "</table>";
  45. }
  46. ?>

Looks like you can not copy and paste out of the e-book, since you retain special character formatting (angled-quotes).

Hope this helps
Reputation Points: 30
Solved Threads: 36
Posting Whiz
langsor is offline Offline
389 posts
since Aug 2008
Jul 27th, 2009
0

Re: this as apposed to [this]

Vtek,

Are you editing in MS Word? Guaranteed grief.

Use notepad, or my favourite 1st Page 2000/2006 by Evrsoft

Airshow
Last edited by Airshow; Jul 27th, 2009 at 10:45 pm.
Sponsor
Reputation Points: 300
Solved Threads: 357
WiFi Lounge Lizard
Airshow is offline Offline
2,524 posts
since Apr 2009
Jul 28th, 2009
0

Re: this as apposed to [this]

Thanks a million to everyone who posted their help comments, I really appreciate it.
I think your'e right langsor, although Its a pain in the ass reading then typing as opposed to copying and pasting i'll have to do it, plus I think that I might actually LEARN some of the code doing it this way.
and no I'm note using wordpad, I learned the hard way a while back after trying to make a website using word pad.
It wasnt pretty!
Could you tell me is there any software (freeware, opensource) that checks syntax for you? or better still is there something like notepad available but aimed more towards scripting with syntax error checking functions on it?
Thanks a bunch!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vtek is offline Offline
7 posts
since Jul 2009
Jul 28th, 2009
0

Re: this as apposed to [this]

Vtek,

1st Page 2000 is free, I think they charge for v2006 but 2000 is very capable (it's the one I use).

It doesn't go as far as you want but it colour-codes scripts such that many errors are easy to spot.

(I'm so pleased you're not using Word or Wordpad)

Airshow
Last edited by Airshow; Jul 28th, 2009 at 9:07 am.
Sponsor
Reputation Points: 300
Solved Threads: 357
WiFi Lounge Lizard
Airshow is offline Offline
2,524 posts
since Apr 2009
Jul 28th, 2009
0

Re: this as apposed to [this]

Thanks Airshow. I maybe a newb but im not completley out of touch =D
I got 1stpage so thanks for the link.
I also came accross a program called Dev-PHP, Ever heard of it?

http://dev-php.software.informer.com/

It looks pretty cool and just as in depth as first page but I dont think I configured it properly, as Im getting a couple of error messages when trying to use some specific functions.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vtek is offline Offline
7 posts
since Jul 2009
Jul 28th, 2009
0

Re: this as apposed to [this]

Vtek,

I don't know Dev-PHP. Maybe I will take a look ... thanks.

Airshow
Sponsor
Reputation Points: 300
Solved Threads: 357
WiFi Lounge Lizard
Airshow is offline Offline
2,524 posts
since Apr 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: creating an automatable autoresponder
Next Thread in PHP Forum Timeline: ftp_put Problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC