Another error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mattmcb
Forum Commoner
Posts: 27
Joined: Sun Jan 25, 2004 3:34 pm

Another error

Post by mattmcb »

Can anyone help with this one?
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in c:\program files\apache group\apache\storegroup\sg_forum\joint_venture_admin.php on line 36

Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in c:\program files\apache group\apache\storegroup\sg_forum\joint_venture_admin.php on line 36
Query failed:

Code: Select all

$linkid = @mysql_connect('localhost', 'seekide_si', '*password is correct*');
mysql_select_db('seekide_sgforum', $linkid);

define('IN_PHPBB', true);
$phpbb_root_path = './';
include($phpbb_root_path . 'extension.inc');
include($phpbb_root_path . 'common.'.$phpEx);

$userdata = session_pagestart($user_ip, PAGE_INDEX);
init_userprefs($userdata);

include($phpbb_root_path . 'includes/page_header.'.$phpEx);

if (!isset($mode)) $mode = '';
$mode = $_GET['mode'];
echo $mode;
/* MODES:	create | edit | view | approve | print |Send */

// MODE: CREATE
//function create_contract()
//{
	// Redirect to contract, CREATE MODE
	//redirect("joint_venture_contract.php?mode=create");
//}

// MODE: EDIT
function edit_contract() {
// now to output the form HTML.
// Redirect to contract, CREATE MODE
	$user_id = $userdata['user_id'];
	$sql1 = 'SELECT `contract_id` , `user_id_1` , `user_id_2` , `user_id_3` , `user_id_4` , `venture_id` , `vdesc` , `status` , `post_date` '
        . ' FROM `venture_contract` '
        . ' WHERE user_id_1 = '.$user_id.' OR user_id_2 = '.$user_id.' OR user_id_3 = '.$user_id.' OR user_id_4 = '.$user_id.' ORDER BY post_date DESC'; 
***LINE 36***	$result1 = mysql_query($sql1, $linkid) or die("Query failed: " . mysql_error($linkid));

	if(mysql_num_rows($result1) == 0){ 
   		echo("<br><center><span class='genmed'><font size='2' color='red'><b>You have NO Venture Contracts Created.</b></font></span></center>"); 
	}else{ 
        echo ("<br><table width='95%' cellpadding='2' cellspacing='1' border='0' class='forumline' align='center'><tr><th class='catleft' colspan='2' height='22' align='left'><img src='templates/phpib2/images/nav.gif'><span class='thCornerL'> EDIT CONTRACT MODE: Select a Venture Contract to EDIT</a></span></th></tr>
				<tr>
   					<td class='row1'>
					<span class='genmed'>");
	}

	// Display results for edit mode
	while ($row1 = mysql_fetch_array($result1))
	{    
		echo ("<br><a href='http://www.storegroup.org/sg_forum/joint_venture_contract.php?mode=edit&user_id=".$user_id."&contract_id=".$row1['contract_id']."'>EDIT</a> Venture Type: ".$row1['venture_id']." Post Date:".$row1['post_date']." Contract Status: ".$row1['status']."<br>Venture Description: ".$row1['vdesc']."<br>Contract Participants: ");
		
		// Get usernames of contract participants
		$sql2 = 'SELECT username'
        . ' FROM sgforum_users'
        . ' WHERE user_id'
        . ' IN ( '.$row1['user_id_1'].', '.$row1['user_id_2'].', '.$row1['user_id_3'].', '.$row1['user_id_4'].' ) LIMIT 0, 30';
		$result2 = mysql_query($sql2, $linkid) or die("Query failed: " . mysql_error($linkid));
		while ($row2 = mysql_fetch_array($result2)) {
			echo ($row2['username'].", ");
		}
			echo ("<br><br>");
	}
			echo ("</span></td></tr></table>");
}
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Do the 3 things mentioned here first then let us know the outcome ;)
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

try leaving out $linkid out of those two functions.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Its an error in the sql, put it all on one line and then see. You can seperate it to more than one line when it works.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Testing marks theory.
Post Reply