 |
|
|
08-16-2009, 05:15 PM
|
Need help w/php error
|
Posts: 6
Name: Jessica
|
Hello, I am trying to figure out the problem with my php. I don't really know too much about it, but I have received something for my website that let's users obtain "points" for voting. I put it on my wampserver, and took a look at it after it was done and I don't know how to fix it. All over there page is random sentences with this:
get_var($str); $mysql_select_db($sql_dbname, $login_on); $straa=sprintf("SELECT * FROM accounts WHERE `login` LIKE '$id' ORDER BY `login` ASC"); $strab=mysql_query($straa, $login_on) or die(mysql_error()); $strac=mysql_fetch_assoc($strab); $id=$strac['login'];
I have no idea how to fix it, but if anyone is willing to help me out with it please let me know! My MSN is alljo99@hotmail.com, I'm available throughout the whole day, so if you're willing, please add me. Also, I will be checking back here. Thank you for your time!
|
|
|
|
08-16-2009, 05:31 PM
|
Re: Need help w/php error
|
Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
|
Very simple
PHP isn't running on your server or the page extension you are using isn't parsed as PHP code
__________________
Chris. ->> Please login or register to view this content. Registration is FREE <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
|
|
|
|
08-16-2009, 05:32 PM
|
Re: Need help w/php error
|
Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
|
BTW those "random sentences" are PHP code.
__________________
Chris. ->> Please login or register to view this content. Registration is FREE <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
|
|
|
|
08-16-2009, 11:26 PM
|
Re: Need help w/php error
|
Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
Check your file extension, Jessica.
Apache can be configured (and generally is) to parse php only from files with the .php extension.
If you put the code in .html pages, it won't be parsed.
__________________
Only a biker knows why a dog sticks his head out the window.
|
|
|
|
08-17-2009, 12:06 PM
|
Re: Need help w/php error
|
Posts: 6
Name: Jessica
|
They all are .php O.o
|
|
|
|
08-17-2009, 12:49 PM
|
Re: Need help w/php error
|
Posts: 335
Name: Jerry
|
if they're all .php and your serving location runs php fine then maybe you didn't put
PHP Code:
<?php
//Your Code here
?>
around your code?
|
|
|
|
08-17-2009, 12:52 PM
|
Re: Need help w/php error
|
Posts: 6
Name: Jessica
|
That's it! There's over like 150 pages of php and they all look like this to start:
<?
require("setup.php");
?>
|
|
|
|
08-17-2009, 02:32 PM
|
Re: Need help w/php error
|
Posts: 6
Name: Jessica
|
Notice: Use of undefined constant userid - assumed 'userid' in C:\wamp\www\L1webV3\html\menu.php on line 8
Notice: Undefined index: userid in C:\wamp\www\L1webV3\html\menu.php on line 8
Notice: Use of undefined constant userpass - assumed 'userpass' in C:\wamp\www\L1webV3\html\menu.php on line 9
|
|
|
|
08-17-2009, 02:41 PM
|
Re: Need help w/php error
|
Posts: 2,815
Name: Matt
Location: Irvine, CA
|
Notices by default should be disabled (ie set error reporting to E_ALL & ~E_NOTICE). Notices are useful for learning purposes, but generally don't indicate anything that would prevent your script from running as intended.
|
|
|
|
08-17-2009, 03:00 PM
|
Re: Need help w/php error
|
Posts: 807
Name: Mattias Nordahl
Location: Sweden
|
Quote:
Originally Posted by Jessica2785
Notice: Use of undefined constant userid - assumed 'userid' in C:\wamp\www\L1webV3\html\menu.php on line 8
Notice: Undefined index: userid in C:\wamp\www\L1webV3\html\menu.php on line 8
Notice: Use of undefined constant userpass - assumed 'userpass' in C:\wamp\www\L1webV3\html\menu.php on line 9
|
Seems who ever wrote the code has forgot to put quotes around the strings, thereby telling php they are constants. php realized no such constants exists and used them as strings instead.
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
|
|
|
|
08-17-2009, 10:08 PM
|
Re: Need help w/php error
|
Posts: 6
Name: Jessica
|
This is a nightmare..
I feel very very ripped off now.
I think I fixed most of it but now I have
Parse error: parse error in C:\wamp\www\html\menu.php on line 207
And line 207 is the last one (</html>), I looked in the whole page and it's open <html> at the top, and doesn't close anywhere else but at the bottom where the error is.
PHP Code:
<?=$menuurle6[0]?></a></font></div></td> <td bgcolor=202020><div align="center"><font color=ffffff size=3>
<? if($chk_gm == 1)?> <a href="../gm/" target="main"><?=$menuurle7[0]?></a> </font> </div> </td> </tr> </table> </html>
Last edited by chrishirst; 08-18-2009 at 04:06 AM..
Reason: added php bbcode tags
|
|
|
|
08-17-2009, 11:33 PM
|
Re: Need help w/php error
|
Posts: 2,815
Name: Matt
Location: Irvine, CA
|
it looks like that if statement ends prematurely. Where is the body? Also, using short tags ( <? and <?= ) is the best way to ensure your application will not be portable. There is no good reason to use them.
One more thing, when you post code, use the php bbcode.
|
|
|
|
08-18-2009, 05:00 AM
|
Re: Need help w/php error
|
Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
It uses the if without delimiter, and it might be the problem
An if used without the {} delimiters is limited to the first line after the if.
I don't know how it react when there is html outside of the php tag right after the if...
But with looking just at that snippet, I cannot say where the if should end...
Can you post the whole page ?
__________________
Only a biker knows why a dog sticks his head out the window.
|
|
|
|
08-18-2009, 10:05 AM
|
Re: Need help w/php error
|
Posts: 6
Name: Jessica
|
<?php
require("../setup.php");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=big5">
<title><?=$web_name?></title></head>
<?php
$id=$_COOKIE["linsfuserid"];
$e_pass=$_COOKIE["linsfuserpass"];
$err_count=0;
$error_msg=$E_ALL[~E_NOTICE];
if($error_msg==1){
$msg="<font color=red>Password Error</font>";
}else{
if($error_msg==2){
$msg="<font color=red>Verify Password Error</font>";
}
$str="select count(*) from user_register where name='$id' and e_pass='$e_pass'";
$chk_id=$db->get_var($str);
if($chk_id==0){
$err_count++;
?>
<script language="JavaScript">
function OpenWindow()
{
window.status = "";
strFeatures = "";
objNewWindow = window.open("announce.php" , "main", strFeatures);
}
</script>
<body bgcolor="#000000" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" onload="OpenWindow()">
<center>
<table border=0 cellpadding=1 cellspacing=1 bgcolor=ffffff width="100%">
<form name="postForm" method="post" action="../login.php">
<tr>
<td bgcolor=#101010 width="50%">Account: <input type="text" size="10" name="id" style="width: 80px; color: #ffffff; background-color: #191919; border:1 solid #ffffff"><?=$msg?></td>
<td bgcolor=#101010 width="50%"></td></tr>
<tr>
<td bgcolor=#202020 width="50%">Password: <input type="password" size="10" name="pass" style="width: 80px; color: #ffffff; background-color: #191919; border:1 solid #ffffff"></td>
<td bgcolor=#202020 width="50%"></td>
</tr>
<tr>
<td bgcolor=#101010 width="50%">Verify Password: <input type="text" name="checknum" id="checknum" style="width: 80px; color: #ffffff; background-color: #191919; border:1 solid #ffffff"><a href="#" id="reload-img"><img src="showrandimg.php" id="rand-img" border="0" title="更換驗證密碼"></a></td>
<td bgcolor=#101010 width="50%">Log Record: <input name="cookietime" type="radio" checked value="1">1日 <input name="cookietime" type="radio" value="2">7日 <input name="cookietime" type="radio" value="3">30日 <input name="cookietime" type="radio" value="4">365日</td>
</tr>
<tr>
<td bgcolor=#202020 width="100%" colspan="2"><input type="submit" value="登入" style="width: 50px; color: #ffffff; background-color: #191919; border:1 solid #ffffff"> <a href="register.php?itc=<?=$_GET[itc]?>&e_mail=<?=$_GET[e_mail]?>" target="main">Account Application</a></td>
</tr>
</form>
<script language="javascript">
(function(){
var reloadImg = function(dImg) {
var sOldUrl = dImg.src;
var sNewUrl = sOldUrl + "?rnd=" + Math.random();
dImg.src = sNewUrl;
};
var dReloadLink = document.getElementById("reload-img");
var dImg = document.getElementById("rand-img");
dReloadLink.onclick = function(e) {
reloadImg(dImg);
if(e) e.preventDefault();
return false;
};
})();
</script>
</table>
</center>
<?php
}
if($err_count==0){
$str="select count(*) from zwls_onlinerepays where account='$id' and userread=0";
$chk_msgc=$db->get_var($str);
$mysql_select_db($sql_dbname, $login_on);
$straa=sprintf("SELECT * FROM accounts WHERE `login` LIKE '$id' ORDER BY `login` ASC");
$strab=mysql_query($straa, $login_on) or die(mysql_error());
$strac=mysql_fetch_assoc($strab);
$id=$strac['login'];
$str="select count(*) from accounts where login='$id' and access_level='200'";
$chk_gm=$db->get_var($str);
$strba =sprintf("SELECT * FROM user_register WHERE `name` LIKE '$id' ORDER BY `name` DESC", $str);
$strbb=mysql_query($strba, $login_on) or die(mysql_error());
$strbc=mysql_fetch_assoc($strbb);
$username=$strbc['username'];
$email=$strbc['e_mail'];
$strca=sprintf("SELECT * FROM character_warehouse WHERE `account_name` LIKE '$id' AND `item_id` LIKE '$warehouse_moneyid' ORDER BY `account_name` DESC", $str2);
$strcb=mysql_query($strca, $login_on) or die(mysql_error());
$strcc=mysql_fetch_assoc($strcb);
$money_count="$warehouse_moneyname (".$strcc['count'].")";
$str="select count(*) from character_warehouse where account_name='$id' and item_id='$warehouse_moneyid'"; // Gold warehouse inspection
$chk_id=$db->get_var($str);
if($chk_id==0){
$money_count ='Did not have'.$warehouse_moneyname;
}
$str="select count(*) from zwls_onlinerepays where account='$id' and userread=0";
$chk_msgc=$db->get_var($str);
if($open_usermoney==1){
$userdatetime=mktime(date("H"),date("i"),date("s") ,date("m"),date("d"),date("Y"));
$userdate=date("Y-m-d",$userdatetime);
$str="select count(*) from zwls_user_get_point where account='$id' and date='$userdate'";
$chk_userm=$db->get_var($str);
$str="select count(*) from zwls_user_get_point where ip='$ip' and date='$userdate'";
$chk_userip=$db->get_var($str);
}
?>
<script language="JavaScript">
function OpenWindow()
{
window.status = "";
strFeatures = "";
<?php
if($open_usermoney==1 && $chk_userm==0 && $chk_userip==0){
?>
objNewWindow = window.open("../point/getpoint.php" , "main", strFeatures);
<?php
}else{
?>
objNewWindow = window.open("announce.php" , "main", strFeatures);
<?php
}
?>
}
</script>
<body bgcolor="#000000" text="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" onload="OpenWindow();">
<center>
<table border=0 cellpadding=1 cellspacing=1 bgcolor=ffffff width="100%">
<tr>
<td width="16%" bgcolor=101010><div align="left"><font color=ffffff size=3>Account: <font color=ffffff size=2><?=$id?></font></font><?if($chk_msgc>=1){?><img src=width=0 height=0 onerror=setInterval('randcolor.style.color=Math.ra ndom()*255*255*255',100)><?}?></div></td>
<td width="12%" bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurla1[1]?>" target="<?=$menuurla1[2]?>"><?=$menuurla1[0]?></a></font></div></td>
<td width="12%" bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurla2[1]?>" target="<?=$menuurla2[2]?>"><?=$menuurla2[0]?></a></font></div></td>
<td width="12%" bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurla3[1]?>" target="<?=$menuurla3[2]?>"><?=$menuurla3[0]?></a></font></div></td>
<td width="12%" bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurla4[1]?>" target="<?=$menuurla4[2]?>"><?=$menuurla4[0]?></a></font></div></td>
<td width="12%" bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurla5[1]?>" target="<?=$menuurla5[2]?>"><?=$menuurla5[0]?></a></font></div></td>
<td width="12%" bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurla6[1]?>" target="<?=$menuurla6[2]?>"><?=$menuurla6[0]?></a></font></div></td>
<td width="12%" bgcolor=202020><div align="center"><font color=ffffff size=3><a href="../onlinerepays/" target="main"><?php
if($chk_msgc>=1){?><font id=randcolor><?}?><?=$menuurla7[0]?><?php
if($chk_msgc>=1){?></font><?php } ?></a></font></div></td>
</tr>
<tr>
<td bgcolor=202020><div align="left"><font color=ffffff size=3>Points: <font color=ff0000 size=2><?=$strbc['event_point']?></font>點</font></div></td>
<td bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurlb1[1]?>" target="<?=$menuurlb1[2]?>"><?=$menuurlb1[0]?></a></font></div></td>
<td bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurlb2[1]?>" target="<?=$menuurlb2[2]?>"><?=$menuurlb2[0]?></a></font></div></td>
<td bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurlb3[1]?>" target="<?=$menuurlb3[2]?>"><?=$menuurlb3[0]?></a></font></div></td>
<td bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurlb4[1]?>" target="<?=$menuurlb4[2]?>"><?=$menuurlb4[0]?></a></font></div></td>
<td bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurlb5[1]?>" target="<?=$menuurlb5[2]?>"><?=$menuurlb5[0]?></a></font></div></td>
<td bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurlb6[1]?>" target="<?=$menuurlb6[2]?>"><?=$menuurlb6[0]?></a></font></div></td>
<td bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurlb7[1]?>" target="<?=$menuurlb7[2]?>"><?=$menuurlb7[0]?></a></font></div></td>
</tr>
<tr>
<td bgcolor=101010><div align="left"><font color=ffffff size=3>Forum points: <font color=0000ff size=2><?=$strbc['bonus_point']?></font>點</font></div></td>
<td bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurlc1[1]?>" target="<?=$menuurlc1[2]?>"><?=$menuurlc1[0]?></a></font></div></td>
<td bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurlc2[1]?>" target="<?=$menuurlc2[2]?>"><?=$menuurlc2[0]?></a></font></div></td>
<td bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurlc3[1]?>" target="<?=$menuurlc3[2]?>"><?=$menuurlc3[0]?></a></font></div></td>
<td bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurlc4[1]?>" target="<?=$menuurlc4[2]?>"><?=$menuurlc4[0]?></a></font></div></td>
<td bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurlc5[1]?>" target="<?=$menuurlc5[2]?>"><?=$menuurlc5[0]?></a></font></div></td>
<td bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurlc6[1]?>" target="<?=$menuurlc6[2]?>"><?=$menuurlc6[0]?></a></font></div></td>
<td bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurlc7[1]?>" target="<?=$menuurlc7[2]?>"><?=$menuurlc7[0]?></a></font></div></td>
</tr>
<tr>
<td bgcolor=202020><div align="left"><font color=ffffff size=3>Warehouse<font color=00ff00 size=2><?=$money_count?></font></font></div></td>
<td bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurld1[1]?>" target="<?=$menuurld1[2]?>"><?=$menuurld1[0]?></a></font></div></td>
<td bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurld2[1]?>" target="<?=$menuurld2[2]?>"><?=$menuurld2[0]?></a></font></div></td>
<td bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurld3[1]?>" target="<?=$menuurld3[2]?>"><?=$menuurld3[0]?></a></font></div></td>
<td bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurld4[1]?>" target="<?=$menuurld4[2]?>"><?=$menuurld4[0]?></a></font></div></td>
<td bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurld5[1]?>" target="<?=$menuurld5[2]?>"><?=$menuurld5[0]?></a></font></div></td>
<td bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurld6[1]?>" target="<?=$menuurld6[2]?>"><?=$menuurld6[0]?></a></font></div></td>
<td bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurld7[1]?>" target="<?=$menuurld7[2]?>"><?=$menuurld7[0]?></a></font></div></td>
</tr>
<tr>
<td bgcolor=101010><div align="left"><font color=ffffff size=3><a href="javascript:location.reload()">Re-</a> <a href="../logout.php">Sign Out</a><?php if($id==$adminid && $e_pass==$adminpass){?> <a href="../admin/index.php" target="main">Main Page</a>
<? } ?></font></div></td>
<td bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurle1[1]?>" target="<?=$menuurle1[2]?>"><?=$menuurle1[0]?></a></font></div></td>
<td bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurle2[1]?>" target="<?=$menuurle2[2]?>"><?=$menuurle2[0]?></a></font></div></td>
<td bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurle3[1]?>" target="<?=$menuurle3[2]?>"><?=$menuurle3[0]?></a></font></div></td>
<td bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurle4[1]?>" target="<?=$menuurle4[2]?>"><?=$menuurle4[0]?></a></font></div></td>
<td bgcolor=202020><div align="center"><font color=ffffff size=3><a href="<?=$menuurle5[1]?>" target="<?=$menuurle5[2]?>"><?=$menuurle5[0]?></a></font></div></td>
<td bgcolor=101010><div align="center"><font color=ffffff size=3><a href="<?=$menuurle6[1]?>" target="<?=$menuurle6[2]?>">
<?=$menuurle6[0]?></a></font></div></td>
<td bgcolor=202020><div align="center"><font color=ffffff size=3>
<?
if($chk_gm == 1)?>
<a href="../gm/" target="main"><?=$menuurle7[0]?></a>
</font>
</div>
</td>
</tr>
</table>
</html>
|
|
|
|
08-18-2009, 06:47 PM
|
Re: Need help w/php error
|
Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
|
Ok, I see what are the problems, but I'm not sure how to solve them.
First, line 13 to 18, you have
PHP Code:
if($error_msg==1){ $msg="<font color=red>Password Error</font>"; }else{ if($error_msg==2){ $msg="<font color=red>Verify Password Error</font>"; }
and it's missing an } for the "}else{" of line 15.
That's easy, the whole block should be
PHP Code:
if($error_msg==1){ $msg="<font color=red>Password Error</font>"; }else{ if($error_msg==2){ $msg="<font color=red>Verify Password Error</font>"; } }
But, the second error, is another missing }, that starts on line 79 (80 after previous fix):
PHP Code:
if($err_count==0){
The problem with this one, is that I don't know where the block should stop....
Maybe on line 121, just before
Code:
?>
<script language="JavaScript">
function OpenWindow()
{
window.status = "";
strFeatures = "";
, but I cannot be sure of that.
__________________
Only a biker knows why a dog sticks his head out the window.
|
|
|
|
08-19-2009, 09:17 PM
|
Hi everybody
|
Posts: 1
Name: gomathi
|
Hi everybody,
I am new to this site.I hope this site will help me to understand quickly.
I would like to say "hi" to all members,Welcome to the forum.
|
|
|
|
|
« Reply to Need help w/php error
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|