Jump to content

[SOLVED] unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING


PHPilliterate

Recommended Posts

Howdy!

I created a search page that redirected to cwplayers_Results...it was 1 list field and worked great. Then I decided to add a second field and make it into a LOGIN page as well. So....now something went kaputz!(the search resulted in getting all records)... I thought that editing the "redirect to URL" setting (in DW8) to the following line would work, but now i get "unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING"

 

Can someone let me know where the problem is?

 

$MM_redirectLoginSuccess = "cwplayers_Results.php?<?php echo((isset($_POST["S_team"]))?$_POST["S_team"]:"") ?>=";

Link to comment
Share on other sites

If you are already in PHP (since you have a variable at the start), why are you doing a <?php echo statement in the middle?

 

Howdy!

I created a search page that redirected to cwplayers_Results...it was 1 list field and worked great. Then I decided to add a second field and make it into a LOGIN page as well. So....now something went kaputz!(the search resulted in getting all records)... I thought that editing the "redirect to URL" setting (in DW8) to the following line would work, but now i get "unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING"

 

Can someone let me know where the problem is?

 

$MM_redirectLoginSuccess = "cwplayers_Results.php?<?php echo((isset($_POST["S_team"]))?$_POST["S_team"]:"") ?>=";

Link to comment
Share on other sites

Here is an expanded view of my code.

The first is from my search page that I tried to turn into a login page...The S_team field is what i want to pass as a variable to my results page....

// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}

$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}

if (isset($_POST['S_team'])) {
  $loginUsername=$_POST['S_team'];
  $password=$_POST['password'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "cwplayers_Results.php?<?php echo((isset($_POST["S_team"]))?$_POST["S_team"]:"") ?>=";
  $MM_redirectLoginFailed = "cwreg.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_alflregister, $alflregister);
  
  $LoginRS__query=sprintf("SELECT username, userpass FROM login WHERE username='%s' AND userpass='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
   
  $LoginRS = mysql_query($LoginRS__query, $alflregister) 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 );
  }
}
?>

 

Here is the code from my RESULTS page:

 

<?php
$maxRows_WADAcwplayers = 1000;
$pageNum_WADAcwplayers = 0;
if (isset($_GET['pageNum_WADAcwplayers'])) {
  $pageNum_WADAcwplayers = $_GET['pageNum_WADAcwplayers'];
}
$startRow_WADAcwplayers = $pageNum_WADAcwplayers * $maxRows_WADAcwplayers;

$Paramteam_WADAcwplayers = "-1";
if (isset($_GET['S_team'])) {
  $Paramteam_WADAcwplayers = (get_magic_quotes_gpc()) ? $_GET['S_team'] : addslashes($_GET['S_team']);
}
mysql_select_db($database_alflregister, $alflregister);
$query_WADAcwplayers = sprintf("SELECT * FROM cwplayers WHERE (team LIKE '%%%s%%' OR '-1' = '%s') ORDER BY last ASC", $Paramteam_WADAcwplayers,$Paramteam_WADAcwplayers);
$query_limit_WADAcwplayers = sprintf("%s LIMIT %d, %d", $query_WADAcwplayers, $startRow_WADAcwplayers, $maxRows_WADAcwplayers);
$WADAcwplayers = mysql_query($query_limit_WADAcwplayers, $alflregister) or die(mysql_error());
$row_WADAcwplayers = mysql_fetch_assoc($WADAcwplayers);

if (isset($_GET['totalRows_WADAcwplayers'])) {
  $totalRows_WADAcwplayers = $_GET['totalRows_WADAcwplayers'];
} else {
  $all_WADAcwplayers = mysql_query($query_WADAcwplayers);
  $totalRows_WADAcwplayers = mysql_num_rows($all_WADAcwplayers);
}
$totalPages_WADAcwplayers = ceil($totalRows_WADAcwplayers/$maxRows_WADAcwplayers)-1;
?>

Link to comment
Share on other sites

And my question still remains...

 

Here is an expanded view of my code.

