Jump to content


Photo

Help with passing variables


  • Please log in to reply
8 replies to this topic

#1 RobRocker

RobRocker
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 21 September 2006 - 02:58 AM

Howdy everyone.

I am having trouble passing a $_GET variable. It is "getting" it correctly but it wont pass it to next site.

Here is my code that I am trying to get to work. Now when I pass this I get a error that says.

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1


$id = $_GET['id_eve'];
$MM_redirectLoginSuccess = "calenderedit.php?id_eve=$id";

Here is the scenario...

I have a dynamic calendar view page, it loads id_eve and grabs the correct information from the database. I have a "Login to Edit" form at the bottom of the page. Which is what the redirectLoginSuccess variable is for. Now when I hit the sumbit form information button it send me to the site but it just has "calenderedit.php?id_eve=" in the address bar but no variable....

Can you help? BTW I have all my code like this above the html tags.

#2 trillion

trillion
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 21 September 2006 - 03:02 AM

try this maybe

$id = $_GET['id_eve'];
$MM_redirectLoginSuccess = "calenderedit.php?id_eve=".$id;

#3 RobRocker

RobRocker
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 21 September 2006 - 03:17 AM

No that didnt work. *sigh*

Here is my whole code.

<?php require_once('Connections/calendar.php'); ?>
<?php
$colname_Recordset1 = "-1";
if (isset($_GET['id_eve'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['id_eve'] : addslashes($_GET['id_eve']);
}
mysql_select_db($database_calendar, $calendar);
$query_Recordset1 = sprintf("SELECT * FROM rsCalendar WHERE id_eve = %s", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $calendar) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<?php 
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}
$id = $_GET['id_eve'];
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['email'])) {
  $loginUsername=$_POST['email'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "calenderedit.php?id_eve=".$id;
  $MM_redirectLoginFailed = "calender.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_calendar, $calendar);
  
  $LoginRS__query=sprintf("SELECT user_email, user_pass FROM rsCalendar_users WHERE user_email='%s' AND user_pass='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysql_query($LoginRS__query, $calendar) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
    
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;	      

    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>


#4 trillion

trillion
  • Members
  • PipPipPip
  • Advanced Member
  • 41 posts

Posted 21 September 2006 - 03:37 AM

what do you get for a simple

echo $_GET['id_eve'];

#5 RobRocker

RobRocker
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 21 September 2006 - 01:03 PM

When I do a "print_r" I get the correct variable...

#6 RobRocker

RobRocker
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 21 September 2006 - 04:37 PM

I tried doing $id = echo $_GET['id_eve']; and that was a syntax error... I thought I would give it a try anyways.

#7 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 21 September 2006 - 05:00 PM

remove echo and it'll work. So do this:
$id = $_GET['id_eve'];

#8 RobRocker

RobRocker
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 21 September 2006 - 07:05 PM

Ive tried that, and it wont pass the variable.

#9 RobRocker

RobRocker
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 21 September 2006 - 07:33 PM

Ok, Well since that is giving me trouble. I had another idea.

I know in PHP you can have modules that are shown depending on certain situations. Can I make a module that after the person logs in, it "unlocks" a module so the person can access that module?

If that is possible can anyone give me resources on how to do it?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users