GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rating: Thread Rating: 2 votes, 4.50 average.
  #21  
Old 20-Mar-2005, 10:40
idenr idenr is offline
New Member
 
Join Date: Mar 2005
Posts: 2
idenr is on a distinguished road

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'


I'm working on the O'Reilly "Learning PHP 5" (problem 4 in chapter 7 if it makes it quicker and easier for you). I am stymied as to why I can't reference the value of $_POST['phone'] for example. When I var_dump $_POST it will give me a nice report that the key 'phone' is in there and what it's value is but I can't get at it from my code and I know this is maybe a fundamental misunderstanding that most beginners must have about what to do with $_POST. I can't think of how to debug this type of error except debugging my understanding of $_POST.

PHP Code:

<?php
require 'DB.php';
require 'formhelpers.php';
$db = DB::connect('mysql://iden:iden@localhost/test');
if (DB::isError($db)) {die("Can't connect: ".$db->getMessage());};
$db->setErrorHandling(PEAR_ERROR_DIE);
$db->setFetchMode(DB_FETCHMODE_OBJECT);

//Create TABLE customers (
//                customerID INT unsigned,
//                name VARCHAR(255),
//                phone     VARCHAR(15),
//                favoriteDishID INT unsigned
//                )

//main
{
print "<html><body>\n";
// Get array of dish names to put in menu
global $db;

$q = 'select distinct dish_name from dishes'; // table already exists
$results = $db->query($q);
    while ($row = $results->fetchRow()) {
        $dish_names[] = $row->dish_name;
    }
// done getting our menu choices form the dishes table    
if ($_POST['_submit_check']) {
    if ($errors = validate()) {
        show_form($errors);
    } else {
        do_form();
    } 
} else {
        show_form($errors);
    }
print "</body></html>\n";
}

function do_form() {
global $db;
    print "<p>doing form</p>";
    $record_id = $db->nextID('customers');
//    $q = 'INSERT INTO customers'; 
//    $q .= '(record_id,name,phone,favoriteDish, values(?,?,?,?),'; 
//    $q .= 'array($record_id,$_POST[\'name\'],$_POST[\'phone\'],$_POST[\'favoriteDishID\'])'; 
//print $q; 
echo '<pre>'; var_dump ($_POST); print'</pre>';

// problem line is next with parse error
print '<pre>'; echo "$_POST['phone']"; print'</pre>'; // here
// problem line with parse error above

echo '<pre>'; var_dump ($GLOBALS['dish_names']); print'</pre>';
echo '<pre>';
//echo "$_POST['favoritDishID']";
print'</pre>';
//    $res = $db->query($q);
}

function show_form ($errors) {
global $dish_names;
    $defaults = array();
    if ($_POST['_submit_check']) { $defaults = $_POST; }
    if ($errors) {
        print "<p>The following errors were found in the form:<p>";
        foreach ($errors as $error) {
            print "<strong>$error</strong><br>";
        }
    }
    print '<form method="post" action="7-4.php">';
    print '<table><tr><td>Customer Name:&nbsp;';
    input_text ('name','');                                      //name field
    input_text ('phone','');                                 // phone field
    print "</td><td>";
    input_select ('favoriteDishID',$defaults, $dish_names); //favorite dish
    print '</td></tr>';
    print '<tr><td colspan="2"><input type="submit" value=" E n t e r ">';
    print '<input type="hidden" name="_submit_check" value="1">';
    print '</td></tr></table>';
    print '</form>';
}

function validate() {
global $dish_names;
    $errors = array();
    echo '?'.$_POST['name'].'?';
    echo '?'.$_POST['phone'].'?';
    if (! strlen(trim($_POST['name'])) ) {
        $errors[] = 'Please enter your name';
    }
    if (! strlen(trim($_POST['phone'])) ) {
        $errors[] = 'Please enter a phone number that makes sense';
    }
    if (! array_key_exists($_POST['favoriteDishID'],$dish_names) ) { //i know this aint right but it is minor
                                            //compared to the bigger problem
        $errors[] = 'Dish name not in menu';
    }
    return $errors;
}

?>

