Jump to content


Photo

Noobie Stuff: Very Basics Explained Easily


  • Please log in to reply
117 replies to this topic

#81 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 12 August 2006 - 09:21 AM

Hi Im Back Again.

I Have Started My Little Project But Have Come Across A Little Prob While Trying To Pull Info From My Database.

I Have Changed The Names Of What I Want Pulled From Database Because I Am Keeping My project A Secret Till It's Done. (though i have made it obvious sometimes).

Here Is The Code.

project_home.php:

<?php
session_start();
if(empty($_SESSION['username']) or empty($_SESSION['id'])){//if there is nothing in the session
echo 'you are not logged in';
exit;//quit the page so they cant view anything else
}else{
$username = base64_decode($user);
$password = base64_decode($pass);
echo 'You Are Now Logged In ';
echo $username;
echo '.';
include ('dbinfo.inc.php');
$sql_1 = 'SELECT * FROM user_[b]sumthing[/b] WHERE username == $username AND password == $password';
$result_1 = mysql_query($sql_1);
$num_1 = 'mysql_num_rows($result_1)';
$row = 'mysql_fetch_assoc($result_1)';
echo '<br><a href="sumthin/summit_else.php"><img src="images/summit/summit_else.png alt="Summit Else"></a>';
echo 'Level ';
echo $row['summit_else'];
}
?>

basically im tryin to make it so that the page displays the number in the summit_else field after level.

prob it-all it displays is "Level s"

which makes me think its echoing the s from summit_else.

ys dat?
[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]

#82 Guest_huey4657_*

Guest_huey4657_*
  • Guests

Posted 12 August 2006 - 10:27 AM

This probably sounds stupid but can someone tell me what noob stands for?

#83 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 12 August 2006 - 12:43 PM

Noob, n00b, newbie is slang for someone being new to something. Usually you experience this sort of slang when playing online games. This site exlpains this word.

#84 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 12 August 2006 - 04:44 PM

yeh soz-im a bit of a gamer-not sum gamer that stays inside al the time thouhg-i just like games-especially strategy and css :D  ROCK ON

ne1 know the answer to my prob?
[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]

#85 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 12 August 2006 - 04:55 PM

Did you actually mean to or have this in your code in your SQL query?

[b]sumthing[/b]

with the [b] tags? Or was that part of displaying it here in your post?

#86 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 12 August 2006 - 05:01 PM

ooh lol ignore that-it aint in the actual code-forgot that was there-it was for i showed it to someone else lol

any other ideas why?
[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]

#87 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 12 August 2006 - 05:25 PM

Ok, cool. So, to be perfectly clear, you stated this:

basically im tryin to make it so that the page displays the number in the summit_else field after level.

prob it-all it displays is "Level s"

which makes me think its echoing the s from summit_else.


I can't see where it's pulling a stray 's' from but this line needs a closing " after your .png

<img src="images/summit/summit_else.png alt="Summit Else">





#88 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 12 August 2006 - 06:20 PM

thanx for that-sorted 1 prob-but i still getting the s echoed
[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]

#89 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 12 August 2006 - 06:35 PM

The only logical explanation is that this query:

echo $row['summit_else'];

has a field or entry with an 's' in it. Otherwise there's nothing else in your posted code that echo's an 's'.

#90 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 12 August 2006 - 06:46 PM

there aint an m in th database

thats y im confused-there is no m to echo-anywhere!
[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]

#91 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 12 August 2006 - 06:49 PM

Ok, is it an M or an S ?? Seems to change with each post  ???

#92 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 12 August 2006 - 07:00 PM

sori

its actually an m-i was sayin s randomly


its an m-definately m sorri lol
[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]

#93 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 12 August 2006 - 07:15 PM

Ok, now that we have that clear :)

I know PHP can do a lot of things. But, displaying a character without a source or some code that creates that character is not one of them. If that's all you code (meaning that there's no other parts to this that you haven't displayed) then the only reasonable solution is that your database table being called either contains an 'm' or a set of characters that the browser is interpreting as an 'm'.

Your code has these echo statements in it:

echo 'you are not logged in';

echo 'You Are Now Logged In ';
echo $username;
echo '.';

echo '<br><a href="sumthin/summit_else.php"><img src="images/summit/summit_else.png alt="Summit Else"></a>';
echo 'Level ';
echo $row['summit_else'];


If we go through these we note that none of them have an extra 'm' in them. Unless, of course, something to do with your encryption is causing this display. But, ruling that out, all of the echo statements are very straight forward. The only one we don't know the results of is the last one summoning the $row since it comes from the database. If there's an 'm' being echoed then it has to be coming from somewhere in that table since, according to your posts, the rogue 'm' is being displayed right after the word 'Level ' which indicates the last echo statement would be the logical choice.

#94 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 12 August 2006 - 07:25 PM

yes that is true.

ok il tell u the field that is being echoed.

it is called mining_depot

that gives my project away but its better than not avin one at al cus of this.

so it would be echo $row['mining_depot']

