Pastebin works lots better when you're posting code: www.pastebin.com I don't see your database.php included in both of these modules. Wheredo you include it? EVert On Wed, Jun 18, 2008 at 9:38 PM, bateivan <ivanovivans@xxxxxxxx> wrote:>> Hello,>> To answer these qwestions:> 1. I am using "include" in my code.> 2. About the "$link = mysql_connect('localhost', 'root', 'testing');"> variable. I can just include this line before mysql_query function and it> works even without entering into mysql_query the "$link" variable. (Like the> connection is waking up).> 3.My php.ini register_globals is off as suggested for new versions of PHP> but include file should work instead according to the manual.> 4. I am posting some of my code to compare. Module "carmade.php" works v.s.> "login.php" which does not. Also, I am posting my "database.php" which is> establishing the connection and is included in every page through> "layout.php"->"common.php"->"database.php".>> carmade.php:> <?php> include $_SERVER['DOCUMENT_ROOT'].> '/layout.php';>> // Quick Login session check> login_check();>> switch($_REQUEST['req']){> // Insert Case> case "create_carmade":> myheader("Добавяне на автомобилни марки в списъка");>> // Double check form posted values are there> // before performing INSERT query> if(!$_POST['car_descr']){> echo '<p align="center">Липсва информациятя от формата!</p>'.> '<p align="center">Моля, използвайте бутона'.> 'Назад и въведете данните отново!</p>';> footer();> exit();> }>> // Insert Query> $sql = mysql_query("INSERT INTO carmade> (car_descr)> VALUES('{$_POST['car_descr']}')");>> // Insert query results> if(!$sql){> echo "Грешка при въвеждане на данните:".mysql_error();> } else {>> echo '<p align="center">Марката "'.$_POST['car_descr'].> '"е въведена<br/>с номер:'.mysql_insert_id();> echo '<br /> /admin/carmade.php?req=new_carmade Искате ли да'.> 'въведете друга марка? ';> }> break;>> // Create car made form case> case "new_carmade":> myheader("Въвеждане на нова автомобилна марка");> include $_SERVER['DOCUMENT_ROOT'].> '/html/forms/carmade_insert.html';> footer();> break;>> default:> myheader("Администриране на списъка с автомобилните марки");> include $_SERVER['DOCUMENT_ROOT'].> '/html/carmade_admin.html';> footer();> break;>> }> ?>>> login.php:> <?php> include $_SERVER['DOCUMENT_ROOT'].> '/layout.php';>>> switch($_REQUEST['req']){>> case "validate":>> $validate = mysql_query("SELECT * FROM members> WHERE username = '{$_POST['username']}'> AND password = md5('{$_POST['password']}')"> );>> $num_rows = mysql_num_rows($validate);>> if($num_rows == 1){> while($row = mysql_fetch_assoc($validate)){> $_SESSION['login'] = true;> $_SESSION['userid'] = $row['member_id'];> $_SESSION['first_name'] = $row['first_name'];> $_SESSION['last_name'] = $row['last_name'];> $_SESSION['email_address'] = $row['email_address'];>> if($row['admin_access'] == 1){> $_SESSION['admin_access'] = true;> }> $login_time = mysql_query("UPDATE members> SET last_login=now()> WHERE id='{$row['id']}'");> }> header("Location: /loggedin.php");> } else {> myheader("Входът в административната зона е неуспешен!");> echo '<p align="center">Входът в страницата не е успешен!</p>';> echo '<p align="center">Проверете потребителското си '.> 'име и паролата си и опитайте пак или се '.> 'обадете на администратора.</p>';> footer();> }> break;>> default:> myheader("Вход!");> include $_SERVER['DOCUMENT_ROOT'].> '/html/forms/login_form.html';> footer();> break;> }> ?>>> database.php:> <?php> $link = mysql_pconnect('localhost','root','testing');> $set = mysql_query('SET NAMES CP1251');> $set = mysql_query('SET_COLLATION=CP1251_GENERAL_CI');> mysql_select_db('samek_db', $link) or die(mysql_error());>> ?>>> common.php:> <?php>> // Include Meta Content Class> include $_SERVER['DOCUMENT_ROOT'].'/classes/clsMetaContent.php';>> // Include Email Class> include $_SERVER['DOCUMENT_ROOT'].'/classes/clsEmail.php';>> // Include Database Connection File> include $_SERVER['DOCUMENT_ROOT'].'/includes/database.php';>> // Include Session File> include $_SERVER['DOCUMENT_ROOT'].'/includes/session.php';>> ?>>> Thank you for your help>>> You're very welcome, I understand that you need a solution which allows you> to keep using the connection this way.>> I doubt that your php.ini is the cause so I'll suggest the following:>> Try executing your MySQL queries by passing the $link variable to the> function as the connection resource:>> mysql_query("SELECT...", $link);>> Something that also might cause it is that you use (include|require)_once> and that this module doesn't have access to the connection resource, if this> is the case change it into include|require and see if that solves your> issue. If not then could you please post some example code of your module if> possible so we can be more helpful?>> Also be sure that you global $link; it in functions (I don't know if this> required since I didn't use it this way for a long while).>> Could you also please answer to the list instead of directly to me as this> might also be informative for others.>> --> View this message in context: http://www.nabble.com/PHP-MySQL-connection-for-particular-module-tp17915108p17990192.html> Sent from the Php - Database mailing list archive at Nabble.com.>>> --> PHP Database Mailing List (http://www.php.net/)> To unsubscribe, visit: http://www.php.net/unsub.php>>