Jump to content

sessions - point out the error please?


Recommended Posts

hello guys..i wrote this code!!

and..... its not working!!  :(

 

<?php

session_register('db_name');

?>

 

 

<?php

 

if(isset($_POST['posted']))

{

$db_name1=$_SESSION['db_name'];--------->error in here??

$link_id=mysql_connect("localhost",root,"");

$result=mysql_query("create database $db_name1");

echo"result is ".$result;--------->checking to see if its working

}

 

else

{

echo"enter database name:

<form method=post action=database.php>

<input type=text name=db_name>

<input type=submit value=submit>

<input type=hidden name=posted>

";

}

 

?>

 

cud neone find whats d prob?

i think the value of database name entered by the user is not getting into db_name1!!

thank u..

Link to comment
https://forums.phpfreaks.com/topic/61970-sessions-point-out-the-error-please/
Share on other sites

hey mmarif..

thanks 4 the response!.... :)

what u said is true...

but..sessions used for storing data in d server side persistently?

and we can access it anytime from the global aarray $_SESSION ?

 

if not, then whats d purpose of sessions?  :-\

 

please

explain?

 

 

hi

jithesh..

i havent used  session_start,  because  its  said  its  not  mandatory, and if we use session_register, a SID will be automatically assigned..

and well...i havent initialised its value!...

is that a problem?

// Check you have Privilege to create database

<?php

session_start();

 

if(isset($_POST['posted']))

{

if(isset($_SESSION['db_name']) and !empty($_SESSION['db_name'])){

            $db_name1=$_SESSION['db_name'];

}else{

        echo "Database name not found ";

        exit;

}

$link_id=mysql_connect("localhost",root,"");

$result=mysql_query("create database $db_name1");

echo"result is ".$result;

}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.