Page 1 of 1

can u create a RecordSet in a function??

Posted: Thu Jun 15, 2006 5:01 am
by bennythemink
hi guys,

im using php and mysql.

Ive a function that creates a table displaying the data from a passed RecordSet(RS). one of the columns in the table needs to be populated by creating a new second RS which uses data from the first RS in its WHERE clause.

when i try to create this second RS i get an error saying that the database connection string is invalid?! i am positive that the connection string is valid as its used in other parts of the page's script. :(

This reason for this error seems to be my trying to create the RS in a function?!! can anyone give me some advice on this please? can u create an RS in a function?


many thanks for any help :wink:


the error is:
Notice: Undefined variable: database_database_connection in somepage.php on line 428

Posted: Thu Jun 15, 2006 5:22 am
by lettie
Show me the code.

code included

Posted: Thu Jun 15, 2006 5:29 am
by bennythemink
Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


hey Lettie,

cant show u the full thing cos its actually a huge form, but the important part is below. thanks for any advice

Code: Select all

function createForm($rs1,$row_rs1, ..... $rs9,$row_rs9)
{
......
......

                <td>
               <?php if($row_rs9['Region'] != null)
		{echo $row_rs9['Region'];} else {echo "Not Specified";};?></td>
	<td>
	<?php 

	$currRes = $row_res9['RESID'];
	
                /* This is the part its throwing an error at!!! */
	mysql_select_db($database_database_connection, $database_connection);
	$query_selectedResRS = "SELECT * FROM resolution_table WHERE ID = '$currRes'";
	$selectedResRS = mysql_query($query_selectedResRS, $database_connection) or die(mysql_error());
	$row_selectedResRS = mysql_fetch_assoc($selectedResRS);
		
	$ans = $row_selectedResRS['resX'] . " x " . $row_selectedResRS['resY'];
		
	?>
                </td>

Pimptastic | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Jun 15, 2006 6:19 am
by bennythemink
its ok, got it working, im feckin stupid :D all i needed to do was to pass a reference to the connection variables to the function! i cant believe i didnt think of that sooner! sorry to waste every1s time!