Last edited by idenr : 20-Mar-2005 at 10:55. Reason: Different Error : Parse error: parse error in /Users/iden/Sites/php/7-4.php on line 48
  #22  
Old 20-Mar-2005, 20:49
idenr idenr is offline
New Member
 
Join Date: Mar 2005
Posts: 2
idenr is on a distinguished road
Please disregard and excuse. I apologize for posting before I discovered my typo. Very lame I realize.
  #23  
Old 07-May-2005, 15:28
tonia tonia is offline
New Member
 
Join Date: May 2005
Posts: 1
tonia is on a distinguished road
Im haveing parse errors of my own... The error says
Parse error: parse error, unexpected T_STRING in /home/track03/public_html/photo/includes/pixelpost.php on line 26

Here are lines 21 - 27, can anyone see what went wrong? (line 26 being the version variable)

PHP Code:

'".$pixelpost_db_host      = "localhost"."'; // database host
'".$pixelpost_db_user      = "***"."'; // database user
'".$pixelpost_db_pass      = "***"."'; // database user password
'".$pixelpost_db_pixelpost = "track03_pixel"."'; // database
'".$pixelpost_db_prefix    = "pixelpost_"."'; // table prefix, leave as is unless you want to install multiple blogs on the same database
'".$version                = "WW91IGFyZSBydW5uaW5nIHZlcnNpb24gMS40LjEgb2YgUGl4ZWxwb3N0LiBSZWxlYXNlZCAyNCBBcHJpbCAyMDA1Lg"."'; // pixelpost version 


  #24  
Old 27-Jun-2005, 06:19
evinx evinx is offline
New Member
 
Join Date: Jun 2005
Location: Sliedrecht
Posts: 1
evinx is on a distinguished road

need help please !!!


please someone help me i can't get out the problem it must be easy for u but im not PHP website designer but game designer

sorry for my bad english


Parse error: parse error, unexpected T_SL in /usr/export/www/hosting/evinx/message.php on line 12
Code:
print <<<ENDHTML

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /usr/export/www/hosting/evinx/kogel.php on line 98
Code:
echo "<a href="kogel-shop.php?x=koopmagazijn">

Warning: mysql_query(): Access denied for user: 'root@localhost' (Using password: NO) in /usr/export/www/hosting/evinx/clanbank.php on line 11
Warning: mysql_query(): A link to the server could not be established in /usr/export/www/hosting/evinx/clanbank.php on line 11

Code:
mysql_query("UPDATE `[clans]` SET `online`=NOW() WHERE `login`='{$clan->login}'");

Parse error: parse error, unexpected T_STRING in /usr/export/www/hosting/evinx/admin-basic.php on line 42
Code:
print " <tr><td class="subTitle"><b>Admin - Setup Turns</b></td></tr>n";

Parse error: parse error, unexpected T_STRING in /usr/export/www/hosting/evinx/shop.php on line 63
Code:
print " <tr><td class="subTitle"><b>Shop</b></td></tr>";

Parse error: parse error, unexpected T_STRING in /usr/export/www/hosting/evinx/shop-sms.php on line 34
Code:
print " <tr><td class="mainTxt">Je hebt 10 sms credits gekocht</td></tr>n";

Parse error: parse error, unexpected T_SL in /usr/export/www/hosting/evinx/garage.php on line 6
Code:
print <<<ENDHTML

Parse error: parse error, unexpected T_SL in /usr/export/www/hosting/evinx/carsel.php on line 64
Code:
print <<<ENDHTML

Parse error: parse error, unexpected T_SL in /usr/export/www/hosting/evinx/autojatte.php on line 49
Code:
print <<<ENDHTML

Parse error: parse error, unexpected T_SL in /usr/export/www/hosting/evinx/paarden.php on line 47
Code:
print <<<ENDHTML

