473,771 Members | 2,328 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

parse error in nested query - please help.

I am having troubles finding the parse error in this script. I've been
checking for weeks. I am too new to the subject I guess.

I am trying to show a readord and them have a form at the bottom of the
page for inputting data to Update the record. I get a parse error that
points to the last line in the script so I know it is something I am missing
earlier in the script but doing a line by line it seems fine to me.

Thanks for any atempt and suggestions.

Polar :)

------------------------------
<--cut--
$query = "SELECT sub_id, username, story_title, DATE_FORMAT(dat e_submitted,
'%m/%d/%y'), category, story FROM Submission WHERE date_processed < 1 LIMIT
0,1";

$result = @mysql_query ($query); // Run the query.
if ($result) { // If OK, display the record.
echo '<table align="center" cellspacing="5" cellpadding="1" border="0"
width="500"><sp an><tr><td align="left" width="100">Sto ry ID:</td><td
align="left" width="100">Nam e</td><td align="left" width="250">Tit le</td><td
align="left" width="100">Dat e&nbsp;Submitte d</td><td align="left"
width="50">Cate gory</td></tr><tr><td colspan="5"></span><hr></td></tr>';

// Fetch and print the record.
while ($row = mysql_fetch_arr ay($result, MYSQL_NUM)) {
echo"<tr><td align=\"left\" width=\"100\">"
..$row[0]
.."</td><td align=\"left\" width=\"100\">"
..$row[1]
.."</td> <td align=\"left\"w idth=\"250\">"
..$row[2]
.."</td><td align=\"left\" width=\"50\">"
..$row[3]
.."</td><td align=\"left\" width=\"50\">"
..$row[4]
.."</td></tr><tr><td colspan=\"5\"wi dth=\"500\"><br >"
..nl2br($row[5])
.."</td></tr>\n";
}
echo '</table>';
echo '<hr>';

if (isset($_POST['submit'])) { // Handle the form.

if (isset($_POST['accepted']) == 'Y') {
$acc = $_POST['accepted'];
echo "<b><p>Grea t A story to pass on!</p></b>";
$query = "UPDATE Submission SET reader={$_SESSI ON['username']},
date_processed= NOW(), accepted=$acc WHERE sub_id=$row[0]";

} elseif (isset($_POST['accepted']) == 'N') {
$acc = $_POST['accepted'];
echo "<b><p>Try again with a new story!</p></b>";
$query = "UPDATE Submission SET reader={$_SESSI ON['username']},
date_processed= NOW(), accepted=$acc WHERE sub_id=$row[0]";
$result = @mysql_query ($query); // Run the query.
if (mysql_affected _rows() == 1) { // If it ran OK.
echo 'Done';
include ('includes/footer.html'); // Include the HTML footer.
exit();
} else { // If no accepted was selected...
$accepted = NULL;
echo '<p><b>You forgot to enter Yes or No for the story
acceptance!</b></p>';

}

}

?>
Jul 17 '05 #1
8 2195
Polar wrote:
I am having troubles finding the parse error in this script. I've been
checking for weeks. I am too new to the subject I guess.


Count the number of "{" and compare with the number of "}".

I imagine they'll be different :)

--
USENET would be a better place if everybody read: | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html | header, textonly |
http://www.expita.com/nomime.html | no attachments. |
Jul 17 '05 #2
Thanks Pedro

I went over that many times - thinking the same thing - and low any beold on
my second to last bunch of hair I found it

Now I have a new problem. The query is not updating the record.

the $_Session['username'] is available as it is posting on top of the screen
about the form.
the Now() is evident it should be ok as is Accepted that leaves the
qualifier of the sud_id?

....

if (isset($_POST['accepted']) == 'Y') {
$query = "UPDATE Submission SET reader={$_SESSI ON['username']},
date_processed= NOW(), accepted='Y' WHERE sub_id=$row[0]";
echo "<b><p>Grea t A story to pass on!</p></b>";

....

is there an error here in my syntax That I am not seeing?

Thanks for the time and any comments

Polar :)

Jul 17 '05 #3
I noticed that Message-ID: <8MkGc.30436$P7 .21937@pd7tw3no > from Polar
contained the following:
if (isset($_POST['accepted']) == 'Y') {
$query = "UPDATE Submission SET reader={$_SESSI ON['username']},
date_processed =NOW(), accepted='Y' WHERE sub_id=$row[0]";
echo "<b><p>Grea t A story to pass on!</p></b>";

...

is there an error here in my syntax That I am not seeing?


Not sure you can use isset() like that
http://uk.php.net/manual/en/function.isset.php
And where is $row[0] coming from?

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4
Polar wrote:
Now I have a new problem. The query is not updating the record.

the $_Session['username'] is available as it is posting on top of the screen
about the form.
the Now() is evident it should be ok as is Accepted that leaves the
qualifier of the sud_id?

...

if (isset($_POST['accepted']) == 'Y') {
$query = "UPDATE Submission SET reader={$_SESSI ON['username']},
date_processed= NOW(), accepted='Y' WHERE sub_id=$row[0]";
echo "<b><p>Grea t A story to pass on!</p></b>";

...

is there an error here in my syntax That I am not seeing?


Yes, in SQL syntax. I'll leave it up to you to find :)

You do not show your mysql_query() call and *most importantly* how
you're checking for errors!

I usually do (pseudo-code)

<?php
$query = "whatever";
$result = mysql_query($qu ery)
or die('Error in query [' . $query . ']. The error was: ' . mysql_error());
?>

Hint: is $_SESSION['username'] a string?

--
USENET would be a better place if everybody read: | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html | header, textonly |
http://www.expita.com/nomime.html | no attachments. |
Jul 17 '05 #5
Pedro Graca wrote:
I usually do (pseudo-code)

<?php
$query = "whatever";
$result = mysql_query($qu ery)
or die('Error in query [' . $query . ']. The error was: ' . mysql_error());
?>

Hint: is $_SESSION['username'] a string?


Okay I'll hazard a guess on this one. I haven't tested this particular
solution, but I've occasionally run into similar problems.

If Polar's $query is holding a string, is it possible that the php
expressions must be concatenated as they are in Pedro's example? For
instance, wouldn't you really need to do something like this:

$query = "UPDATE Submission SET reader='".{$_SE SSION['username']}."',
date_processed= NOW(), accepted='Y' WHERE sub_id='".$row[0]."'";

Also, wouldn't you want to do something like

/*temporary error check line*/
echo $query;

Just to make sure the query looks the way it's supposed to?

Hope this helps.

Jul 17 '05 #6
I posted the full script ( I hope ) at the very beginning of the thread.

Thanks for the info and not just giving me the answer - I have only been
doing this for about 3 weeks now. So ALL this is new.

thanks again I'll let you know how my crawling goes...

the weekender coder

Polar :)
"'bonehead" <se*********@he re.org> wrote in message
news:40******** ******@here.org ...
Pedro Graca wrote:
I usually do (pseudo-code)

<?php
$query = "whatever";
$result = mysql_query($qu ery)
or die('Error in query [' . $query . ']. The error was: ' . mysql_error()); ?>

Hint: is $_SESSION['username'] a string?


Okay I'll hazard a guess on this one. I haven't tested this particular
solution, but I've occasionally run into similar problems.

If Polar's $query is holding a string, is it possible that the php
expressions must be concatenated as they are in Pedro's example? For
instance, wouldn't you really need to do something like this:

$query = "UPDATE Submission SET reader='".{$_SE SSION['username']}."',
date_processed= NOW(), accepted='Y' WHERE sub_id='".$row[0]."'";

Also, wouldn't you want to do something like

/*temporary error check line*/
echo $query;

Just to make sure the query looks the way it's supposed to?

Hope this helps.

Jul 17 '05 #7
I noticed that Message-ID: <40************ **@here.org> from 'bonehead
contained the following:
/*temporary error check line*/
echo $query;

Just to make sure the query looks the way it's supposed to?


I usually do that and then paste the result into phpmyadmin That
usually helps me find any SQL syntax errors.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #8
'bonehead wrote:
Pedro Graca wrote:
<?php
$query = "whatever";
$result = mysql_query($qu ery)
or die('Error in query [' . $query . ']. The error was: ' . mysql_error());
?>
If Polar's $query is holding a string, is it possible that the php
expressions must be concatenated as they are in Pedro's example? For
instance, wouldn't you really need to do something like this:

$query = "UPDATE Submission SET reader='".{$_SE SSION['username']}."',
date_processed= NOW(), accepted='Y' WHERE sub_id='".$row[0]."'";


No, not really. The string building of Polar's query is ok.
I don't like double quotes, but my die() expression could have been
written

die("Error in query [$query]. The error was: " . mysql_error());

Also, wouldn't you want to do something like

/*temporary error check line*/
echo $query;

Just to make sure the query looks the way it's supposed to?


That is also a good idea.
The idea behind the die is to get the query itself written to the output
as long as the reason for failure. Suppose you have this query

UPDATE xyz SET id=8 WHERE id=2

and try to run it on a database that has no xyz table. The die() output
will be something like

Error in query [UPDATE xyz SET id=8 WHERE id=2]. The error
was: Table 'xyz' doesn't exist
--
USENET would be a better place if everybody read: | to email me: use |
http://www.catb.org/~esr/faqs/smart-questions.html | my name in "To:" |
http://www.netmeister.org/news/learn2quote2.html | header, textonly |
http://www.expita.com/nomime.html | no attachments. |
Jul 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2932
by: josh dismukes | last post by:
/// here is the code i'm getting a parse error on the last line of the code which /// is </html> any help will be much appreciated. <?php session_start ();
6
19029
by: Ehartwig | last post by:
I recently created a script for user verification, solved my emailing issues, and then re-created the script in order to work well with the new PHP 5 that I installed on my server. After submitting user information into my creation script, I get the following error from the page that is suppose to insert the user data into the database, create a code, then send an email out for verification. Parse error: parse error, unexpected $end in...
2
4671
by: Michael . | last post by:
I had an error before involving a temporary table, and that has been taken care of... The last message I wrote where it seemed to have needed it after I added it was because of different \connects. Could someone please help me with this next error as I'm importing to a new server? I am getting quite a few of these... CREATE VIEW care_plan_note_state AS
0
1033
by: jinapaia | last post by:
hi, i am getting a message Parse error:parse error, unexpected $...please help with this code: <?php require_once('db_login.php'); $sdbh = ""; $expire = 900; function sess_open($save_path, $session_name){ global $dbhost, $dbuser, $dbpasswd, $sdbh; if (! $sdbh = mysql_pconnect($dbhost, $dbuser, $dbpasswd)){ echo mysql_error();
36
8010
by: rhys | last post by:
My Gurus and Angels -- Please pardon this old-school programmer, only recently enlightened to open-source, having been trapped in the convenience of proprietary lingos for way too long. My shortcomings will soon become apparent. I am developing an estimating construction system, using PHP5 and MySQL 5.0.24a with Ubuntu. I have a main "projects" file, and 2 detail files, one for piping and one for equipment. Each of these files will have...
1
6189
by: maconbot | last post by:
hi all, please exuse my email ">" i am working on location. > hey team, thanks for the quick reply. > > i am trying to parse a pop3 account and populate it into flash. > > the how to code... > http://www.derickrethans.nl/parsing_mail_with_php.php > > - is this the class? i am really confused how to plug this into my
6
2977
by: =?Utf-8?B?RGF2aWRN?= | last post by:
Hello, I have an XML file generated from a third party application that I would like to parse. Ideally, I plan on having a windows service setup to scan various folders for XML files and parse the file, then spit out totals. Since I haven't worked with XML too much in C#, I'm trying to develop a structured and easy-to-read way to parse the file. Essentially, I would like to read the file and add the "BatchTktAmountfor any...
2
3243
by: fburn | last post by:
I need some help with an error I'm getting using php 5.2.5 running on linux. I receive an error: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /var/www/html/inventoryControl/supplier.php on line 26 (line number changed to match code tags) The code is as follows: // get a supplier using the supplier id
11
2936
by: JRough | last post by:
I'm trying to use output buffering to cheat so i can print to excel which is called later than this header(). header("Content-type: application/xmsdownload"); header("Content-Disposition: attachment; header("Pragma: no-cache"); header("Expires; 0"); print "$header\n$data";
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9910
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.