rakesh.ravindran Posted July 27, 2007 Share Posted July 27, 2007 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 More sharing options...
mmarif4u Posted July 27, 2007 Share Posted July 27, 2007 Bcoz the value is coming from post in ur form not from session: $db_name1=$_SESSION['db_name'];--------->Worng Try it like this: $db_name1=$_POST['db_name']; Link to comment https://forums.phpfreaks.com/topic/61970-sessions-point-out-the-error-please/#findComment-308586 Share on other sites More sharing options...
jitesh Posted July 27, 2007 Share Posted July 27, 2007 Can you show us where have you mention session_start(); and where value for session var "db_name" is set? Link to comment https://forums.phpfreaks.com/topic/61970-sessions-point-out-the-error-please/#findComment-308589 Share on other sites More sharing options...
rakesh.ravindran Posted July 27, 2007 Author Share Posted July 27, 2007 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 https://forums.phpfreaks.com/topic/61970-sessions-point-out-the-error-please/#findComment-308594 Share on other sites More sharing options...
rakesh.ravindran Posted July 27, 2007 Author Share Posted July 27, 2007 guyyss please help me out? Link to comment https://forums.phpfreaks.com/topic/61970-sessions-point-out-the-error-please/#findComment-308615 Share on other sites More sharing options...
jitesh Posted July 27, 2007 Share Posted July 27, 2007 // 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 https://forums.phpfreaks.com/topic/61970-sessions-point-out-the-error-please/#findComment-308617 Share on other sites More sharing options...
rakesh.ravindran Posted July 27, 2007 Author Share Posted July 27, 2007 guys...thanx 4 d responses.....but it doesnt seems to b working... cud u guys tell me if my logic is correct or not?... Link to comment https://forums.phpfreaks.com/topic/61970-sessions-point-out-the-error-please/#findComment-308979 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.