Jump to content

Can You Spot The Error?


darrin365

Recommended Posts

Hmmm..

I've got an error in here somewhere and I cannot find it despite hours of review. Also, in line 45 is some code I picked up from somewhere else on how to pull the newly generated key_id from one table and immediately insert it into other tables. It calls for inserting NULL into the field, but it dawns on me that it's the primary key field and it's set for NOT NULL. That won't work, will it?

[code]
<?php
// get the parameters passed
$task = trim( mosGetParam( $_REQUEST, 'task', '' ) );

// determine what to do
switch ($task) {
case "check":
// if user is not logged in
loggedin();
break;   

case "savelisting":
// save the listing
savelisting( $option );
break;   
}

function loggedin() {
if ( $my->id > 0 ) {

$query = "LOCK TABLES dtd_trips WRITE, dtd_user2trip WRITE, dtd_link2trip WRITE";
$database->setQuery($query);

echo "Tables locked";

$name_query = "INSERT INTO dtd_trips (trip_id, trip_name) VALUES (NULL, $_POST[trip_name])";
$intersect_query = "INSERT INTO dtd_trip2user (user_id, trip_id) VALUES ($my->id, LAST_INSERT_ID())";

$n_query = mysql_query($name_query);
$i_query = mysql_query($intersect_query);

$query = "UNLOCK TABLES";
$database->setQuery($query); 

} else {
die("You must be logged in to create a trip.");


HTML_tripmaker::show_form();
?>
[/code]

Keep in mind the form is in another file and is inside of the show_form function.

The site is returning this error:
Parse error: parse error, unexpected $ in /xxx/xxx/components/com_tripmaker/tripmaker.php on line 57

I hope that's enough data.

Thanks for your time.
Link to comment
Share on other sites

[code]
// get the parameters passed
$task = trim( mosGetParam( $_REQUEST, 'task', '' ) );

// determine what to do
switch ($task) {
case "check":
// if user is not logged in
loggedin();
break;   

case "savelisting":
// save the listing
savelisting( $option );
break;   
}

function loggedin() {
if ( $my->id > 0 ) {

$query = "LOCK TABLES dtd_trips WRITE, dtd_user2trip WRITE, dtd_link2trip WRITE";
$database->setQuery($query);

echo "Tables locked";

$name_query = "INSERT INTO dtd_trips (trip_id, trip_name) VALUES (NULL, $_POST[trip_name])";
$intersect_query = "INSERT INTO dtd_trip2user (user_id, trip_id) VALUES ($my->id, LAST_INSERT_ID())";

$n_query = mysql_query($name_query);
$i_query = mysql_query($intersect_query);

$query = "UNLOCK TABLES";
$database->setQuery($query); 

} else {
die("You must be logged in to create a trip.");
        }
  }

HTML_tripmaker::show_form();[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.