Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Will This Script Work?
Old 06-15-2006, 02:17 PM Will This Script Work?
Average Talker

Posts: 22
Trades: 0
Will this script work:

PHP Code:
<?php  
/* written: 3-31-05 */  
session_start(); 
session_id();
//get the username and password from the session, almost like magic!  
$password $_SESSION['password'];  
$username $_SESSION['username'];  
//connect to DB, you may need to change settings  
mysql_connect("localhost""username""password") or die(mysql_error());  
mysql_select_db("table") or die(mysql_error());  
$res mysql_query("SELECT * FROM logsys WHERE username='$username' AND password='$password'") or die(mysql_error());  
if(
mysql_num_rows($res) == 1)  
{  
while(
$get=mysql_fetch_array($res))
$Buildingneeded1 5
if($get[building1] < Buildingneeded1){ 
echo 
" ";
}
else{ 
  echo
  
"<form action="BuyBuildings.php" method="post">
<p>HQ <? 
while(
$get=mysql_fetch_array($res))
echo(" 
Current level<b" . $get[building1] . "</b> )");?> </p>
<p>The HQ is where the main stuff in your base  happens.</p>
<table>
<tr>
<td>Money: 50 Food: 50 Wood: 50 Power: 50 </td>
<td><input name="
building1" type="hidden" value="1" /></td>
</tr>
</table>
<input type="
submit" name="submit" value="Buy" />
</form>"
;
<?else  
//hmmm we didnt find there data? error time! :eek:  
{  
echo(
"<center><font face=\"Verdana\">Sorry, your not logged in, proceed <a href=\"login.php\">here</a> to login.");  
}  
?>
What i want it to do is only display the form if the building in the database is above level 5. Now would this script work?
SuperDude is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-15-2006, 02:17 PM Re: Will This Script Work?
stOx's Avatar
Machine

Latest Blog Post:
Worlds Smallest Car - Peel P50
Posts: 2,111
Name: Matt. (>',')>
Location: London, England.
Trades: 0
Wy don't you try it?
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
stOx is offline
Reply With Quote
View Public Profile Visit stOx's homepage!
 
Old 06-15-2006, 02:21 PM Re: Will This Script Work?
Average Talker

Posts: 22
Trades: 0
I did and it didn't work
SuperDude is offline
Reply With Quote
View Public Profile
 
Old 06-15-2006, 02:26 PM Re: Will This Script Work?
stOx's Avatar
Machine

Latest Blog Post:
Worlds Smallest Car - Peel P50
Posts: 2,111
Name: Matt. (>',')>
Location: London, England.
Trades: 0
Doesn't work in what sense?
Doesn't do what you want, or gives errors?

This line
$Buildingneeded1 = 5
Looks like its missing a ; at the end... it should be like
$Buildingneeded1 = "5";
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
stOx is offline
Reply With Quote
View Public Profile Visit stOx's homepage!
 
Old 06-15-2006, 04:21 PM Re: Will This Script Work?
Average Talker

Posts: 22
Trades: 0
I did what you said and the error i get is:

Quote:
Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/robsdabe/public_html/levels.php on line 23
SuperDude is offline
Reply With Quote
View Public Profile
 
Old 06-15-2006, 05:20 PM Re: Will This Script Work?
stOx's Avatar
Machine

Latest Blog Post:
Worlds Smallest Car - Peel P50
Posts: 2,111
Name: Matt. (>',')>
Location: London, England.
Trades: 0
I just had a proper look through your code and it's all over the place.
You ave php starting and ending at random places and " where they are not allowed.

PHP Code:
<?php  
/* written: 3-31-05 */  
session_start(); 
session_id();

//get the username and password from the session, almost like magic!  
$password $_SESSION['password'];  
$username $_SESSION['username'];  
//connect to DB, you may need to change settings  


mysql_connect("localhost""username""password") or die(mysql_error());  
mysql_select_db("table") or die(mysql_error());  
$res mysql_query("SELECT * FROM logsys WHERE username='$username' AND password='$password'") or die(mysql_error());  
if(
mysql_num_rows($res) == 1)  
{  
while(
$get=mysql_fetch_array($res))
$Buildingneeded1 "5";
if(
$get[building1] < Buildingneeded1)

echo 
" ";
}
else

 echo 
'<form action="BuyBuildings.php" method="post">
<p>HQ'

 
while(
$get=mysql_fetch_array($res))
echo 
' ( Current level<b> " . $get[building1] . "</b> )
 
</p>
<p>The HQ is where the main stuff in your base  happens.</p>
<table>
<tr>
<td>Money: 50 Food: 50 Wood: 50 Power: 50 </td>
<td><input name="building1" type="hidden" value="1" /></td>
</tr>
</table>
<input type="submit" name="submit" value="Buy" />
</form>'
;

}

else  
//hmmm we didnt find there data? error time! :eek:  
{  
echo 
'<center><font face=\"Verdana\">Sorry, your not logged in, proceed <a href=\"login.php\">here</a> to login.';  
}  
?>
Try that..
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
stOx is offline
Reply With Quote
View Public Profile Visit stOx's homepage!
 
Old 06-15-2006, 05:30 PM Re: Will This Script Work?
Average Talker

Posts: 22
Trades: 0
Ok cheers, tried it and now i get:

Quote:
Parse error: parse error, unexpected T_ELSE in /home/robsdabe/public_html/levels.php on line 44
SuperDude is offline
Reply With Quote
View Public Profile
 
Old 06-15-2006, 08:57 PM Re: Will This Script Work?
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,918
Name: Keith Marshall
Location: Connecticut
Trades: 0
You don't need to escape your quotes in the last echo line.

PHP Code:
echo '<center><font face="Verdana">Sorry, your not logged in, proceed <a href="login.php">here</a> to login.'
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Will This Script Work?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26525 seconds with 12 queries