| View previous topic :: View next topic |
| Author |
Message |
James0816
Joined: 20 May 2004 Posts: 12
|
Posted: Thu May 20, 2004 5:31 pm Post subject: Pass a variable between pages |
|
|
I'm new to PHP and learning quickly (I guess) :D
Question.....How do I pass a variable from one page to the next? |
|
| Back to top |
|
 |
berber Site Admin
Joined: 29 Apr 2004 Posts: 383
|
Posted: Thu May 20, 2004 6:20 pm Post subject: |
|
|
That depends on how you pass from one page to the other.
Are you using a FORM or a link to pass between the pages? |
|
| Back to top |
|
 |
James0816
Joined: 20 May 2004 Posts: 12
|
Posted: Thu May 20, 2004 6:41 pm Post subject: |
|
|
| I am currently using a link. Which leads me to my next issue. The page I was using uses frames and I would need to be able to pass that value into the other frame. |
|
| Back to top |
|
 |
berber Site Admin
Joined: 29 Apr 2004 Posts: 383
|
Posted: Thu May 20, 2004 6:45 pm Post subject: |
|
|
If you want my advice, try to avoide frames.
They are good in some cases but ususlly very bad for most.
Is the link to the next page constant or dynamic?
you should do something like :
[code:1]
<A HREF="http://www.mydomain.com/mypage.php?var1=1&var2=3">Next Page</A>
[/code:1]
This will navigate to the next page in the current frame.
If you need to navigate to a diffrent frame named "OtherFrameName" try :
[code:1]
<A HREF="http://www.mydomain.com/mypage.php?var1=1&var2=3" TARGET="OtherFrameName">Next Page</A>
[/code:1]
if the links are dynamic you just build them in your PHP code. |
|
| Back to top |
|
 |
James0816
Joined: 20 May 2004 Posts: 12
|
Posted: Thu May 20, 2004 7:14 pm Post subject: |
|
|
thx.....down to just using one page. getting the variable to pass now (on the same page at least). Now if you don't mind. let me throw a monkey wrench into the equasion.
I have to data sources. The first is used to pull the item list. This one is working correctly. The second should be a result set of the value that is placed in the variable from a choice in the first. Then display records accordingly. Not working.
my link is defined like this:
PHPTest5.php?name=<?php echo $ItemList->Value("itemname") ?>
my second data source is defined as this:
$ItemInfo = WrapMySQLDatabaseResults("ItemDB", "select * from iteminfo where itemname = " . pageParameter("name"," -1") . "", "block=1","ItemInfo");
I'm getting an error returned. I'm obviously missing something right? |
|
| Back to top |
|
 |
berber Site Admin
Joined: 29 Apr 2004 Posts: 383
|
Posted: Thu May 20, 2004 8:34 pm Post subject: |
|
|
| What is the error you are getting? |
|
| Back to top |
|
 |
James0816
Joined: 20 May 2004 Posts: 12
|
Posted: Thu May 20, 2004 8:39 pm Post subject: |
|
|
Fatal error: Call to a member function on a non-object in E:\Birchwood folder\Birchwood\PHPTest5.php on line 128
128 - <?php $ItemInfo->MoveFirst(); ?>
129 - <?php $ItemInfo->Move($ItemInfo->FirstRecordOnPage() - 1); ?>
130 - <?php while (!$ItemInfo->EOF() && !$ItemInfo->EOB()) { ?> |
|
| Back to top |
|
 |
berber Site Admin
Joined: 29 Apr 2004 Posts: 383
|
Posted: Thu May 20, 2004 9:02 pm Post subject: |
|
|
I'm not familiar with your DB wrapper, this is something you will need to solve on your own.
how about connecting directly to you DB?
[code:1]
<?
mysql_connect("localhost","user","pass") or die("Unable to connect to SQL server");
mysql_select_db("MyDB") or dir("Unable to select database");
$result=mysql_query("SELECT FieldName FROM MyTable") or die(mysql_error());
While($row = mysql_fetch_object($result)) {
Echo $row->FieldName;
}
?>
[/code:1] |
|
| Back to top |
|
 |
James0816
Joined: 20 May 2004 Posts: 12
|
Posted: Thu May 20, 2004 9:19 pm Post subject: |
|
|
| ummm....not familiar with what you are calling DB wrapper? I'm using Adobe GoLive to lay out my pages and PHP to code. MYSql is the DB. Is there another way I should be doing this? Still learning so any and help is greatly appreciated. |
|
| Back to top |
|
 |
berber Site Admin
Joined: 29 Apr 2004 Posts: 383
|
Posted: Thu May 20, 2004 9:21 pm Post subject: |
|
|
for starters, you can try to see if using my code works for you to access the DB. once you can query the DB you can get info and update info as you like.
Make sure you change the parameters in my code to fit your system. |
|
| Back to top |
|
 |
|