PHP - Different Databases Or Tables To Make "servers" In A Web Based Game
I'm working on a web based RPG game, and I want the ability to run different "servers" but I'm not sure what the best way to go about it would be.
First idea: Create a table which would be named, "world" when a character is created, they get to choose a world to join, and then use world_id to know what items, mobs, npc, is in that world. Here is just a quick mock-up of the table.
Second idea: Create a whole new database for the game data, creature_game contains the accounts and forum data. While creature_server_x contains the rest of the game. The structure of each database would be exactly the same.
I want the people that runs the different "servers" to be able to do whatever changes they want, even if that would mean to rewrite the story line. I could do it with both the first and second idea. But I want to hear about what people here think is best and why. Ofc, they won't be able to access or change the tables inside the databases, just the data the tables contains.
Similar TutorialsHello, I am building an online game(users make a character and move on a map and so on...)
All user data is stored in a mySQL database and I want the users to interact in real-time, but there can be a 1-3 second delay between the communication, but not exceed 3 seconds even if 500 players are playing at the same time.
But for the purpose of the question let's say the users can only chat between one another, if I'll have a solution for that then I can use the same method for more parts of the game.
I can't use websockets because my webhost doesn't support it( I don't want to use pusher.com).
I know I can make real-time apps with ajax long polling, but I think that with 500 players playing at the same time it's not the best solution.
So, finally:
How can I make user interaction as close as possible to a real-time game?
(Without too much load on the hosting server)
(I am sorry if some of my terms are not correct - I am just getting back to coding after a long time...)
Edited by Mythion, 17 August 2014 - 02:34 AM. Hi! I have two similar tables on two different databases and i need to check if there are any entries on the table1, for example, that there aren't on the second table and print if there are i need to print them. Any suggestions? Thank you... Hi, I am using the following PHP email code, and when I send it to my Gmail account it works fine, but some servers are blocking this email and are not being received. How can I tweak it to make it more compatible? Code: [Select] $headers = "From: $row_o_email[email] \r\n"; $headers .= "BCC: $row_o_email[email] \r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $to = $row_e['email']; mail($to, "subject", " email body ", $headers); I have a little experience in coding php and am wanting to code a browser-based RPG. (One of the click the link games). I know how to code the login, registration, player list, lost password, etc., but I have no idea where to start with coding the attack, throwing in random chance, strength, agility and so forth; stores, items, money, and so on and so on. Can someone help me? This portion is kind of stumping me. Basically, I have a two tables in this DB: users and users_access_level (Separated for DB normalization) users: id / username / password / realname / access_level users_access_level: access_level / access_name What I'm trying to do, is echo the data onto an HTML table that displays users.username in one table data and then uses the users.access_level to find users_access_level.access_name and echo into the following table data, I would prefer not to use multiple queries if possible or nested queries. Example row for users: 1234 / tmac / password / tmac / 99 Example row for users_access_level: 99 / Admin Using the examples above, I would want the output to appear as such: Username: Access Name: Tmac Admin I am not 100% sure where to start with this, but I pick up quickly, I just need a nudge in the right direction. The code I attempted to create just shows my lack of knowledge of joining tables, but I'll post it if you want to see that I did at least make an effort to code this myself. Thanks for reading! Hi folks, If thought i finally managed to make a 2 player game with PHP and Jquery but i my whole computer gets stucked when the first player has gets his 2nd turn. What i basically have are 2 .txt files where both players units are listed. I will read this file into an array. Each unit has a speed key wich value increases when that unit has made an action, i write the new speed to the file and the script runs again. Heres the script that decides which unit goes first. Code: [Select] $time = 0; $found = 0; while ($found != 1) { foreach ($P1recruit as $p1) { if ($found == 1) break; if ($p1['speed']<$time) { $p1['speed'] = $p1['speed'] * ceil ($time / $p1['speed']); } elseif ($p1['speed']==$time) { $p1turn = true; $p2turn = false; $found ++; } } foreach ($P2recruit as $p2) { if ($found == 1) break; if ($p2['speed']<$time) { $p2['speed'] = $p2['speed'] * ceil ($time / $p2['speed']); } elseif ($p2['speed']==$time) { $p1turn = false; $p2turn = true; $found ++; } } $time ++; } Then follows all the HTML to build up the page. The player who has to act gets a form with choices to do with his unit. The other player gets "Opponents turn" in that window. So in the above code you see $p1turn or $p2turn gets true or false. This is for the Jquery script at the end of all the HTML to tell wich player needs to keep polling the unit files until theres a unit for him to act. Heres the script: Code: [Select] if ($p1turn == true) { if ($battle['player2'] == $_SESSION['SESS_MEMBER_ID']) { echo " <script type='text/javascript'> function turnlistener() { $('#main').load('battlegetnextunit.php'); }; $(function() { setInterval('turnlistener()', 5000 ); }); </script> "; } } if ($p2turn == true) { if ($battle['player1'] == $_SESSION['SESS_MEMBER_ID']) { echo " <script type='text/javascript'> function turnlistener() { $('#main').load('battlegetnextunit.php'); }; $(function() { setInterval('turnlistener()', 5000 ); }); </script> "; } } Now for the first player (the one who starts the battle) he can act properly. The next player can act, but he still is longpolling the .txt files as the form resets. If he acts withing the 5 seconds (setInterval('turnlistener()', 5000 )) the other player gets his turn again but my whole computer starts strugling and i'm not able to select anything in the form. Maybe it's like the players get double longpolling the 2nd turn. But i only have the last code once and obviously only 1 of 2 can run as either $p1turn or $p2turn can be true and it can only run for one player. What could this be? Is doing it this way even possible? I'm trying to figure this out for days now, i really hope someone can help me out. Thanks! Hi,
I am a bit of a MYSQL newbie so please bear with me. I have a database created about football/soccer stats. The database at the moment contains the following tables but more maybe added:
Players
Clubs
Seasons
Competitions
I will create php pages for these tables that add, edit and delete records for each. But the problem I can't get my head around is how to add a record that uses data from other tables, for example we would add a...
player -> club-season-competition
Lets say we want create a player called 'Joe Bloggs' and want to add his details, we need somehow for the page to display an option for club, season and competition. Maybe they can be drop down boxes but how does one fill those drop down boxes with records that are already added in the database for each table?
Thanks
$username = $_POST['uid']; $email = $_POST['mail']; $password = $_POST['pwd']; $passwordRepeat = $_POST['pwd-repeat']; $date = $_POST['date2']; $stream = $_POST['relationship']; $sql1 = "INSERT INTO users (uidUsers, emailUsers, pwdUsers, relationship) VALUES (?, ?, ?, ?);"; $sql2 = "INSERT INTO Family1 (username, application_filed, relationship) VALUES (?, ?, ?);"; $sql3 = "INSERT INTO Family2 (username, application_filed, relationship) VALUES (?, ?, ?);"; mysqli_query($sql1, $conn); mysqli_query($sql2, $conn); mysqli_query($sql3, $conn); $stmt = mysqli_stmt_init($conn); if (!mysqli_stmt_prepare($stmt, $sql2)) { header("Location: ../signup.php?error=sqlerror"); exit(); } else { mysqli_stmt_bind_param($stmt, "sss", $username, $date, $stream); $result = mysqli_stmt_get_result($stmt); if ($row = mysqli_fetch_assoc($result)) ($username==$_SESSION['uid'] and $stream =='nursing'); mysqli_stmt_execute($stmt); } if (!mysqli_stmt_prepare($stmt, $sql3)) { header("Location: ../signup.php?error=sqlerror"); exit(); } else { mysqli_stmt_bind_param($stmt, "sss", $username, $date, $stream); $result = mysqli_stmt_get_result($stmt); if ($row = mysqli_fetch_assoc($result)) ($username==$_SESSION['uid'] and $stream =='doctoral'); mysqli_stmt_execute($stmt); } if (!mysqli_stmt_prepare($stmt, $sql1)) { header("Location: ../signup.php?error=sqlerror"); exit(); } if (!mysqli_stmt_prepare($stmt, $sql1)) { header("Location: ../signup.php?error=sqlerror"); exit(); } else { $hashedPwd = password_hash($password, PASSWORD_DEFAULT); mysqli_stmt_bind_param($stmt, "ssss", $username, $email, $hashedPwd, $stream); mysqli_stmt_execute($stmt); header("Location: ../signup.php?signup=success"); exit(); I was wondering if someone could point me in the right direction. I have this code. They idea I had behind it is to insert values into different tables depending on variables being passed. So when user fills out a form and selects $stream="nursing" I want results to go to table 'users' and 'Family1', but not 'Family2' table. and if user selects $stream='doctoral' results should go to table 'users' and 'Family2', and not go to 'Family1' But with my query I get results go to both table and also users table. And there is no restriction to what users selects, variable $stream being passed no matter what it is. Is this the wrong way to go here? Did I completely mess up the logic? I have 3 tables w/ the following fields: Cities id | state_id | city_name States id | state_name New_cities id | state_id | city_name I am trying to write a script (and still working on it) that will INSERT new cities in cities WHERE New_cities.state_id = Cities.state_id. Obviously I am still in testing and results sort out, but honest to all hell, I might be going about this all wrong, and would appreciate any comments, criticism, assistance or feedback on what I am trying to do. <?php $query = "SELECT * FROM cities, states, new_cities"; if ($results = mysqli_query($cxn, $query)) { $row_cnt = mysqli_num_rows($results); echo $row_cnt . " Total Records in Query.<br /><br />"; if (mysqli_num_rows($results)) { while ($row = mysqli_fetch_array($results)) { if ($row['cities']['state_id'] == $row['new_cities']['new_state_id']) { $insert_city_query = "INSERT INTO cities id, new_state_id, city_name VALUES ('','$new_state_id','$city_name')" or mysqli_error(); } //if ($row['cities']['state_id'] == $row['new_cities']['new_state_id']) echo "$row[new_city_name]<br />"; } //while ($row = mysqli_fetch_array($results)) } //if (mysqli_num_rows($results)) } //if ($results = mysqli_query($cxn, $query)) ?> Hello,
I want to show checkbox is checked when there is entry of that id in a table in my database.
I have 2 tables page and access_level. I am getting data from page table and displays it in <ul><li> tag with checkbox to select all or only few. After selecting the checkbox, i will store only selected checkbox value in access_level table along with table id. Page link and page name details will be stored in page table.
Now if i want to edit , i should display all the pages which is there in page table and i should also mark checked to those which are already stored in access_level table.
I am using LEFT OUT JOIN, It displays all the pages. But it is not displaying the check mark to those which are already selected.
Here is my code
<?php $s1 = mysql_query("SELECT pages.page_id, pages.code, pages.page, pages.href, access_level.aid, access_level.page_id as pgid, access_level.department, access_level.position, access_level.active FROM pages LEFT OUTER JOIN access_level ON pages.page_id=access_level.page_id WHERE access_level.department=".$department." AND access_level.position=".$position." AND pages.code='sn'") or die(mysql_error()); while($s2 = mysql_fetch_array($s1)) { ?> <tr><td><li><?php echo $s2['page']; ?> </td><td><input type="checkbox" name="sn[]" value="<?php echo $s2['page_id']; ?>" <?php if($row['pgid'] === $s2['page_id']) echo 'checked="checked"';?> />here is my pages table pages.JPG 26.55KB 0 downloads access_level access_level.JPG 19.09KB 0 downloads In access_level table i do not have page ids 8 and 9. But i want to display that also from pages table and for 1 to 7 and 10 i should display check mark. How i can achieve this? Please Help To accomplish the layout I was looking for, I used the following code: for ($i=1; $i<=7; $i++) { //set day of week for display as title of columns $dow=date("l", strtotime($year.'W'."$weekno"."$i")); echo "<td class=\"wvcolumn\" valign=\"top\"> <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\" width=\"$daycolumn\"> <tr><th class=\"wvtitle\" valign=\"bottom\" align=\"center\" width=\"$daycolumn\"><a class=\"titledate\" href=\"createticket.php?action=o&month=".date("m", strtotime($year.'W'."$weekno"."$i"))."&date=".date("d", strtotime($year.'W'."$weekno"."$i"))."&year=".date("Y", strtotime($year.'W'."$weekno"."$i"))."\">$dow, ".date("F d", strtotime($year.'W'.$weekno."$i"))."</a> <a onClick=\"window.open('http://www.batchgeo.com')\" title=\"Map $dow's Appointments\" href=\"mapday.php?week=$weekno&year=$year&day=$i\"><img width=\"20\" style=\"border-style: none\" src=\"../images/icon_globe.png\"></a></th></tr>"; if(date("Y-m-d")==date("Y-m-d", strtotime($year.'W'."$weekno"."$i"))) { $query = "SELECT fieldtickets.ticketnumber, fieldtickets.business, title, apptdatetime, DATE_FORMAT(apptdatetime,'%h:%i %p') AS fapptdatetime, status, billstatus, type, assigntech, clients.business FROM fieldtickets LEFT JOIN clients ON fieldtickets.business = clients.id WHERE status='Open' AND (type = 'Field' OR type = 'Phone') AND apptdatetime BETWEEN '".date("Y-m-d", strtotime($year.'W'."$weekno"."$i"))." 00:00:00' AND '".date("Y-m-d", strtotime($year.'W'."$weekno"."$i"))." 23:59:59' UNION SELECT fieldtickets.ticketnumber, fieldtickets.business, title, apptdatetime, DATE_FORMAT(apptdatetime,'%h:%i %p') AS fapptdatetime, status, billstatus, type, assigntech, clients.business FROM fieldtickets LEFT JOIN clients ON fieldtickets.business = clients.id WHERE status = 'Pending' ORDER BY status ASC, apptdatetime ASC"; } else { $query = "SELECT fieldtickets.ticketnumber, fieldtickets.business, title, apptdatetime, DATE_FORMAT(apptdatetime,'%h:%i %p') AS fapptdatetime, status, billstatus, type, assigntech, clients.business FROM fieldtickets LEFT JOIN clients ON fieldtickets.business = clients.id WHERE status='Open' AND (type = 'Field' OR type = 'Phone') AND apptdatetime BETWEEN '".date("Y-m-d", strtotime($year.'W'.$weekno."$i"))." 00:00:00' AND '".date("Y-m-d", strtotime($year.'W'.$weekno."$i"))." 23:59:59' ORDER BY apptdatetime ASC"; } $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ //if ticket is open show appt time and business, if ticket pending display DELIVERY and business name if($row[status]=="Open") { $href="createticket.php?action=e&ticket=".$row[ticketnumber]; $time=$row[fapptdatetime]; $delivery=""; } elseif($row[status]=="Pending") { $href="createticket.php?action=c&ticket=".$row['ticketnumber'].""; $time=""; $delivery="DELIVER"; } echo "<tr><td valign=\"top\"><a title=\"".$row[ticketnumber]." - ".$row[title]."\" class=\"".$row[status]."\" href=\"$href\"><span>$delivery$time ".substr($row['business'], 0, $displaychars)."</span></a></td></tr>\n"; } echo "</table>"; } echo "</td></tr> </table>"; Output is similar to this, and any existing "deliveries" are displayed under the current day. _________________________________________________ ______________ | Monday | Tuesday | Wednesday | Thursday | Friday | |appointments |appointments |appointments |appointments |appointments This works great, but requires 5 separate queries. My database is very small for now, so its not a big deal, but I know this can be done much more efficiently. How can I query the whole week and put appointments in their corresponding tables (days)? Thank you for your help! Hi Guys, I building a system, where i have a customer table where user info is saved, and customer can choose the package like silver, gold, and platinum customer table: ID Username Password Name Address Active Now i want to make a table for choosing packages: package table: Package_ID Package_Name Package_Description Package_Duration Package_Amount Package_Active 1.Now my doubt is, whether Duration can be kept in days/month for example: 90 days or January, February, March 2.Package_Amount: what currency to be specify. Because am building a system for international users, what currency to be specify. (500 INR or 10USD) 3. what about upgrade of package: give me some ideas how to handle this. Please Help me, and i guess i have a design a table right. Thanks, How to make a form using HTML/PHP with conditional responses based on zip code? What I want to do exactly... zip codes 91900-92600 go to URL www.example.com after submit. All others go to URL www.example.com/page after submit. Any help would be much appreciated. Hi im new to php and I need help making webpage that queries a mysql database based on a 3 check boxes and displays results on the same page or on another page. The table being queried has 4 columns, name, gps, wifi, bluetooth. So for example a row in the table would be like, samsung galaxy s2, yes, yes, yes. The idea is for it to be a website that will display phones according to their features. So the idea is depending on if the boxes were ticked the samsung galaxy would be displayed as a result. So i need some help understanding how to make this. Some1 gave me the code below in attempt to help me (im not sure it works or not) but im not sure how fully use it, ie what pages i need to make and how i create the connection to the mysql database, and how to use the query that they wrote to display the results thanks code: Code: [Select] <form action="?do=filter" method="post"> <table cellspacing="0" cellpadding="3" border="1"> <tr> <td>GPS<input type="checkbox" name="gps" value="checked"></td> <td>Wifi<input type="checkbox" name="wifi" value="checked"></td> <td>Bluetooth<input type="checkbox" name="bluetooth" value="checked"></td> </tr> <tr><td><input type='submit' name='filter' value='Filter'></td></tr> </table> </form> </html> <?php function filterMe($filter){ if(isset($_POST[$filter])){ return "Yes"; }else{ return "No"; } } if(isset($_POST['filter'])){ echo "Gps - " . filterMe('gps'); echo " Wifi - " . filterMe('wifi'); echo " Bluetooth - " . filterMe('bluetooth'); } ?> All you need to do is use a query something like SELECT name,gps,wifi,bluetooth FROM `product` WHERE `gps`='".filterMe('gps')."' AND `wifi`='".filterMe('wifi')."' AND `bluetooth`='".filterMe('bluetooth')."' Hi again, i'm wondering how can i make Sort (for example a-z) an column in php reading mysql informations. Here's the script: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link rel="stylesheet" href="table.css" type="text/css"> </head> <body style="margin: 0 0 0 0;"> <? include("passwd.php"); @$start = $_GET["start"]; if($start =='') $start =0; include("lib.php"); $link = mysql_connect($host,$username,$password); if (!$link) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db($db, $link); if (!$db_selected) { die ("Can't use $db : " . mysql_error()); } //total number of records in the table $res = mysql_query("SELECT * from `$table`"); @$rows = mysql_num_rows ($res); $result = mysql_query("SELECT * from `$table` limit $start,10"); if (!$result) { die('Invalid query: ' . mysql_error()); } echo "<p align=center class = 'menu'> Ocitana tabela: $table </p>"; $cols = mysql_num_fields($result); $records = mysql_num_rows ($result); echo "<table align='center' width='1200' >"; echo "<tr bgcolor='BBCCDD' class='menu'>"; for ($i = 0; $i < $cols;$i++) { echo "<td align='center'>".mysql_field_name($result,$i)."</td>"; } echo "</tr>"; while ($row = mysql_fetch_array($result, MYSQL_NUM)) { echo "<tr bgcolor='F6F6F6' class='normal'>"; foreach ($row as $value) { echo "<td align='center'>".$value ."</td>"; } echo "</tr>"; } $end = $start + $records; echo "<tr align = 'center' bgcolor = 'BBCCDD' class='menu'><td colspan=$cols> Prijema $start do $end od $rows </td></tr>"; echo "<tr align = 'center' class='mylink'><td colspan=$cols> "; if($start != 0) { $prev = $start - 10; echo "<a href='tabela.php?start=$prev'> Prethodna </a> "; } if($start<$rows-10) { $next = $start + 10; echo "<a href = 'tabela.php?start=$next'>Sledeca</a> "; } echo "</td></tr>"; echo "</table>"; ?> </body> </html> Hi All, I created a website which runs perfectly on one server but now I transferred the website to another server I get all kinds of errors like, Undefined variables and so on. How is this possible. I thought it was all in the code. Marco I'm developing a kind of social network. I've got a question, say it to grow very quickly, I would have to run it across multiple servers to support all users, but I have no idea how I would do it. I'm basically using PHP / MySQL. Could anyone give me a hand? Thanks. I am trying to transfer some data from one Servers DB to a new server with cleaner tables. When i run my code the transfer seems to be working but the script just keeps running and never give the desired responses. First it collects the data (for testing i limited results by 1) then checks to see if the app is in the new DB, if so then it updates its contents. If not then it adds it. It seems to work for both updates and inserts but i must still be missing something. Thanks for any help. Code: [Select] <?php function getTime() { $a = explode (' ',microtime()); return(double) $a[0] + $a[1]; } $Start = getTime(); ###################################################################### $connection1 = mysql_connect('','',''); if (!$connection1){ die('Could not connect: ' . mysql_error()); } $db_selected1 = mysql_select_db('', $connection1); if (!$db_selected1) { die ('Could not connect: ' . mysql_error()); } //if(isset($_REQUEST['appcounting'])){ //$appcounting = ($_REQUEST['appcounting'] + 1); //$appnext = 1; //$appgroup = $appcounting + $appnext; //echo "Checked app $appcounting-$appgroup.<br />\n"; //} //else{ //$appcounting = 0; //$appnext = 1; //} $count = 0; $appinfo = mysql_query("SELECT app_id, ipayAppID, Status, MID, BusinessContactName, BusinessContactPhone, BusinessEmail, BusinessWebsite, BusinessName, BusinessAddress, BusinessCity, BusinessState, BusinessZip, BusinessTaxID, BusinessMailingAddress, BusinessMailingCity, BusinessMailingState, BusinessMailingZip, agent_id, CreateTime, StatusChangeTime, ReceiveTime, ReviewTime, PayrollApprovalTime, PayrollPayTime, ApproveTime, DeclineTime, CancelTime, CancelDesc, PendingTime, PendingDesc FROM app ORDER BY app_id DESC LIMIT 0, 1") or die('SELECT ' . mysql_error()); while($row = mysql_fetch_array($appinfo)) { $app_id[] = $row['app_id']; $ipayAppID[] = $row['ipayAppID']; $Status[] = $row['Status']; $MID[] = $row['MID']; $BusinessContactName[] = $row['BusinessContactName']; $BusinessContactPhone[] = $row['BusinessContactPhone']; $BusinessEmail[] = $row['BusinessEmail']; $BusinessWebsite[] = $row['BusinessWebsite']; $BusinessName[] = $row['BusinessName']; $BusinessAddress[] = $row['BusinessAddress']; $BusinessCity[] = $row['BusinessCity']; $BusinessState[] = $row['BusinessState']; $BusinessZip[] = $row['BusinessZip']; $BusinessTaxID[] = $row['BusinessTaxID']; $BusinessMailingAddress[] = $row['BusinessMailingAddress']; $BusinessMailingCity[] = $row['BusinessMailingCity']; $BusinessMailingState[] = $row['BusinessMailingState']; $BusinessMailingZip[] = $row['BusinessMailingZip']; $agent_id[] = $row['agent_id']; $CreateTime[] = $row['CreateTime']; $StatusChangeTime[] = $row['StatusChangeTime']; $ReceiveTime[] = $row['ReceiveTime']; $ReviewTime[] = $row['ReviewTime']; $PayrollApprovalTime[] = $row['PayrollApprovalTime']; $PayrollPayTime[] = $row['PayrollPayTime']; $ApproveTime[] = $row['ApproveTime']; $DeclineTime[] = $row['DeclineTime']; $CancelTime[] = $row['CancelTime']; $CancelDesc[] = $row['CancelDesc']; $PendingTime[] = $row['PendingTime']; $PendingDesc[] = $row['PendingDesc']; $count++; } mysql_close($connection1); ###################################################################### $connection2 = mysql_connect('','',''); if (!$connection2){ die('Could not connect: ' . mysql_error()); } $db_selected2 = mysql_select_db('', $connection2); if (!$db_selected2){ die ('Could not connect: ' . mysql_error()); } $number = 0; $count_insert = 0; while($number <= $count) { $findapp = $app_id[$number]; $one = mysql_query("SELECT AppID FROM Apps WHERE `AppID`='$findapp'") or die('FIND ' . mysql_error()); $num_rows = mysql_num_rows($one); if ($num_rows == 1){ $myBusinessContactName = $BusinessContactName[$number]; $myBusinessContactName = addslashes($myBusinessContactName); $myBusinessName = $BusinessName[$number]; $myBusinessName = addslashes($myBusinessName); $myBusinessCity = $BusinessCity[$number]; $myBusinessCity = addslashes($myBusinessCity); $myBusinessMailingCity = $BusinessMailingCity[$number]; $myBusinessMailingCity = addslashes($myBusinessMailingCity); $myPendingDesc = $PendingDesc[$number]; $myPendingDesc = addslashes($myPendingDesc); $myCancelDesc = $CancelDesc[$number]; $myCancelDesc = addslashes($myCancelDesc); $myBusinessAddress = $BusinessAddress[$number]; $myBusinessAddress = addslashes($myBusinessAddress); $myBusinessMailingAddress = $BusinessMailingAddress[$number]; $myBusinessMailingAddress = addslashes($myBusinessMailingAddress); mysql_query("UPDATE Apps SET `IpayAppID`='$ipayAppID[$number]', `Status`='$Status[$number]', `MID`='$MID[$number]', `ContactName`='$myBusinessContactName', `ContactPhone`='$BusinessContactPhone[$number]', `ContactEmail`='$BusinessEmail[$number]', `ContactWebsite`='$BusinessWebsite[$number]', `DBA`='$myBusinessName', `BusinessAddress`='$myBusinessAddress', `BusinessCity`='$myBusinessCity', `BusinessState`='$BusinessState[$number]', `BusinessZip`='$BusinessZip[$number]', `BusinessTaxID`='$BusinessTaxID[$number]', `MailingAddress`='$myBusinessMailingAddress', `MailingCity`='$myBusinessMailingCity', `MailingState`='$BusinessMailingState[$number]', `MailingZip`='$BusinessMailingZip[$number]', `Agent1ID`='$agent_id[$number]', `CreateTime`='$CreateTime[$number]', `StatusChangeTime`='$StatusChangeTime[$number]', `ReceivedTime`='$ReceiveTime[$number]', `ReviewedTime`='$ReviewTime[$number]', `PayrollApprovalTime`='$PayrollApprovalTime[$number]', `PayrollPayTime`='$PayrollPayTime[$number]', `ApproveTime`='$ApproveTime[$number]', `DeclineTime`='$DeclineTime[$number]', `CancelTime`='$CancelTime[$number]', `CancelDesc`='$myCancelDesc', `PendingTime`='$PendingTime[$number]', `PendingDesc`='$myPendingDesc' WHERE AppID='$app_id[$number]'") or die('UPDATE ' . mysql_error()); $number++; } elseif(isset($app_id[$number]) && isset($BusinessName[$number])){ echo "Transfered App $findapp<br />\n"; $myBusinessContactName = $BusinessContactName[$number]; $myBusinessContactName = addslashes($myBusinessContactName); $myBusinessName = $BusinessName[$number]; $myBusinessName = addslashes($myBusinessName); $myBusinessCity = $BusinessCity[$number]; $myBusinessCity = addslashes($myBusinessCity); $myBusinessMailingCity = $BusinessMailingCity[$number]; $myBusinessMailingCity = addslashes($myBusinessMailingCity); $myPendingDesc = $PendingDesc[$number]; $myPendingDesc = addslashes($myPendingDesc); $myCancelDesc = $CancelDesc[$number]; $myCancelDesc = addslashes($myCancelDesc); $myBusinessAddress = $BusinessAddress[$number]; $myBusinessAddress = addslashes($myBusinessAddress); $myBusinessMailingAddress = $BusinessMailingAddress[$number]; $myBusinessMailingAddress = addslashes($myBusinessMailingAddress); mysql_query("INSERT INTO Apps (AppID, IpayAppID, Status, MID, ContactName, ContactPhone, ContactEmail, ContactWebsite, DBA, BusinessAddress, BusinessCity, BusinessState, BusinessZip, BusinessTaxID, MailingAddress, MailingCity, MailingState, MailingZip, Agent1ID, CreateTime, StatusChangeTime, ReceivedTime, ReviewedTime, PayrollApprovalTime, PayrollPayTime, ApproveTime, DeclineTime, CancelTime, CancelDesc, PendingTime, PendingDesc) VALUES ('$app_id[$number]', '$ipayAppID[$number]', '$Status[$number]', '$MID[$number]', '$myBusinessContactName', '$BusinessContactPhone[$number]', '$BusinessEmail[$number]', '$BusinessWebsite[$number]', '$myBusinessName', '$myBusinessAddress', '$myBusinessCity', '$BusinessState[$number]', '$BusinessZip[$number]', '$BusinessTaxID[$number]', '$myBusinessMailingAddress', '$myBusinessMailingCity', '$BusinessMailingState[$number]', '$BusinessMailingZip[$number]', '$agent_id[$number]', '$CreateTime[$number]', '$StatusChangeTime[$number]', '$ReceiveTime[$number]', '$ReviewTime[$number]', '$PayrollApprovalTime[$number]', '$PayrollPayTime[$number]', '$ApproveTime[$number]', '$DeclineTime[$number]', '$CancelTime[$number]', '$myCancelDesc', '$PendingTime[$number]', '$myPendingDesc')") or die('INSERT ' . mysql_error()); $number++; $count_insert++; } } if($count_insert == 0){ echo "All apps have been found.<br />\n"; exit; } mysql_close($connection2); ###################################################################### $End = getTime(); echo "Time taken = ".number_format(($End - $Start),2)." secs<br />\n"; //header('Refresh: 60; url=transfer_apps.php?appcounting=$appcounting'); ?> Hi: I have a login file where a user goes to a db based on the dbtype selected. Now $dbtype1 links to a db on Server 1 ( that is the server on which this script is running and $dbtype2 links to a db on Server 2 I created a connection-link file connectlink.php as under but while $dbtype1 works without a problem , $dbtype2 gives me an error 'no access to db' and user dbun1@localhost not found on db1.db . What am I missing in the connectlink.php file please ? Thanks login.php =========== <? ...... if($_POST['submit']){ $dbtype = $_POST['dbtype']; if ($dbtype == 'type1') { $section = 'type1'; require("../x/type1/type1.php"); } if ($dbtype == 'type2') { $section = 'type2'; require("../x/type2/connectlink.php"); //the dir 'x' is a common name on both the servers'' } //then it processes $userfile and give this Click <a href="'.$section.'/'.$userFile.'?Userid='.$userid.'"> here ?> connectlink.php ============== <? //this file contains db info, log and checks if user is authorised to access the db - ist check. error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR); $dbusername2='a'; $dbpassword2='b'; $dbname2='c'; $servername = 'ip address of server or localhost ?'; $link2=mysql_connect ("$servername","$dbusername2","$dbpassword2", true); if(!$link2){ die("Could not connect to MySQL");} mysql_select_db("$dbname2",$link2) or die ("could not open db".mysql_error()); $dbusername1='d'; $dbpassword1='e'; $dbname1='f'; $servername = 'localhost'; $link1=mysql_connect ("$servername","$dbusername1","$dbpassword1", true); if(!$link1){ die("Could not connect to MySQL");} mysql_select_db("$dbname1",$link1) or die ("could not open db".mysql_error()); $sql = "SELECT * FROM Users WHERE Userid='$userid'",$link2; $result = mysql_query($sql); if ($myrow = mysql_fetch_array($result)){ $login_success = 'Yes'; $status = "On"; .... $sql2= "insert into Log (....) values(.....)",$link2;; $result2 = mysql_query($sql2) or die ('no access to database: ' . mysql_error()); // echo mysql_error(); } } else { $failureMessage = '<p class="data"><center><font face="Verdana" size="2" color="red">Login Failure. You are not authorised to access this database .<br /></font></center></p>'; print $failureMessage; $logoutMessage = 'Click <a href="../NEWDBS/mainlogout.php"> here </a>to logout </p>'; print $logoutMessage; exit; } ?> Just wondering, which is better php databases or sql? I have phpMyAdmin and I've that you can convert the database into php scripts? |