Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

captainmeowtron

macrumors member
Original poster
Dec 1, 2008
43
0
My code is giving me unexpected t variable errors around line 42, which is the if part of the statement. What am I doing wrong? :(
Code:
if($_POST['Title'] != "")
{
  $title_In = cleanvalue($_POST['Title']);
  $serialnum_In = cleanvalue($_POST['SerialNum']);
  $ImageURL_In = cleanvalue($_POST['ImageURL']);
  
  if (is_numeric($_POST['Price']))
  {
    $price_In = $_POST['Price'];
  }
  if (is_numeric($_POST['Shipping1']))
  {
    $shipping1_In = $_POST['Shipping1'];
  }
  if (is_numeric($_POST['Shipping2']))
  {
    $shipping2_In = $_POST['Shipping2'];
  }
 
 
}
else
{
  $Type_In=cleanvalue($_POST['type']);
  if ($Type_In=='blood orange')
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
Sometimes the error is before the line number they give, that's just when it notices there is an issue. Not sure if line 42 was the first line you posted or not.
 

Darth.Titan

macrumors 68030
Oct 31, 2007
2,905
753
Austin, TX
T_VARIABLE errors usually are caused by errors directly before the given line number.

Look for a missing ';' or unclosed set of parentheses before line 42. The code you've posted looks fine.
 

m3kilpat

macrumors regular
Jul 6, 2009
119
0
The only thing that I see is that blood orange may need double quotes around it and not single quotes.
 

captainmeowtron

macrumors member
Original poster
Dec 1, 2008
43
0
Thanks for all the help. I'm looking through it for some unclosed parentheses or anything like that. I didn't post the entire thing, figuring nobody wanted to scroll through pages of code.
 

SrWebDeveloper

macrumors 68000
Dec 7, 2007
1,871
3
Alexandria, VA, USA
@OP:

Based on the incomplete code you posted there are no syntax errors in the block of text - not that I mean you could run code as posted and it'll work, of course.

Do not be put off by any negative replies about debugging, etc and the single vs. double quote which is fine for a string with no variables embedded. Yes, your code has some minor issues, but as to your question:

It's just hard for us to help you when you do what you did (posting incomplete code based on a specific reference to a specific line number) - that's the only part which prevents us from helping you.

Please post all code.

-jim
 
Jun 30, 2009
318
0
Get yourself a real text editor. Try TextWrangler. It is free and powerful enough. This way, you will have line numbering.

When you get an error message, check the line first and the code around it/related to it. Check it for errors. If you don't manage to do it yourself, even after trying a lot, ask for help on a forum, but in a decent manner. That is, post all the code you've got between <?php ?>.
 

captainmeowtron

macrumors member
Original poster
Dec 1, 2008
43
0
I got Text Wrangler and it is helping me immensely. I selected "zap gremlins" and it deleted that extra curly brace (wherever it was). Now I am trying to redirect a parent window from a child window and then close the child window. It sounds simple, but after hours of googling and trying different things, I can't get it working. Here's what I've got (the entire page this time :D)
I want to submit the item to the shopping cart, open the shopping cart in the parent window, and close the popup. This is the popup. The parent window is not the shopping cart, but a catalog page.
Code:
<html>
<head>
<title>jewelery</title>
<STYLE type="text/css">
<!--
A { text-decoration:none }
-->
</STYLE>
</head>
<body bgcolor="#000000" TEXT="000000" body link="#000000" vlink="#000000" alink="#000000">
<table border="0" bordercolor="" style="background-color:#000000" width="100%" cellpadding="" cellspacing="">
<tr>
<td><img src="1.jpg"></td>
<td> </td>
<td>
<form method="post" action="ShoppingCart.php">
Item Title: <strong><font color="E3E5CD">cool spiral pendant</font></strong><br />
<font color="E3E5CD">Frosty turquoise glass wrapped in a steel spiral. 1.75 inches.</font><br />
<br />
Item Price: <strong><font color="E3E5CD">$30.00</font></strong><br />
Item Shipping: <strong>$5.00</strong><br />
Item Additional Shipping: <strong>$0.00</strong><br />
<input name="Title" type="hidden" value="cool spiral pendant" />
<input name="Price" type="hidden" value="30.00" />
<input name="Shipping1" type="hidden" value="0.00" />
<input name="Shipping2" type="hidden" value="0.00" />
<input name="cmd" type="hidden" id="cmd" value="1" />
<input type="submit" name="Submit" value="Add To Cart" / >
</form>
<script type="text/javascript" language="javascript">
onunload="opener.location='_parent';self.close()"
</script>
</td>
	</tr>
</table>
<center> 
</body>
</html>
 

Cerebrus' Maw

macrumors 6502
Mar 9, 2008
409
1
Brisbane, Australia
I got Text Wrangler and it is helping me immensely. I selected "zap gremlins" and it deleted that extra curly brace (wherever it was). Now I am trying to redirect a parent window from a child window and then close the child window. It sounds simple, but after hours of googling and trying different things, I can't get it working. Here's what I've got (the entire page this time :D)
I want to submit the item to the shopping cart, open the shopping cart in the parent window, and close the popup. This is the popup. The parent window is not the shopping cart, but a catalog page.
Code:
<html>
<head>
<title>jewelery</title>
<STYLE type="text/css">
<!--
A { text-decoration:none }
-->
</STYLE>
</head>
<body bgcolor="#000000" TEXT="000000" body link="#000000" vlink="#000000" alink="#000000">
<table border="0" bordercolor="" style="background-color:#000000" width="100%" cellpadding="" cellspacing="">
<tr>
<td><img src="1.jpg"></td>
<td> </td>
<td>
<form method="post" action="ShoppingCart.php">
Item Title: <strong><font color="E3E5CD">cool spiral pendant</font></strong><br />
<font color="E3E5CD">Frosty turquoise glass wrapped in a steel spiral. 1.75 inches.</font><br />
<br />
Item Price: <strong><font color="E3E5CD">$30.00</font></strong><br />
Item Shipping: <strong>$5.00</strong><br />
Item Additional Shipping: <strong>$0.00</strong><br />
<input name="Title" type="hidden" value="cool spiral pendant" />
<input name="Price" type="hidden" value="30.00" />
<input name="Shipping1" type="hidden" value="0.00" />
<input name="Shipping2" type="hidden" value="0.00" />
<input name="cmd" type="hidden" id="cmd" value="1" />
<input type="submit" name="Submit" value="Add To Cart" / >
</form>
<script type="text/javascript" language="javascript">
onunload="opener.location='_parent';self.close()"
</script>
</td>
	</tr>
</table>
<center> 
</body>
</html>

You have not attached the javascript to the submission of your form.

Code:
<form method="post" action="your.php" onSubmit="javaScriptFunction();" >
.....
</form>
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
The code,
PHP:
opener.location='_parent';
doesn't actually mean anything.

Assigning some actions to onunload would occur when the user moves to another page. You have an action to close the window, but by the time onunload is running, that window is likely being closed.

If you need the parent window to go to a different URL you would have something like,
PHP:
window.opener.location.href="some URL here";

You can have at the end of your ShoppingCart.php script a piece of JavaScript that closes the window. You can also submit the form using JavaScript since it looks you're forcing the users to have JavaScript enabled.

PHP:
document.formname.submit();
(You form would need a name attribute for this, or an id attribute and use the getElementById function.)

Here's one small discussion on this.
 

captainmeowtron

macrumors member
Original poster
Dec 1, 2008
43
0
I think I may have figured it out. Looks like it's
Code:
<form method="post" action="ShoppingCart.php" onsubmit="opener.location='ShoppingCart.php';self.close()">
...
<input type="submit" name="Submit" value="Add To Cart" / >
</form>
It seems to be working so far. I'll be back if something goes awry.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.