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
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?

Link to comment
Share on other sites

// 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;

}

 

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.