| | |
this as apposed to [this]
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2009
Posts: 7
Reputation:
Solved Threads: 0
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 []
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 []
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.
•
•
Join Date: Jul 2009
Posts: 7
Reputation:
Solved Threads: 0
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>
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>
Replace ” or “ with " (just a regular quotation).
Replace ’ with ' (just an apostrophe)
Replace ’ with ' (just an apostrophe)
Google is your friend.
Use [code] tags.
If you have found a solution to your problem, please mark the thread as SOLVED.
Use [code] tags.
If you have found a solution to your problem, please mark the thread as SOLVED.
•
•
Join Date: Aug 2008
Posts: 381
Reputation:
Solved Threads: 33
Please use the CODE tags, found here http://www.daniweb.com/forums/misc-e...=400&width=680
It will help us examine your code.
Looks like you can not copy and paste out of the e-book, since you retain special character formatting (angled-quotes).
Hope this helps
It will help us examine your code.
php Syntax (Toggle Plain Text)
<?php /* Program: mysql_up.php * Desc: Connects to MySQL Server and * outputs settings. */ //echo; <html><head><title>Test MySQL</title></head><body>; echo "<html><head><title>Test MySQL</title></head><body>"; //$host=”localhost”; $host = "localhost"; //$user=”root”; $user = "root"; //$password=””; $password = ""; $cxn = mysqli_connect($host,$user,$password); //$sql=”SHOW STATUS”; $sql = "SHOW STATUS"; $result = mysqli_query($cxn,$sql); if($result == false) { //echo “<h4>Error: “.mysqli_error($cxn).”</h4>”; 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>”; echo "<table border=\"1\"><tr><th>Variable_name</th> <th>Value</th></tr>"; for($i = 0; $i < mysqli_num_rows($result); $i++) { //echo “<tr>”; 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 "<td>”.$row_array[$j].”</td>\n"; } } //echo “</table>”; echo "</table>"; } ?>
Looks like you can not copy and paste out of the e-book, since you retain special character formatting (angled-quotes).
Hope this helps
Google is the answer to all of your questions -- the trick is knowing what question to ask in your specific predicament.
Vtek,
Are you editing in MS Word? Guaranteed grief.
Use notepad, or my favourite 1st Page 2000/2006 by Evrsoft
Airshow
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.
50% of the solution lies in accurately describing the problem!
•
•
Join Date: Jul 2009
Posts: 7
Reputation:
Solved Threads: 0
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!
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!
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
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.
50% of the solution lies in accurately describing the problem!
•
•
Join Date: Jul 2009
Posts: 7
Reputation:
Solved Threads: 0
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.
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.
![]() |
Similar Threads
- Programming FAQ - Updated 1/March/2005 (Computer Science)
- Creating special classes (Java)
- computer to speakers (Troubleshooting Dead Machines)
- Ram Timings??? (Motherboards, CPUs and RAM)
- Class Constructor Shorthand (C++)
- which degree (IT Professionals' Lounge)
- PHP Beginner Here (PHP)
- Multiple PHP INCLUDES (PHP)
- XPpro to WinME networking from hell :( (Networking Hardware Configuration)
- Internet Explorer has been Hijacked. (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: creating an automatable autoresponder
- Next Thread: Don't wast your time with multiple $_GETS, $_POSTS, $_REQUEST, $rows
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dropdown dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube






