Author Topic: perplexing "parse error" that i've yet to figure out how to fix it.  (Read 480 times)

Offline 133794m3r

  • Level 22
  • *
  • Posts: 265
  • Reputation: +2/-0
    • View Profile
Ok here's my code thus far. I'm just trying to do a basic query to get the exp from the previous level that i've already recorded. Now for some reason PHP is giving me this error upon the 11th row. So i've included here all code up until then. "Parse error: parse error in C:\wamp\www\tester\ExpCalculator.php on line 11"

Code: [Select]
<?php
(int)$CL $_POST['Level'];
$dbhost 'localhost';
$dbuser 'user';
$dbpass 'pass';
$dbname 'various_values';
if (
$CL <= 120) {
$conn mysql_connect($dbhost,$dbuser,$dbpass)
or die (
'ERROR CONNECTING');
mysql_select_db($dbname);
$query sprintf("SELECT EXP FROM xp WHERE id = ($CL-1)"),
$PXP mysql_query($query);

After looking over my code i find nothing wrong with it. The only thing i can think of is that it's trying to "auto-run" the code w/o any input as ther'es nothing currently in the "level" form later on in the code. The main thing that's confusing me is why it's still trying to "auto-run" i thought it'd do nothing if something's not there. Should i add some sort of thing to stop it from going?

Offline Nox

  • Level 35
  • **
  • Posts: 768
  • Reputation: +12/-2
    • View Profile
Re: perplexing "parse error" that i've yet to figure out how to fix it.
« Reply #1 on: November 19, 2009, 06:36:39 AM »
$query = ...

at the end is comma instead of semi-colon... some IDE like NetBeans would show such errors to you
btw you have sprintf without any arguments, that's kinda redudant

the bracket from if is probably closed somewhere we don't see I guess
Meet us at an IRC irc.freenode.net #bbg as well
https://vimeo.com/36579366 (a must-watch) | Join BOINC - no longer a hype, but you can help never the less

Offline 133794m3r

  • Level 22
  • *
  • Posts: 265
  • Reputation: +2/-0
    • View Profile
Re: perplexing "parse error" that i've yet to figure out how to fix it.
« Reply #2 on: November 19, 2009, 06:49:43 AM »
yeah i'm using Notepad++ to make sure everything closes properly. And hmm i guess i'll try to get netbeans. Didn't know it also showed PHP errors.

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal