Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
parsing error ')' unexpected
Old 06-03-2008, 04:30 PM parsing error ')' unexpected
Skilled Talker

Posts: 76
Trades: 0
Hello. I have this error.
Code:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/russia5/public_html/month_conversion.php on line 9
Code:
<?php 
//DB CONNECTION GOES HERE
 
$lookup = array("January" => '01', "February" => '02', "March" => '03', "April" => '04', "May" => '05', "June" => '06', "July" => '07', "August" => '08', "September" => '09', "October" => '10', "November" => '11', "December" => '12'); 
// use month names on your form 
$month = $_POST["age_mth"]; // the name 
$monthnum = $lookup[$month]; // the number
$query = "INSERT INTO subdomain_submission (age_month) VALUES ('.$monthnum.');"
 
print "month = $month";
print "monthnum = $monthnum";

?> 
 
LINE 10 IS WHERE $lookup is at.  So line 9 is blank.
 
Thanks to all who consider my problem
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
russia5 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-03-2008, 04:43 PM Re: parsing error ')' unexpected
VirtuosiMedia's Avatar
Web Design Made Simple

Posts: 1,228
Trades: 0
Change:
PHP Code:
$query "INSERT INTO subdomain_submission (age_month) VALUES ('.$monthnum.');" 
To:
PHP Code:
$query "INSERT INTO subdomain_submission (age_month) VALUES ('.$monthnum.')"
VirtuosiMedia is offline
Reply With Quote
View Public Profile Visit VirtuosiMedia's homepage!
 
Old 06-03-2008, 04:59 PM Re: parsing error ')' unexpected
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
The only error I can see like that is:
PHP Code:
$query "INSERT INTO subdomain_submission (age_month) VALUES ('.$monthnum.');" 
where you mix the PHP string " delimiter with the SQL one (')
The query should be written:
PHP Code:
$query "INSERT INTO subdomain_submission (age_month) VALUES ('$monthnum');" 
if the age_month column is a text or varchar field, or
PHP Code:
$query "INSERT INTO subdomain_submission (age_month) VALUES ($monthnum);" 
if age_month is a numeric field (integer)
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 06-03-2008, 05:28 PM Re: parsing error ')' unexpected
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
so given ->
LINE 10 IS WHERE $lookup is at. So line 9 is blank.

What's the code that should be where this -> //DB CONNECTION GOES HERE <- is ?

because that's where the error will be (you are probably missing a ")" on the line before the stated error line. (the code you haven't shown us)
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-03-2008, 05:42 PM Re: parsing error ')' unexpected
Junior Talker

Posts: 1
Name: Ahsan
Trades: 0
Hi,
Please add one additional semicolon after the query line. that is replace your :

$query = "INSERT INTO subdomain_submission (age_month) VALUES ('.$monthnum.');"

with the following correct line :

$query = "INSERT INTO subdomain_submission (age_month) VALUES ('.$monthnum.');";


then everything will be fine. Be a bit careful while from making these little mistakes pls.

Best Regards
Ahsan
ahsan_razib is offline
Reply With Quote
View Public Profile
 
Old 06-03-2008, 06:35 PM Re: parsing error ')' unexpected
Skilled Talker

Posts: 76
Trades: 0
Thanks for the help everyone! I am getting it, but not quite. I am still getting 0 in the age_month field Here is what month_conversion.php is now outputting.

Code:
 
month = monthnum =
so the lookup table is not quite right, I believe
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
russia5 is offline
Reply With Quote
View Public Profile
 
Old 06-04-2008, 12:49 AM Re: parsing error ')' unexpected
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
Can you please give us the full PHP code? Also now that you're asking for help with your mysql please give us the table structure of your database too.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-05-2008, 09:59 PM Re: parsing error ')' unexpected
Skilled Talker

Posts: 76
Trades: 0
Okay... I will give you everything that I have, since I have spent an very long time on this and can not get it with many variants. I am doing something wrong. Thanks...