im going to try without encryption and see what happens-if anyone thinks of something else please say

Pudgemeister
[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]

#95 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 12 August 2006 - 07:28 PM

Actually it doesn't matter the name of the field or table. The echo statement is displaying whatever it contains. And, apparently, it contains an 'm' in there somewhere. Not sure what else to tell you except echo means echo. :)

#96 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 12 August 2006 - 07:33 PM

in the field-mining_depot-is a number "0" in this case.

it is a bigint field

seriously that is all thats there.

is it anything to do with username and password?

m,aybe its something thats being passed from an erlier file

these are ALL the files:

index.php

<?php
//Title//
echo '<center>Game Testing</center><br><br><br>';
//Register Form//
echo 'Register';
echo '<form action="register.php" method="post">';
echo 'First Name:<input type="text" name="first_name"><br>';
echo 'Last Name:<input type="text" name="last_name"><br>';
echo 'Username:<input type="text" name="username"><br>';
echo 'Password:<input type="password" name="password"><br>';
echo 'Confirm Password:<input type="password" name="password2"><br>';
echo 'E-Mail:<input type="text" name="mail"><br>';
echo 'Confirm E-Mail:<input type="text" name="mail2"><br>';
echo '<input type="Submit" value="Register Me"></form><br><br><br>';

//Login Form//
echo 'Login';
echo '<form action="login.php" method="post">';
echo 'Username:<input type="text" name="username"><br>';
echo 'Password:<input type="password" name="password"><br>';
echo '<input type="submit" value="Log In"></form>';

?>


login.php

<?php

// check username and password POST vars exists first, before continuing
if(isset($_POST['username']) && isset($_POST['password']))
{
    session_start();

    include ("dbinfo.inc.php");

    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['password']);

    $sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
    $result = mysql_query($sql) or die(mysql_error());

    // returns numbers of matches found.
    $users = mysql_num_rows($result);

    // if there was 1 result returned, user has successfully logged in
    if ($users == 1)
    {
        $row = mysql_fetch_assoc($result);

        $_SESSION['id'] = $row['id'];
        $_SESSION['username'] = $row['username'];
				$_SESSION['password'] = $row['password'];
        header("Redirect=5; URL=logged_in.php");

        echo "You are logged in! You'll be automatically redirected in 5 secounds. ";
        echo 'Or click <a href="island_home.php">here</a> if you are impatient';
    }
    // user was not logged in, username/password combo incorrect
    else
    {
        echo 'Your Password and/or Username are incorrect<br />Please try agin<br /><br /><a href="index.php">Here</a>';
    }
}
else
{
    die("You have either come to this page in error or you did not fill in the login form!");
}
?>

island_home.php

<?php
session_start();
if(empty($_SESSION['username']) or empty($_SESSION['id']) or empty($_SESSION['password'])) {//if there is nothing in the session
echo 'you are not logged in';
exit;//quit the page so they cant view anything else
}else{
echo 'You Are Now Logged In ';
echo $username;
echo '.';
include ('dbinfo.inc.php');
$sql_1 = "SELECT * FROM user_buildings WHERE username == '$username' AND password == '$password'";
$result_1 = mysql_query($sql_1);
$num_1 = 'mysql_num_rows($result_1)';
$row = 'mysql_fetch_assoc($result_1)';
echo '<br><a href="buildings/mining_depot.php"><img src="images/buildings/mining_depot.png" alt="Mining Depot"></a>';
echo '<br>Level ';
echo $row['mining_depot'];
}
?>

in the database table "user_buildings" are the fields "id username password mining_depot wood_farm  energy_dock  filteration_airport  research_factory  sub_terrain_war_station  land_war_station  oceanic_war_dock  war_airport"

now is there anything being passed along or anything anyone else can think of?

this is relli weird tbh (to me anyway lol)

Pudgemeister
[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]

#97 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 13 August 2006 - 06:14 AM

ive also taken out the encryption to make sure-it still returns m
[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]

#98 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 August 2006 - 07:07 AM

what is the outcome you need palese also post the database for us and exsplain the database entrys ok.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#99 Pudgemeister

Pudgemeister
  • Members
  • PipPipPip
  • Advanced Member
  • 94 posts
  • LocationCornwall, England, UK,

Posted 14 August 2006 - 05:19 PM

ok the outcome i want is for it to echo level and then the number in the field mining_depot in the database table user_buildings
[div align="center"][a href="http://imageshack.us" target="_blank"][/a]
[/div]

#100 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 14 August 2006 - 05:25 PM

redarrow, the problem he's having is that when displaying his results to the browser there's a rogue 'm' character showing up. After staring at his posted code until i've gone blind, there's no 'echo m' anywhere. There must be an entry in his database that's causing that character to display. Especially when it's being displayed in the sequence shown:

echo '<br><a href="buildings/mining_depot.php"><img src="images/buildings/mining_depot.png" alt="Mining Depot"></a>';
echo '<br>Level ';
echo $row['mining_depot'];

The results display as this:

Level  m


The question he has is WHERE is the 'm' coming from.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users