PHP Question

C++, C#, Java, PHP, ect...
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: PHP Question

Post by hallsofvallhalla »

yes add in a or die so you can see what is failing. I have a feeling its the DB. What is the data type for the lastlogin field? PHP might be out putting a string not capable of you current datatype.

add

Code: Select all

echo $datetime;
what does it look like?
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: PHP Question

Post by SpiritWebb »

Ok, I placed the or die and when i click logout, this is what I get:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) in C:\wamp\www\Mythuto\logout.php on line 19
Included is a screenshot of players in phpMyAdmin
Image

Image
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: PHP Question

Post by hallsofvallhalla »

change it to

Code: Select all

$result=mysql_query($SQL)or die("it crapped out");  
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: PHP Question

Post by SpiritWebb »

hallsofvallhalla wrote:change it to

Code: Select all

$result=mysql_query($SQL)or die("it crapped out");  
I tried the:

Code: Select all

$result=mysql_query($SQL)or die("MySql Error");
I get the same thing...(wamp is running, everything works, up until I click logout, now cause of the "or die" placed.)
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\Mythuto\logout.php on line 19
it crapped ou
Image

Image
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: PHP Question

Post by Torniquet »

are you including the connect.php script that connects to your DB? i cant see it on your script you put up.
New Site Coming Soon! Stay tuned :D
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: PHP Question

Post by SpiritWebb »

Here is the entire code:

Code: Select all

<link href="style.css" rel="stylesheet" type="text/css" />
<STYLE type="text/css">
 <!--
 BODY { background-image:url(logoutFinish.png);
               background-repeat:no-repeat;
               background-position:center;
               background-attachment:fixed }
 -->
</STYLE>

<body bgcolor="black">
<body text="white">
<div id="return">
 <?php
    session_start();
    $datetime=date("d/m/y h:i:s"); //create date time

$sql="INSERT INTO players (lastlogin)VALUES('$datetime')";
$result=mysql_query($sql) or die("MySql Error");



    session_destroy();

    
       ?>


    </div>
I didnt change nothing with the code that halls provided with the tutorial. Except add the code in between session_start() and session_destroy(). I added the include_once 'connect.php'; command, and now I just get MySql Error
Image

Image
User avatar
hallsofvallhalla
Site Admin
Posts: 12023
Joined: Wed Apr 22, 2009 11:29 pm

Re: PHP Question

Post by hallsofvallhalla »

whats the mysql error?
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: PHP Question

Post by SpiritWebb »

hallsofvallhalla wrote:whats the mysql error?
where u put "it crapped out" I changed it too "MySql Error"
Image

Image
User avatar
Torniquet
Posts: 869
Joined: Sun Aug 02, 2009 6:18 am

Re: PHP Question

Post by Torniquet »

im pretty sure you need to have the include in there lol. as its trying to access a DB. in halls tut as far as i can remember he is not accessing any DBs.

stick the include in and see if it works :p
New Site Coming Soon! Stay tuned :D
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: PHP Question

Post by SpiritWebb »

Torniquet wrote:im pretty sure you need to have the include in there lol. as its trying to access a DB. in halls tut as far as i can remember he is not accessing any DBs.

stick the include in and see if it works :p
i did place the include_once, its in the above code, and it still doesnt work.
Image

Image
Post Reply

Return to “Coding”