•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 426,451 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,359 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1119 | Replies: 1
![]() |
•
•
Join Date: Jun 2005
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
I have a problem on mysql_query on using 2 dbs on 1 mysql server.
Please help, and code is;;
<?
$db1[host] = "localhost";
$db1[user] = "abc";
$db1[pass] = "1234";
$db1[db] = "db1";
$db1[dir] = "a/ab";
$db2[host] = "localhost";
$db2[user] = "abc";
$db2[pass] = "1234";
$db2[db] = "db2";
$db2[dir] = "a/cd";
$db[link] = @mysql_connect($db1[host], $db1[user], $db1[pass]) or die("host, user, pass .");
?>
<HTML>
<HEAD>
<TITLE>test</TITLE>
<script>
function in_check() {
if (form1.delete_chk.checked) form1.delete_flg.value=1 ;
if(!document.form1.my_id.value) {
alert("INPUT THE apps ID !!!");
document.form1.my_id.focus();
return false;
}
if(!document.form1.my_id.value) {
alert("INPUT THE myapps ID !!!");
document.form1.my_id.focus();
return false;
}
return true;
}
</script>
</HEAD>
<BODY>
<table align= center border=0 width=500 cellspacing=0 cellpadding=0 >
<form name=form1 action="my2db2.php" method="post" onsubmit="return in_check();">
<tr>
<td align=center><span style="font:32 impact; color:#CDB8CD" >Return</span><br><br></td>
</tr>
<tr>
<td>
<table width=100% >
<tr>
<td align=left>my apps</td>
<td align=left>db2 apps</td>
<td></td>
</tr>
<tr>
<!--<td><input type=text name=my_id style="width:100%;"></td>-->
<td align=left>
<select name="my_id" >
<?
// $db1[dataz]='SELECT no,name FROM control_table order by no';
// $result_db1=mysql_query($db1[dataz]);
$result_db1 = mysql_result(mysql_query("SELECT no,name FROM db1.control_table WHERE 1 LIMIT 1"), 0, 0); // databaseA.tableA.fieldA SELECT!
while($data=mysql_fetch_array($result_db1)) {
?>
<option value=<?=$data[name]?> > <?=$data[name]?> </option>";
<?
}
?>
</select>
</td>
<td align=left>
<select name="my_id" >
<?
$db2[dataz]='select rpt_num,rpt_id,rpt_name from gb_apps order by rpt_num';
$result_db2=mysql_query($db2[dataz]);
while($data=mysql_fetch_array($result_db2)) {
?>
<option value=<?=$data[rpt_id]?> ><?=$data[rpt_name]?> </option>";
<?
}
?>
</select>
</td>
I could not see any datas.
Please help, and code is;;
<?
$db1[host] = "localhost";
$db1[user] = "abc";
$db1[pass] = "1234";
$db1[db] = "db1";
$db1[dir] = "a/ab";
$db2[host] = "localhost";
$db2[user] = "abc";
$db2[pass] = "1234";
$db2[db] = "db2";
$db2[dir] = "a/cd";
$db[link] = @mysql_connect($db1[host], $db1[user], $db1[pass]) or die("host, user, pass .");
?>
<HTML>
<HEAD>
<TITLE>test</TITLE>
<script>
function in_check() {
if (form1.delete_chk.checked) form1.delete_flg.value=1 ;
if(!document.form1.my_id.value) {
alert("INPUT THE apps ID !!!");
document.form1.my_id.focus();
return false;
}
if(!document.form1.my_id.value) {
alert("INPUT THE myapps ID !!!");
document.form1.my_id.focus();
return false;
}
return true;
}
</script>
</HEAD>
<BODY>
<table align= center border=0 width=500 cellspacing=0 cellpadding=0 >
<form name=form1 action="my2db2.php" method="post" onsubmit="return in_check();">
<tr>
<td align=center><span style="font:32 impact; color:#CDB8CD" >Return</span><br><br></td>
</tr>
<tr>
<td>
<table width=100% >
<tr>
<td align=left>my apps</td>
<td align=left>db2 apps</td>
<td></td>
</tr>
<tr>
<!--<td><input type=text name=my_id style="width:100%;"></td>-->
<td align=left>
<select name="my_id" >
<?
// $db1[dataz]='SELECT no,name FROM control_table order by no';
// $result_db1=mysql_query($db1[dataz]);
$result_db1 = mysql_result(mysql_query("SELECT no,name FROM db1.control_table WHERE 1 LIMIT 1"), 0, 0); // databaseA.tableA.fieldA SELECT!
while($data=mysql_fetch_array($result_db1)) {
?>
<option value=<?=$data[name]?> > <?=$data[name]?> </option>";
<?
}
?>
</select>
</td>
<td align=left>
<select name="my_id" >
<?
$db2[dataz]='select rpt_num,rpt_id,rpt_name from gb_apps order by rpt_num';
$result_db2=mysql_query($db2[dataz]);
while($data=mysql_fetch_array($result_db2)) {
?>
<option value=<?=$data[rpt_id]?> ><?=$data[rpt_name]?> </option>";
<?
}
?>
</select>
</td>
I could not see any datas.
•
•
Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 344
Reputation:
Rep Power: 4
Solved Threads: 4
Please read and follow Paradox814's post at this thread:
http://www.daniweb.com/techtalkforums/thread25821.html
It will show you some basics of running mysql queries in PHP along with how to read the mysql errors. Use the techniques shown to modify how you run your queries. Create a page that only has the problem--nothing else. Keep the chunk you are working on as small as possible. When you get it working, add one step to it, and test again.
If you run into one step that you can't get working, then post here with just enough information to make your question clear. Most people answering posts don't have time to read entire code modules and debug for you.
Enjoy the journey. [img]dani-images/smilies/fiyellow/icon_smile.gif[/img]
http://www.daniweb.com/techtalkforums/thread25821.html
It will show you some basics of running mysql queries in PHP along with how to read the mysql errors. Use the techniques shown to modify how you run your queries. Create a page that only has the problem--nothing else. Keep the chunk you are working on as small as possible. When you get it working, add one step to it, and test again.
If you run into one step that you can't get working, then post here with just enough information to make your question clear. Most people answering posts don't have time to read entire code modules and debug for you.
Enjoy the journey. [img]dani-images/smilies/fiyellow/icon_smile.gif[/img]
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- PHP, ASP, ColdFusion, what's your fav? (IT Technologies and Trends)
- ODBC setup with Online Access DB (MS Access and FileMaker Pro)
- Seeking Experienced, Creative Graphic Web Designer (Web Development Job Offers)
- MS Access Beginner (MS SQL)
- User Authorization (Java)
- PHP & File Extensions (PHP)
- SAP DB - The FREE Enterprise Open Source Database (Oracle)
- MySQL-Front - Graphical Interface for MySQL (MySQL)
Other Threads in the PHP Forum
- Previous Thread: Apache2 displaying PHP5 source code
- Next Thread: Php newsletter error


Linear Mode