Question: Do I have a declaration problem with $month or $monthnum It is used in the form below.


First, here is the MySQL table structure for the fields we are dealing with.
Code:
age_day int(2)  No 0                
  age_mth varchar(9)  No                 
  age_yr int(4)  No 0                
  age_month char(2)  No 0                
    Indexes:   Keyname Type Cardinality Action Field 
PRIMARY  PRIMARY 21       sid  
Create an index on  columns
Next, here is the full coding on the loader or PHP page.

Code:
<?php 

require_once("../includes/ru_config.php");
require_once("../includes/ru_connection.php");
require_once("../includes/ru_utils.php");
require_once("../includes/ru_data.php");
require_once("../libs/ru_smarty.php");
RU_CheckInject(); 
 

$lookup = array("January" => '01', "February" => '02', "March" => '03', "April" => '04', "May" => '05', "June" => '06', "July" => '07', "August" => '08', "September" => '09', "October" => '10', "November" => '11', "December" => '12'); 
// use month names on your form 

WHERE IS $month or $monthnum declared?  How do I do this?

$month = ($_POST[$profile['age_mth']]); // the name 
$monthnum = $lookup[$month]; // the number
$query = "INSERT INTO `subdomain_submission` (age_month) VALUES ('{$monthnum}');";   


print "month = $month";
print "monthnum = $monthnum";


?>
On logging into the above php page, I am getting

month = monthnum =

Question: Do I have a declaration problem with $month or $monthnum It is used in the form below.

$month should

Next, here is the form template

Code:
<html ">

</head>
<body>

<form action="?step={ $step+1 }" method="post" enctype="multipart/form-data" name="form2" { if $step < 3 }  onSubmit="return isValid(this)" {/if} >

<input type="hidden" name="id" value="{$id}">

<TABLE >

   {if $step eq 1}
    '1 : ;
{else}
    {$step}.' : Submit Your Photo #'.{$step-1};
{/if}
  </STRONG></FONT></TD>
</TR>

