|
-
Reef Shark
PHP require function
Does this work? Even with database connections?
Code:
require("../file.php");
~ And that is my humble opinion.
When I was a boy I was told that anybody could become President. Now I'm beginning to believe it. - Clarence Darrow
The greatness of a woman’s power is measured in the size and amount of the balls she clutches in hand. -Nephalim
"Tink"
1700+ XP on A7N8X, 768MB PC2700 DDRRAM, Samsung 19" 900IFT, Radeon 64MB DDR VIVO, SB Live! MP3+, 42.9GB IBM HDD, Plexwriter 8/4/32, 3C905CTXM NIC
"Hermes"
Dell Inspiron 8200, 1.7 GHz P4, 512MB DDRRAM, 30GB HDD, DVDROM, Geforce4 Go 64MB
-
Hammerhead Shark
You mean if the required script is accessing a database?
Yes. I made a second script and require the one I posted in your other thread there:
PHP Code:
<?php
require('dbtest.php');
?>
And it gave me identical results.
Require is just like and include, it will act as if the included file is part of the existing script. The only difference from an include is that it will give a fatal error instead of a warning on an error.
-
Reef Shark
Hum... note that the require uses a relative url syntax. I'm not getting any errors, but i'm also not retrieving any data.
-
Ursus Arctos Moderatis
Relative url syntax works fine w/ require. How are you "not retrieving any data"? Some more details might help us diagnose your problem.
-
Reef Shark
I'm working on an admin page that has lists of most of my tables, etc. and with each table, I have put a form for adding a post to each table. Those queries work. However, I've also added queries that would pull all the records from my old database and update them to the new database. These queries do not work, even though i have triple checked the syntax (not necessarily 100% foolproof, but ya know). I seem to get an error that the fields in the second database and table could not be found. Could it be that since the tables are named the same that MySQL is confused and I somehow need to specify which database in the query, not just the database connection?
-
Hammerhead Shark
No, you woudn't specify the database in the query. Nor the connection. You specify the database with the mysql_select_db function.
Maybe if you posted the code that is giving you a hard time it would be a little easier to help you.
Again, whether you are using two DB connections or one, you need to select the current database with mysql_select_db directly prior to the query.
-
Reef Shark
Hmmmm... I was using a function that created a connection and automatically selected the database per the connection. I'll tinker...
Not sure how we ended up over here...
Last edited by Nephalim; 02-14-2003 at 11:51 PM.
-
Reef Shark
CODE:
Code:
if(!$old_result = mysql_query("SELECT * FROM table",database_connection("localhost","php","php","old_db")))
{
error_message("Check old database names.\n");
exit();
}
while($old_record = mysql_fetch_object($old_result))
{
if(!mysql_query("INSERT record(fields...) VALUES('$old_fields')",$database_link))
{
error_message("Check new database names.\n");
exit();
}
}
Last edited by Nephalim; 02-15-2003 at 12:01 AM.
-
Reef Shark
Crushing Success (all around) by not using my function and actively using the select_db function.
MUCH THANKS TO YOU BOTH!
I've been coding all day [this is your brain on PHP].
Last edited by Nephalim; 02-15-2003 at 12:08 AM.
-
Hammerhead Shark
Nice, glad to hear you got it working
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|