The first is from my search page that I tried to turn into a login page...The S_team field is what i want to pass as a variable to my results page....

Link to comment
Share on other sites

Guess my answer would be "How the heLL should I know? I don't speak PHPenese!"  ;D ;D  "Thats why i use DW8...it's suppose to do all that writing for me....

 

Then you should learn PHP. Don't assume that DW8 is going to produce good or even correct code. Learn how to do it yourself.

 

You will thank yourself in the long run.

 

Ken

Link to comment
Share on other sites

Guess my answer would be "How the heLL should I know? I don't speak PHPenese!"   ;D ;D  "Thats why i use DW8...it's suppose to do all that writing for me....

 

Then you should learn PHP. Don't assume that DW8 is going to produce good or even correct code. Learn how to do it yourself.

 

You will thank yourself in the long run.

 

Ken

;D I am slowly learning...but very SLOWLY  :o :o.

 

But while I'm learning I still need to resolve this problem....The suggestions so far still have not helped :'(

Link to comment
Share on other sites

Think i may have found the problem...but can't fugure out how to fix it. The original script has a form method of POST, but once I added a login server behavior, the method changes to POST....could that be the problem?

Original code:

 <form action="cwplayers_Results.php" method="get" name="WADASearchForm" id="WADASearchForm">
                <div class="WADAHeader">Search</div>
                <div class="WADAHorizLine"><img src="WA_DataAssist/images/Pacifica/Refined_tx.gif" alt="" height="1" width="1" border="0" /></div>
                <table class="WADADataTable" cellpadding="0" cellspacing="0" border="0">
                  <tr>
                    <th class="WADADataTableHeader">team:</th>
                    <td class="WADADataTableCell"><input type="text" name="S_team" id="S_team" value="" size="32" /></td>
                  </tr>
                </table>
                <div class="WADAHorizLine"><img src="WA_DataAssist/images/Pacifica/Refined_tx.gif" alt="" height="1" width="1" border="0" /></div>
                <div class="WADAButtonRow">
                  <table class="WADADataNavButtons" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td class="WADADataNavButtonCell" nowrap="nowrap"><input type="image" hspace="0" vspace="0" border="0" name="Search" id="Search" value="Search" alt="Search" src="WA_DataAssist/images/Pacifica/Refined_search.gif"  /></td>
                    </tr>
                  </table>
                </div>
              </form>

 

Once I added the LOGIN behavior, this is what I get:

 

<form action="<?php echo $loginFormAction; ?>" method="POST" name="WADASearchForm" id="WADASearchForm">
                <div class="WADAHeader"></div>
                <div class="WADAHorizLine"><img src="WA_DataAssist/images/Pacifica/Refined_tx.gif" alt="" height="1" width="1" border="0" /></div>
                <table class="WADADataTable" cellpadding="0" cellspacing="0" border="0">
                  <tr>
                    <th class="WADADataTableHeader">Team:</th>
                    <td class="WADADataTableCell"><select name="S_team" id="S_team">
                      <?php
do {  
?>
                      <option value="<?php echo $row_Recordset1['team']?>"><?php echo $row_Recordset1['team']?></option>
                      <?php
} while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));
  $rows = mysql_num_rows($Recordset1);
  if($rows > 0) {
      mysql_data_seek($Recordset1, 0);
  $row_Recordset1 = mysql_fetch_assoc($Recordset1);
  }
?>
                                </select></td>
                  </tr>
                  <tr>
                    <th class="WADADataTableHeader">Password:</th>
                    <td class="WADADataTableCell"><input name="password" type="text" id="password" value="ENTER PASSWORD" /></td>
                  </tr>
                </table>
                <div class="WADAHorizLine"><img src="WA_DataAssist/images/Pacifica/Refined_tx.gif" alt="" height="1" width="1" border="0" /></div>
                <div class="WADAButtonRow">
                  <table class="WADADataNavButtons" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td class="WADADataNavButtonCell" nowrap="nowrap"><input type="Submit" name="Search" id="Search" value="Search" /></td>
                    </tr>
                  </table>

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.