{ if $step eq 1 }
        
        <TD>
            <select name="age" id="age" size="1">
              <option value="0" selected>-- Select --</option>
              <option value="16" {php} if (!empty($profile) and $profile['age'] == '20') echo ' selected' {/php}>16 yo</option>
              <option value="17" {php} if (!empty($profile) and $profile['age'] == '21') echo ' selected' {/php}>17 yo</option>
              <option value="18" {php} if (!empty($profile) and $profile['age'] == '23') echo ' selected' {/php}>18 yo</option>
              <option value="19" {php} if (!empty($profile) and $profile['age'] 
            </select>
          </TD>    
</TR>
<TR>
        <TD align=right><strong></strong></TD>
        <TD>
            <select name="age_day" id="age_day" size="1">
              <option value="0" selected>-- Select --</option>
              <option value="01" {php} if (!empty($profile) and $profile['age_day'] == '01') echo ' selected' {/php}>01</option>
              <option value="02" {php} if (!empty($profile) and $profile['age_day'] == '02') echo ' selected' {/php}>02</option>
              <option value="03" {php} if (!empty($profile) and $profile['age_day'] == '03') echo ' selected' {/php}>03</option>
              <option value="04" 
            </select>
          </TD>    
</TR>
    <TR>
        <TD align=right><strong></strong></TD>
        <TD>
            <select name="age_mth" id="age_mth" size="1">
              <option value="0" selected>-- Select --</option>
              <option value="January" {php} if (!empty($profile) and $profile['age_mth'] == 'January') echo ' selected' {/php}>January</option>
              <option value="Feburary" {php} if (!empty($profile) and $profile['age_mth'] == 'Feburary') echo ' selected' {/php}>Feburary</option>
              <option value="March" {php} if (!empty($profile) and $profile['age_mth'] == 'March') echo ' selected' {/php}>March</option>
              <option value="April" {php} if (!empty($profile) and $profile['age_mth'] == 'April') echo ' selected' {/php}>April</option>
              <option value="May" {php} if (!empty($profile) and $profile['age_mth'] == 'May') 
            </select>
          </TD>    
</TR>
<TR>
        <TD align=right><strong>Ãîä ðîæäåíèÿ</strong></TD>
        <TD>
            <select name="age_yr" id="age_yr" size="1">
              <option value="0" selected>-- Select --</option>
                <option value="1993" {php} if (!empty($profile) and $profile['age_yr'] == '1993') echo ' selected' {/php}>1993</option>
                <option value="1992" {php} if (!empty($profile) and $profile['age_yr'] == '1992') echo ' selected' {/php}>1992</option>
                <option value="1991" {php} if (!empty($profile) and $profile['age_yr'] == '1991') echo ' selected' {/php}>1991</option>
                <option value="1990" 
 </select>             
</TD>
</body>
</html>
Next, here is the form php file.

Code:
<?php
require_once("includes/ru_config.php");
require_once("includes/ru_connection.php");
require_once("includes/ru_data.php");
require_once("includes/ru_utils.php");
require_once("libs/ru_smarty.php");
//RU_CheckInject();
//print "<pre>";
//print_r($_REQUEST);
if (empty($_REQUEST['step'])) $step = 1; else $step = $_REQUEST['step'];
if (empty($_REQUEST['id'])) $id = 0; else $id = $_REQUEST['id'];
function check_received_params($allowedParams_in, $arrayToCheck_in) 
{ 
    // makes sure only the items in the $allowedParams_in 
    // are found in the array $arrayToCheck_in 
    // returns true if there are no unexpected params in the array 
    // returns false otherwise 

    $numAllowed = count($allowedParams_in); 
    if (count($arrayToCheck_in) <= $numAllowed) { 
        while (list($k, $v) = each($arrayToCheck_in)) { 
            $found = false; 
            for($i = 0; $i < $numAllowed; $i++) { 
                if ($k == $allowedParams_in[$i]) { 
                    $found = true; 
                    break; 
                } 
            } 
            if (!$found) { 
                return false; 
            }     
        } 
    } else { 
        return false; 
    } 
    return true; 
}

     
if (!empty($_POST))

{

    if ($step < 3) // insert/update info

    {

        $fields = $values = array();
         unset($_POST['Submit']);
        if (empty($_POST['id']))
        {
            unset($_POST['id']);
            foreach ($_POST as $field=>$value)
            {
                $fields[] = $field;
             mysql_query($query);
            $id = mysql_insert_id();

                    }

                   $qryString = array();

            $currentID = $_POST['id'];

            unset($_POST['id']);

            foreach ($_POST as $field=>$value)
            {
                $qryString[] = $field.' = "'.htmlspecialchars(trim($value)).'" ';
            }        
            $query = 'UPDATE subdomain_submission SET '.implode(',', $qryString).' WHERE sid = "'.$currentID.'"';
            mysql_query($query);

 }
 }
 mysql_query($query);

}
}
elseif (!empty($_COOKIE['authcode']))

{

//echo "COOKIE :: " . $_COOKIE['authcode'];
    $query = 'SELECT * FROM subdomain_submission WHERE sid = "'.$_COOKIE['authcode'].'"';

    $result = mysql_query($query);

    if (mysql_num_rows($result))

    {

        $profile = mysql_fetch_assoc($result);

        $id = $_COOKIE['authcode'];

    }

}

$smarty->display("forms/submission-russian_subdomain.tpl");

?>
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
russia5 is offline
Reply With Quote
View Public Profile
 
Old 06-05-2008, 11:27 PM Re: parsing error ')' unexpected
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
From a quick view change this
PHP Code:
WHERE IS $month or $monthnum declared?  How do do this?

