PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 7th, 2005, 07:49 AM
boardy boardy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Posts: 5 boardy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 46 m 52 sec
Reputation Power: 0
Help needed with - parse error, unexpected T_CONSTANT_ENCAPSED_STRING

Hi,

I'm new here and have a slight issue with some code I'm trying to sort.

Im getting the following error -

Quote:
PHP Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING


This is when using the following code -

PHP Code:
<html>
<
body>

<?
php
// connect to server
mysql_connect'localhost','root','root')
or die( 
"Couldnt connect to server" .mysql_error());

// select db
mysql_select_db('netshift')
or die( 
"Couldnt connect to db" .mysql_error());
if (
$_GET['id'])
    {
//Put update sql to change com status for machine
$sql "update machine set com='$_GET[com]', timestamp = now() WHERE id='$_GET[id]'";
    
    }

// Retrive rows from table
$query "SELECT machine.*, client.name AS client_name FROM machine JOIN client WHERE machine.client_id = client.id";
$results mysql_query($query);

// print results
if($results)
{

    print 
"<TABLE CELLPADDING=\"1\" CELLSPACING=\"4\" BORDER = \"1\"";
    print 
"<tr><td>Client</td><td>Machine</td><td>Communicating</td><td>Updated</td><td>On</td><td>Off</td></tr>";

    while(
$client_tab mysql_fetch_object($results))
        {
            
// print out info";
            
$client $client_tab -> client_name;
            echo(
"<td>$client</td>");
            
$mid $client_tab -> id;
            
$mname $client_tab -> name;
            echo(
"<td>$mname</td>");
            
$com $client_tab -> com;
            echo(
"<td>$com</td>");
            
$timestamp $client_tab -> timestamp;
            echo(
"<td>$timestamp</td>");
            print 
"<td><a href='index.php?id=".$mid."&com=1>YES</a> <a href='index.php?id=".$mid."&com=0>NO</a></td>";
            print 
"<td bgcolor=";
                if (
$com) print green"></td></tr>";
                else print 
red"></td></tr>";
        }
        print 
"</TABLE>";
    }
    else
    {
        die(
"Couldnt connect to db tables." .mysql_error());
    }

?>

</body>
</html> 


Any help on this would be great please. I've been trying to make it work for a while but I can't seem to find the problem.

Cheers
Adam

Reply With Quote
  #2  
Old November 7th, 2005, 07:56 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
It looks like your quotes are off by a bit.
Code:
                if ($com) print green"></td></tr>";
                else print red"></td></tr>"; 


Try this:
PHP Code:
if ($com) print "green></td></tr>";
else print 
"red></td></tr>"

Reply With Quote
  #3  
Old November 7th, 2005, 08:50 AM
boardy boardy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Posts: 5 boardy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 46 m 52 sec
Reputation Power: 0
Thats great, it worked. I now have a coloured block where I was expecting it, only problem is, that it doesn't change colour if I click on the correct button.

I've been trying to figure out why but everything I try to do doesn't work. I have even gone and added a com in the phpMyAdmin to see if it changed the colour with no luck. I also don't think that its updating the table.

The code is now

PHP Code:
<?php
// connect to server
mysql_connect'localhost','root','root')
or die( 
"Couldnt connect to server" .mysql_error());

// select db
mysql_select_db('netshift')
or die( 
"Couldnt connect to db" .mysql_error());
if (
$_GET['id'])
    {

//Put update sql to change com status for machine
$sql "UPDATE machine SET coms='$_GET[coms]', timestamp = now() WHERE id='$_GET[id]'";

    }

// Retrive rows from table
$query "SELECT machine.*, client.name AS client_name FROM machine JOIN client WHERE machine.client_id = client.id";
$results mysql_query($query);

// print results
if($results)
{

    print 
"<TABLE CELLPADDING=\"1\" CELLSPACING=\"4\" BORDER = \"1\"";
    print 
"<tr><td>Client</td><td>Machine</td><td>Communicating</td><td>Updated</td><td>On</td><td>Off</td></tr>";

    while(
$client_tab mysql_fetch_object($results))
        {
            
// print out info";
            
$mid $client_tab -> id;
            
$client $client_tab -> client_name;
            echo(
"<td>$client</td>");
            
$mname $client_tab -> name;
            echo(
"<td>$mname</td>");
            
$com $client_tab -> coms;
            print 
"<td bgcolor=";
                if (
$com="1") print "green></td>";
                else print 
"red></td>";
            
$timestamp $client_tab -> timestamp;
            echo(
"<td>$timestamp</td>");
            print 
"<td><a href='index.php?id=$mid&coms=1'>Comms</a></td>";
            print 
"<td><a href='index.php?id=$mid&coms=0'>No Comms</a></td></tr>";
        }
        print 
"</TABLE>";


If anyone can help with this, I'd be so gratefull.

Cheers
Ad

Reply With Quote
  #4  
Old November 8th, 2005, 04:54 AM
Itsacon's Avatar
Itsacon Itsacon is offline
Command Line Warrior
Click here for more information
 
Join Date: Aug 2004
Location: Sector ZZ9 Plural Z Alpha
Posts: 1,029 Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)Itsacon User rank is Lance Corporal (50 - 100 Reputation Level)  Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6Folding Points: 2966446 Folding Title: Super Ultimate Folder - Level 6
Time spent in forums: 1 Week 12 h 55 m 59 sec
Reputation Power: 16
Send a message via ICQ to Itsacon
try replacing
PHP Code:
if ($com="1"

with
PHP Code:
if ($com=="1"
__________________
This is my code. Is it not nifty?

"The biggest problem encountered while trying to design a system that was completely foolproof, was, that people tended to underestimate the ingenuity of complete fools."
---Douglas Adams


Join the Itsacon fanclub!    
Zero Tolerance: Spammers banned so far: 592

Reply With Quote
  #5  
Old November 8th, 2005, 06:31 AM
boardy boardy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Posts: 5 boardy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 46 m 52 sec
Reputation Power: 0
Hi Itsacon. I just tried that but nothing It's as if it's not taking any notice of that bit at all and just displaying green for everything. I have tried to set the 1 or 0 in phpMyAdmin manually but no change.

Cheers for help
Ad

Reply With Quote
  #6  
Old November 8th, 2005, 09:12 AM
boardy boardy is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Posts: 5 boardy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 46 m 52 sec
Reputation Power: 0
Figured out what I did now. Was sat here looking at the code and had a brainwave, realised I had my MySQL params set just no call to them, added mysql_query($sql) and hey presto it all works perfectly.

Cheers for the help
Ad

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Help needed with - parse error, unexpected T_CONSTANT_ENCAPSED_STRING


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap