Jump to content

[SOLVED] Something Wierd


Kryllster

Recommended Posts

I just switched servers, Im running xp with e>novative>wamp whereas before I was running another wamp. Well the problem is I can create the database and create the character info in that db but when I log in apparently the session isnt starting or something cause now the info I want displayed isn't showing up like it did in WAMP5. Im using InnoDB but was wondering if that had anything to do with it???

 

Thanks In advance,

Link to comment
Share on other sites

session_start();

$uname = $_SESSION['uname'];

$_SESSION['uname'] == $uname;

 

This is at the very start of the page after the <? it worked before so I'm a little confused

 

it says this "Undefined variable on line 4"

 

Hope this helps

Link to comment
Share on other sites

Yeah definately -- plus if its giving a line 4, i only see 3 lines and so thats obviously not all the code for this...  use the [*code] [/*code] commands with both the <?php and ?> tags for syntax highlighting and let us see the code in its entirety.

Link to comment
Share on other sites

Post the line 4 and Check the tmp folder it would be outside your htdocs folder . There you will find some files with name sess_* check weather there is any files with name ??

EDIT

----------------------------

== is for Comparing

= is for assigning

Link to comment
Share on other sites

I'm sorry i am maybe being a little confusing I have change ot around a couple times but here is the ssid in the sessions folder:

 

uname|N;

 

Here is the code for the character sheet

<?php
session_start();
$uname = $_SESSION['uname'];
if ($_SESSION['uname'] == $uname);
{
include ('config.php');

 

Sorry about the mess up like I said it worked before thats whats wierd to me!!

Link to comment
Share on other sites

you dont need the ; there...

 

<?php
session_start();
$uname = $_SESSION['uname'];
if ($_SESSION['uname'] == $uname) { // note the ; is missing
include ('config.php');

 

btw your quote is false for php programming...  you may have the biggest imagination in the world but without the knowledge whatever you've imagined will never be a reality.

Link to comment
Share on other sites

oh duh -- i see why i put a $ in front of it -- sorry most the stuff ive been doing is in $'s and so i often put a $ in front of a function take the $ off and try it -- or revert back to your code and just remove the ; from that one line and see how it works...

Link to comment
Share on other sites

Ok here is the first original code that worked with WAMP5 (please don't laugh) oh another thing is I am using frames if that would have anything to do with it??

 

<?php
session_start();
$_SESSION['uname'] == $uname;
include ('config.php');
$uname = $_SESSION['uname'];
// Select data from database
$sql="SELECT * FROM $tbl_name WHERE uname='$uname'";
$result=mysql_query($sql);
// Put info into array Hopefully
while($row=mysql_fetch_assoc($result)) 
{
echo "<html>";
echo "<head>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"gamestyle.css\" />";
echo "</head>";
echo "<body>";
echo "<center>";
echo $uname;
echo "<br>";
echo "<img src=\"images/Gallery/Elf.jpg\" align=\"center\">";
echo "</center>";
echo "<br>";
echo "<img src=\"images/staff.gif\" align=\"center\">";
echo "<br>";
echo "<font color=\"#b22222\">Character Info</font>";
echo "<br>";
echo "<img src=\"images/staff.gif\" align=\"center\">";
echo "<br>";
echo "<small>";
echo "Race: ";
echo "<font color=\"#b22222\">";
echo $row['race'];
echo "</font>";
echo "<br>";
echo "Class: ";
echo "<font color=\"#b22222\">";
echo  $row['fclass'];
echo "</font>";
echo "<br>";
echo "Level: ";
echo "<font color=\"#b22222\">"; 
echo $row['levl'];
echo "</font>";
echo "<br>";
echo "Hit Points: ";
echo "<font color=\"#b22222\">";
echo  $row['hitp'];
echo "</font>";
echo "<br>";
echo "<img src=\"images/staff.gif\" align=\"center\">";
echo "<br>";
echo "</small>";
echo "<font color=\"#b22222\">Inventory</font><br>";
echo "<img src=\"images/staff.gif\" align=\"center\">";
echo "<br>";
echo "<small>";
echo "Armor: ";
echo "<font color=\"#b22222\">";
echo $row['armor'];
echo "</font>";
echo "<br>";
echo "Weapon: ";
echo "<font color=\"#b22222\">";
echo $row['weapon'];
echo "</font>";
echo  "<br>";
echo "Gold Onhand: ";
echo "<font color=\"#b22222\">"; 
echo $row['onhand'];
echo "</font>"; 
echo "<br>";
echo "Diamonds: ";
echo "<font color=\"#b22222\">";
echo $row['diamond'];
echo "</font>"; 
echo "<br>";
echo "Rubies: ";
echo "<font color=\"#b22222\">";
echo $row['rubie'];
echo "</font>";
echo "<br>";
echo "<img src=\"images/staff.gif\" align=\"center\"><br>";
echo "<a href=\"chat/cdchat.php#bottom\" target=\"_blank\">[ Crimson Chat ]</a><br>";
echo "</small>";
echo "</body>";
echo "</html>";
}
?>

 

 

Link to comment
Share on other sites

Okay -- try doing it like this...

 

<?php
session_start();
if (isset($_SESSION['uname'])) {
include ('config.php');
$uname = $_SESSION['uname'];
// Select data from database
$sql="SELECT * FROM $tbl_name WHERE uname='$uname'";
$result=mysql_query($sql);
// Put info into array Hopefully
$row=mysql_fetch_assoc($result);
echo "<html>";
echo "<head>";
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"gamestyle.css\" />";
echo "</head>";
echo "<body>";
echo "<center>";
echo $uname;
echo "<br>";
echo "<img src=\"images/Gallery/Elf.jpg\" align=\"center\">";
echo "</center>";
echo "<br>";
echo "<img src=\"images/staff.gif\" align=\"center\">";
echo "<br>";
echo "<font color=\"#b22222\">Character Info</font>";
echo "<br>";
echo "<img src=\"images/staff.gif\" align=\"center\">";
echo "<br>";
echo "<small>";
echo "Race: ";
echo "<font color=\"#b22222\">";
echo $row['race'];
echo "</font>";
echo "<br>";
echo "Class: ";
echo "<font color=\"#b22222\">";
echo  $row['fclass'];
echo "</font>";
echo "<br>";
echo "Level: ";
echo "<font color=\"#b22222\">"; 
echo $row['levl'];
echo "</font>";
echo "<br>";
echo "Hit Points: ";
echo "<font color=\"#b22222\">";
echo  $row['hitp'];
echo "</font>";
echo "<br>";
echo "<img src=\"images/staff.gif\" align=\"center\">";
echo "<br>";
echo "</small>";
echo "<font color=\"#b22222\">Inventory</font><br>";
echo "<img src=\"images/staff.gif\" align=\"center\">";
echo "<br>";
echo "<small>";
echo "Armor: ";
echo "<font color=\"#b22222\">";
echo $row['armor'];
echo "</font>";
echo "<br>";
echo "Weapon: ";
echo "<font color=\"#b22222\">";
echo $row['weapon'];
echo "</font>";
echo  "<br>";
echo "Gold Onhand: ";
echo "<font color=\"#b22222\">"; 
echo $row['onhand'];
echo "</font>"; 
echo "<br>";
echo "Diamonds: ";
echo "<font color=\"#b22222\">";
echo $row['diamond'];
echo "</font>"; 
echo "<br>";
echo "Rubies: ";
echo "<font color=\"#b22222\">";
echo $row['rubie'];
echo "</font>";
echo "<br>";
echo "<img src=\"images/staff.gif\" align=\"center\"><br>";
echo "<a href=\"chat/cdchat.php#bottom\" target=\"_blank\">[ Crimson Chat ]</a><br>";
echo "</small>";
echo "</body>";
echo "</html>";
}
?>

 

try doing that, might work...  Also you might take a look at the smarty templating engine (smarty.php.net) -- works great for complex programs...  i wrote a template engine similar to smarty for use on my site (im not using 1 piece of pre-written code)...

 

Smarty makes it so all your logic can be in 1 file,while all your html can be in different files...

Link to comment
Share on other sites

Ok just a blank page, well I used Smarty a little when I was working on a project for another person and was really just learning but I got sick and wasnt available for a few months so I never took it any further. Im just wondering why it woks on 1 server and not the other. I do use the CPED method Copy, Paste, Edit or Delete. Lol but I am learning as I go.

Link to comment
Share on other sites

I think i just found the error -- possibly....

 

or this could be coming from a different part of the frames...

 

$sql="SELECT * FROM $tbl_name WHERE uname='$uname'";

 

 

i doubt your table name is $tbl_name and no-where in this code do we have $tbl_name established.

 

unless thats in config, but i doubt it...

Link to comment
Share on other sites

Yeah It's in config but you know I have always had problems with e>novative>wamp I installed it cause it was quicker but what I need is some sort of wamp that is a little more flexible I think anyways??? And I would like to eventually write code from scratch myself any good or should I say great beginners sites or docs or tutes i could get pointed to would help as well!!

 

Thanks for all the help btw,

Link to comment
Share on other sites

I dunno only thing i could say it possibly try using xaamp instead -- ive never had any success with using wamp -- i use xaamp -- it runs mysql, apache, and you can choose either php4 or 5...

 

Well you are always welcome at my site (im in the process of programming it myself) -- its all about teaching people how to design graphics, and program and all that good stuff -- the url for it is cetutorials.com -- also try the tutorials on this site, they could come in handy -- though ive never read them i just know they are there...

 

also look into smarty some more -- because it really is a great template engine.

Link to comment
Share on other sites

Well I had problems all night with my system so I have a linux server up now just haven't tested it yet. The Way I see it most of the web is Apache nowadays (at least I think so) that this would be better. I got tired of messin with the windows and really the only reason I still am using windows is cause of games. Thanks for all the help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.