Parse error: parse error, unexpected '\"' in /usr/export/www/hosting/evinx/wapens_toevoegen_admin.php on line 167
Code:
echo "<TR><TD width=100%>". $rsl[name] ."<TD><TD width=0><A href="?delete". $rsl[id]

Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /usr/export/www/hosting/evinx/ipban.php on line 49
Code:
while($Verban = mysql_fetch_object($Verbannen)) {
  #25  
Old 26-Oct-2005, 11:08
djd@n djd@n is offline
Awaiting Email Confirmation
 
Join Date: Oct 2005
Posts: 21
djd@n is on a distinguished road

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in


i am also having problems with a login script if you know where i can get one please e-mail dan@hab-globe.com
  #26  
Old 04-Jul-2006, 11:06
killaz killaz is offline
Awaiting Email Confirmation
 
Join Date: Jul 2006
Posts: 4
killaz is on a distinguished road

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in


Hello im also experiencing a T_VARIABLE error, please can some one help me.

Parse error: syntax error, unexpected T_VARIABLE in /home/snakepit/public_html/forums/adr_character.php on line 151

This is part of the coding before and after the error.
PHP Code:

if ( !$name )
        {
            adr_previous( Fields_empty , adr_character , '' );
        }
        delete_unexploited_characteristics($userdata['user_id'])

        $sql = "SELECT * FROM " . ADR_RACES_TABLE ." r , " . ADR_ELEMENTS_TABLE ." e , " . ADR_ALIGNMENTS_TABLE ." a
            WHERE r.race_id = $race
            AND e.element_id = $element
            AND a.alignment_id = $alignment ";
        if (!$result = $db->sql_query($sql)) 
        {
            message_die(CRITICAL_ERROR, 'Error Getting ADR Config!');
        }
        $infos = $db->sql_fetchrow($result); 



Line 151
PHP Code:

$sql = "SELECT * FROM " . ADR_RACES_TABLE ." r , " . ADR_ELEMENTS_TABLE ." e , " . ADR_ALIGNMENTS_TABLE ." a 


  #27  
Old 04-Jul-2006, 11:38
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Florina, Greece
Posts: 1,112
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'


Quote:
Originally Posted by killaz
Hello im also experiencing a T_VARIABLE error, please can some one help me.

try this,
PHP Code:

$sql = "SELECT * FROM " . ADR_RACES_TABLE ." r , " . ADR_ELEMENTS_TABLE ." e , " . ADR_ALIGNMENTS_TABLE ." a WHERE r.race_id = $race AND e.element_id = $element AND a.alignment_id = $alignment "; 



or better yet,
PHP Code:

$sql = "SELECT * FROM " . ADR_RACES_TABLE ." r , " . ADR_ELEMENTS_TABLE ." e , " . ADR_ALIGNMENTS_TABLE ." a".
    " WHERE r.race_id = $race".
    " AND e.element_id = $element".
    " AND a.alignment_id = $alignment "; 



Mark
__________________

"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs

Stories from the NICU Blog
  #28  
Old 04-Jul-2006, 11:56
killaz killaz is offline
Awaiting Email Confirmation
 
Join Date: Jul 2006
Posts: 4
killaz is on a distinguished road

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in


Yo, cable_guy_67 neiter one worked, it certainly looked like it would but it didn't. Do you need the whole file or anything?
  #29  
Old 04-Jul-2006, 12:04
cable_guy_67's Avatar
cable_guy_67 cable_guy_67 is offline
Senior Member
 
Join Date: Oct 2004
Location: Florina, Greece
Posts: 1,112
cable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the roughcable_guy_67 is a jewel in the rough

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING'


I overlooked the obvious on the line prior.

PHP Code:

delete_unexploited_characteristics($userdata['user_id'])
// shoud have a semi-colon at end 



Mark
__________________

"A happy person is not a person in a certain set of circumstances, but rather a person with a certain set of attitudes."
--Hugh Downs

Stories from the NICU Blog
  #30  
Old 04-Jul-2006, 12:20
killaz killaz is offline
Awaiting Email Confirmation
 
Join Date: Jul 2006
Posts: 4
killaz is on a distinguished road

Re: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in


damn i missed that too lol. Thanks man it works like a charm. i missed it because im not good at php, but thanks again.
 
 

Recent GIDBlogRunning Linux Programs at Boot Time by gidnetwork

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 03:53.


vBulletin, Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.