开发者

Session and login phpmysql help

开发者 https://www.devze.com 2023-03-18 08:27 出处:网络
hello can you please tell what is wrong with my code.I dont know what is wrong with my code its showing no error and no result.I have created two tables in my databas(mysql) one database is used for u

hello can you please tell what is wrong with my code.I dont know what is wrong with my code its showing no error and no result.I have created two tables in my databas(mysql) one database is used for usersdetails and the other is used to save the comments and file of the users.

<?php

 session_start();

 $firstname= $_SESSION['SESS_FIRST_NAME'];
  print $firstname;
 $tes=$_SESSION['SESS_MEMBER_ID'];
 print $tes;

 ?>




<?php
 // Default page display
// Connect to the database server
  $dbcnx = @mysql_connect('localh开发者_Python百科ost', 'root', '');
  if (!$dbcnx) {
  die( '<p>Unable to connect to the ' .
  'database server at this time.</p>' );
  }
 // Select the jokes database
 if(! @mysql_select_db('tes') ) {
die( '<p>Unable to locate the joke ' .
'database at this time.</p>' );
 }
// If a joke has been submitted,
// add it to the database.
if (isset($_POST['submit'])) {

$name = $_POST['name'];
$test = $_POST['test'];
$sql = "INSERT INTO details SET
userid='$tes',
name='$name',
test='$test',
date=CURDATE()";
if (@mysql_query($sql)) {
echo('<p>Your joke has been added.</p>');
} else {
 echo('<p>Error adding submitted joke: ' .
 mysql_error() . '</p>');
}
}

 echo('<p> Here are all the jokes in our database: </p>');
 // Request the text of all the jokes
 $result = @mysql_query('SELECT * FROM details where userid="1"');

 if (!$result) {
 die('<p>Error performing query: ' .mysql_error() . '</p>');
   }

 // Display the text of each joke in a paragraph
 while ( $row = mysql_fetch_array($result) ) {

echo('<p><big style="color: rgb(204, 0, 0);">' . $row['name'] . '&nbsp;&nbsp;</big>      <p>');
echo('<div style="text-align: justify;">' . $row['test'] . '&nbsp;&nbsp;</div>');
echo('<p><span style="font-style: italic;">' . $row['date'] . '&nbsp;&nbsp;</span>');


}
 // When clicked, this link will load this page
// with the joke submission form displayed.

?>


Try removing the error control operator, the at sign (@), from the beginning of the database-related functions you are using it with. That suppresses errors from those functions. Also, do you have error reporting on?

ini_set('display_errors',1);
error_reporting(E_ALL);

Are you seeing any text on the page at all? Such as "Here are all the jokes in our database:"

I also see you are using mysql_fetch_array() when you are referring to the $row['name'], $row['test'] as if you were using mysql_fetch_assoc()

0

精彩评论

暂无评论...
验证码 换一张
取 消