$month = ($_POST[$profile['age_mth']]); // the name 
To
PHP Code:
$month = ($_POST['age_mth']); 
See if that makes any difference.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-06-2008, 11:22 AM Re: parsing error ')' unexpected
Skilled Talker

Posts: 76
Trades: 0
I tried it before and I just tried it again. I am still getting the same out put from the script month = monthnum =

It does not see the results from the submitted variable $_POST['age_mth'] or $_POST[$profile['age_mth']] it sayst this is empty. I have tried every combination I can think of. thanks again.

So, you do not see a problem with the declaring of the varibles $month or $monthnum
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

Last edited by russia5; 06-06-2008 at 11:25 AM..
russia5 is offline
Reply With Quote
View Public Profile
 
Old 06-06-2008, 05:30 PM Re: parsing error ')' unexpected
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
Try putting this at the top of the page and see what it says.
PHP Code:
foreach($_POST as $key => $value){
    echo 
"<p>Key: ".$key." Value: ".$value."</p>";} 
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-07-2008, 12:22 PM Re: parsing error ')' unexpected
Skilled Talker

Posts: 76
Trades: 0
I put it at the top, in the middle and at the end. I took out print and left it in. The result was, I got nothing echo'd. white space.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
russia5 is offline
Reply With Quote
View Public Profile
 
Old 06-07-2008, 01:22 PM Re: parsing error ')' unexpected
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
If the foreach I said echo'd nothing then $_POST is empty. Do you have a working example of this that I could look at?
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-07-2008, 02:10 PM Re: parsing error ')' unexpected
Skilled Talker

Posts: 76
Trades: 0
The form successfully posts the narrative month. That is, it puts octomer in the MySQL field, age_mth The form loader php file, I have listed above, shows the variable to upload the narrative, $profile[age_mth]

The test site that we are using to build this is www.russiansweets.us the form can be found at the bottom of the page under "sign up" this is only a site we are using to test and develop, however it does work.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
russia5 is offline
Reply With Quote
View Public Profile
 
Old 06-07-2008, 04:43 PM Re: parsing error ')' unexpected
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
It'd seem, age_mth=0 is the default so $_POST['age_mth'] should be numerical. But it still doesn't explain why the foreach I posted above is showing as empty, if it's not outputting anything then nothing is being posted by the form.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-07-2008, 06:29 PM Re: parsing error ')' unexpected
Skilled Talker

Posts: 76
Trades: 0
Would I need to change the array to 01 => january?
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
russia5 is offline
Reply With Quote
View Public Profile
 
Old 06-07-2008, 07:42 PM Re: parsing error ')' unexpected
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
First off, does $_POST contain anything at all? It won't matter what you change until $_POST contains data.
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-08-2008, 11:25 AM Re: parsing error ')' unexpected
Skilled Talker

Posts: 76
Trades: 0
The form successfully posts to MySQL, so the supervariables would have to hold something. From the form above, you can see we have $_REQUEST and $_POST The form handling script has anti hack coding within it which may be the $_POST. (I just happen to think about that) could it be possible the variables are in the $_REQUEST
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
russia5 is offline
Reply With Quote
View Public Profile
 
Old 06-08-2008, 02:07 PM Re: parsing error ')' unexpected
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
$_REQUEST contains $_COOKIE, $_POST, and $_GET and I believe in that order. The danger with it is if you have $id = $_REQUEST['id'] and expect id to be in a cookie or to be POSTed and I use ?id=1 it'll use that instead. So don't use $_REQUEST, use $_POST there instead (that may be the problem actually)
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Old 06-10-2008, 01:37 PM Re: parsing error ')' unexpected
Skilled Talker

Posts: 76
Trades: 0
I exchanged REQUEST for POST, and I still got month = monthnum = as an output of /month_conversion.php Plus, the images would not load. I have looked at this forever and I am still stumped.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
russia5 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to parsing error ')' unexpected

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.72522 seconds with 12 queries