Jump to content

in php, retrieving value from db(mysql) and passing it to other pages


bluestar

Recommended Posts

i am making a website and some part of which is to show user information...for this i had make a class and functions within it...one of the function is for retrieving values from database(im using mysql)...i know a variable is limited only in function,also tried $_session for this too..the function works fine ....but it is not sendind the information to the page from where im calling it...here is my code.....

 

 

in xyz.php file

 

<?php

class book{

 

public $v1;

public $v2;

public $v3;

 

  function book(){

 

  }

 

function page1(){

 

    $this->con=mysql_connect("localhost","root","usa");

$this->db=mysql_select_db("truth",$this->con);

   

  }

 

  function page2($xyz){

  $this->page1();

    $query="SELECT * FROM member_signup WHERE Uid=$xyz";

    $result=mysql_query($query,$this->con);

$result1=mysql_fetch_array($result);

$_SESSION['info']=$result1;

return $_SESSION['info'];

return $result1;

  }

}?>

 

in show.php file

 

<?

require_once("xyz.php");

 

$pen = new book;

 

if($pen->page2(100011))

{ session_start();

if (mysql_error())

    { print "Database ERROR: " . mysql_error(); }

else{

echo "cows";

 

  echo "<br>cows<br>";

  echo "my name is'".$_SESSION['info']."'";

  echo "my name is'".$_SESSION['FIRST_NAME']."'";  //i have a fied is db named FIRST_NAME

 

 

}

}

else{echo "happy";}

 

?>

Link to comment
Share on other sites

As a die not Object oriented PHP is very bad for app performance and memory. Its only positive aspect is team readability and maintenance. I would suggest making your code more static. If your calling the data from a previous page consider a form to post data to the next page or storing info in cookies or sessions. Also make sure you don't have any headers in the way so that the cookie/session can be created, and make sure they are secure.

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.