PHP - Multiple Servers
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.
Similar TutorialsHi: 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; } ?> 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 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 How do you check if a MySQL or MySQLi server is available through php. I'm trying to make a short script that makes sure the users server can run the application. Like all the popular ones do Hi there, Everyday I run a php script on a database to extract certain information I need and save to a text file. I then need to be able to send this file to another server without needing for manual intervention. i.e. the script will integrate sending the file to another server. Can anyone point me in the right direction to get started? Thanks! Hello wize PHP dudes. I'm a fairly advanced PHP user, but I'm confused by STRTOTIME producing different results on two identical servers. Both running PHP Version 5.2.6-3. - Server 1: echo date("Y",strtotime('1763-03-24 00:00:00')); returns '1763' - Server 2: echo date("Y",strtotime('1763-03-24 00:00:00')); returns '1970' Why do you reckon Server 1 seems not to worry about the Unix Epoch date limit, and happily computes the 1763 date? I would really like Server 2 to do the same thing, but having gone through the php.ini I can't see any difference. I would really like Server 2 to start working with older dates. I don't want a workaround, as server 1 has been working with just strtotime for years. I can't remember doing anything different on setup. Weird! Thanks. I have release notes on my server, at example.com/release.txt. My software points to this file so people can see the notes: Code: [Select] file_get_contents( http://example.com/release.txt ); Why -- since all sites are on the internet -- can most of my customers see the file but some cannot? Just seems odd to me. Could some servers be turning that off or something? Doesn't seem like a problem on my server. Hello everybody!
I'm here today with a mystery i can't solve...
The problem i'm having is that i need to be able to transfer mysql data from one server to another one.
Retrieving data from the one database is easy, but making it transfer to another server is not that easy for me.
I have it printing out the data ATM
This is how i retrieve data from one server:
<?php $dbhost = ""; $dbname = "eg_xenforo"; $dbuser = ""; $dbpass = ""; $conn = mysqli_connect("$dbhost","$dbuser","$dbpass","$dbname") or die("Error " . mysqli_error($conn)); $sql= "SELECT username FROM xf_user WHERE FIND_IN_SET('9',secondary_group_ids) UNION SELECT username FROM xf_user WHERE FIND_IN_SET('10',secondary_group_ids) UNION SELECT username FROM xf_user WHERE FIND_IN_SET('12',secondary_group_ids)"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { // output data of each row while($row = mysqli_fetch_assoc($result)) { $name = $row['username']; echo "$name <br>"; } } else { echo "0 results"; } ?>This is what i get as result: CosmonautBob ooglebrain JamieKG Quinnter16 Jordan Zoehamp skynet1123 misscupcake1306 Sir CrimsonThese are usernames that should be added onto another server in a database table. Any suggestions? Thanks in advance! I have spent lots of time trying to design a nice structure for my project and I would like some feedback to what you guys think, please note this is the first time I've ever done anything like this.
About My Project
I am creating a service where advertisers can search through a catalog of websites they want to directly advertise on. Once they have found a website, they can upload an image, pay the fees and start advertising on that website instantly.
I have designed an image of how I think the structure should look, I have designed it this way for efficiency but I am pretty sure I could improve with some help. If you need more info or have any questions, please ask.
Project Structure Design Image
Thanks for reading, what do you think about this structure? Can I improve it?
Edited by itsliamoco, 26 July 2014 - 09:34 PM. I'm more of a php hobbiest having learned most of what I use from experimenting on our page. I just switched servers from Total choice hosting to Godaddy and now some of my functions are not working. The 2 biggest a On our where to play page the default that loads is our All page and that works but then people are supposed to be allowed to change types at the top and then hit select and pull up that page. The function loads up the folder properly but when you press Select City it just reloads the All page. I still have access to the old server till the end of the month in order to get files and anything else that I may have forgotten to copy over. Is there maybe a php file I should have brought over and forgot? The other big difference I noticed my old page was stored in public_html the new one is stored in the root directory. The page was originally created outside and I have maintained it for the last 5 years so I have been following behind the old code and didn't do the foundation myself. Thank you for any help you can give. The Code I have for these functions is: <?php echo "<form method=POST action=$PHP_SELF> <select name=\"selected_city\"> <option value=\"\"></option>"; //check files in directory if ($handle = opendir('locations/')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo $file; $file = substr($file, 0, -4); echo "<option value=" . $file . ">$file</option>"; } } closedir($handle); } ?> </select> <input type="submit" name="submit" value="Select City" /> </form> <?php DEFINE('LOG_DIR', $_SERVER['DOCUMENT_ROOT'].'/locations/'); //if this is the first visit to this page, display the default city. if ($submit){ if($_POST['selected_city'] == ""){ echo "<p>No city selected, please try again.</p>"; exit; } $selected_city = $_POST['selected_city']; } else{ //default city - must match csv filename exactly prior to appending extension $selected_city = "All"; } echo "<p>$selected_city</p>"; $filename = $selected_city . ".csv"; $file = file(LOG_DIR.$filename); ?> The other big announce is that our front page has a news feed that I update through another page that edits and deletes and adds to the notepad file that is read by the front page. I have the notepad files permissions set to 777 but when I use the update it doesn't do anything. The code for this page is: <?php include "header.php" ?> <td width="75%" id="maincontain" class="main"> <?php include "adminbar.php" ?> <hr /> <?php if($action == "edit" && isset($HTTP_POST_VARS['password'])) { if($HTTP_POST_VARS['password'] == "gonews") { //Recompile that line with the pipe symbols so we can reinsert it $line = $HTTP_POST_VARS['date'] . "|" . $HTTP_POST_VARS['title']; $line .= "|" . $HTTP_POST_VARS['news']; $line = str_replace("\r\n","<BR>",$line); $line .= "\r\n"; $line = stripslashes($line); $data = file('news.txt'); $data[$id] = $line; //the next line makes sure the $data array starts at the beginning reset($data); //now we open the file with mode 'w' which truncates the file $fp = fopen('news.txt','w'); foreach($data as $element) { fwrite($fp, $element); } fclose($fp); echo "Item Edited!<BR><BR>\n"; echo "<a href=\"$PHP_SELF\">Go Back</a>\n"; exit; } else { echo "Bad password!\n"; exit; } } if($action == "edit") { $data = file('news.txt'); $element = trim($data[$id]); $pieces = explode("|", $element); //the next line is to reverse the process of turning the end of lines into breaking returns $news = str_replace("<BR>","\r\n",$pieces[2]); echo "Make the changes you would like and press save.<BR>\n"; echo "<FORM ACTION=\"$PHP_SELF?action=edit\" METHOD=\"POST\" NAME=\"editform\">\n"; echo "Title:<BR>\n"; echo "<INPUT TYPE=\"text\" SIZE=\"30\" NAME=\"title\" value=\"".$pieces[1]."\"><BR>\n"; echo "The News:<BR>\n"; echo "<TEXTAREA NAME=\"news\" COLS=\"40\" ROWS=\"5\">".$news."</TEXTAREA><BR><BR>\n"; echo "Password:<BR>\n"; echo "<INPUT TYPE=\"password\" SIZE=\"30\" NAME=\"password\"><BR>\n"; echo "<INPUT TYPE=\"hidden\" NAME=\"date\" VALUE=\"".$pieces[0]."\">\n"; echo "<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">\n"; echo "<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Save\"><BR>\n"; echo "</FORM>\n"; exit; } if($action == "delete" && isset($HTTP_POST_VARS['password'])) { if($HTTP_POST_VARS['password'] == "nonews") { $data = file('news.txt'); //this next line will remove the single news item from the array array_splice($data,$id,1); //now we open the file with mode 'w' which truncates the file $fp = fopen('news.txt','w'); foreach($data as $element) { fwrite($fp, $element); } fclose($fp); echo "Item deleted!<BR><BR>\n"; echo "<a href=\"$PHP_SELF\">Go Back</a>\n"; exit; } else { echo "Bad password!\n"; exit; } } if($action == "delete") { echo "<H2>You are about to delete the following news item.</H2>\n"; $data = file('news.txt'); $element = trim($data[$id]); $pieces = explode("|", $element); echo $pieces[2] . "<BR>" . "<b>Posted by " . $pieces[1] . " on " . $pieces[0] . "</b>\n"; echo "<BR><BR>\n"; echo "Are you sure you want to delete this news item? If so, enter the password and click on Delete.<BR>\n"; echo "<FORM ACTION=\"$PHP_SELF?action=delete\" METHOD=\"POST\" NAME=\"deleteform\">\n"; echo "Password:<BR>\n"; echo "<INPUT TYPE=\"password\" SIZE=\"30\" NAME=\"password\"><BR>\n"; echo "<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$id\">\n"; echo "<INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Delete\"><BR>\n"; echo "</FORM>\n"; ?> </td> </tr> </table> <br /> <?php include "footer.php"; exit; } ?> <?php $data = file('news.txt'); //next line removed to make everything else easier in the admin script //$data = array_reverse($data); foreach($data as $key=>$element) { $element = trim($element); $pieces = explode("|", $element); echo "<strong>" . $pieces[1] . "</strong> - <font color=\"DF9D00\" size=\"1\">" . $pieces[0] . "</font><BR>" . $pieces[2] . "<br /><br />"; echo " <a href=\"$PHP_SELF?action=delete&id=$key\">Delete</a>\n"; echo " <a href=\"$PHP_SELF?action=edit&id=$key\">Edit</a>\n"; echo "<hr><BR>\n"; } echo "<HR>\n"; echo "<H4><u>Add News</u></H4>\n"; if($HTTP_POST_VARS['submit']) { if($HTTP_POST_VARS['password'] == 'gonews') { if(!$HTTP_POST_VARS['title']) { echo "You must enter a Title"; exit; } if(!$HTTP_POST_VARS['news']) { echo "You must enter some news"; exit; } if(strstr($HTTP_POST_VARS['title'],"|")) { echo "Title cannot contain the pipe symbol - |"; exit; } if(strstr($HTTP_POST_VARS['news'],"|")) { echo "News cannot contain the pipe symbol - |"; exit; } $fp = fopen('news.txt','a'); if(!$fp) { echo "Error opening file!"; exit; } $line = date("m.d.y") . "|" . $HTTP_POST_VARS['title']; $line .= "|" . $HTTP_POST_VARS['news']; $line = str_replace("\r\n","<BR>",$line); $line .= "\r\n"; $line = stripslashes($line); fwrite($fp, $line); if(!fclose($fp)) { echo "Error closing file!"; exit; } echo "<b>News added!</b>\n"; } else { echo "Bad Password"; } } ?> <FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="newsentry"> Your Title:<BR> <INPUT TYPE="text" SIZE="30" NAME="title"><BR> The News:<BR> <TEXTAREA NAME="news" COLS="40" ROWS="5"></TEXTAREA><BR><BR> News Password:<BR> <INPUT TYPE="password" SIZE="30" NAME="password"><BR> <INPUT TYPE="submit" NAME="submit" VALUE="Post it!"><BR> </FORM> </td> <?php include "footer.php" ?> Hi, I have a domain called domain-whois-lookup.com It is having 6 NS records, you can verify that at domaintools.com/domain-whois-lookup.com I have a following code : Code: [Select] <?php $result = dns_get_record("domain-whois-lookup.com", DNS_NS); echo count($result); echo "<p></p>"; print_r ($result['0']); echo "<p>================</p>"; for($i=0; $i<=count($result); $i++) { // @print_r ($result["$i"]); @$target_ns = $result["$i"]; echo "<p></p>"; print_r ($target_ns["target"]); echo "<p></p>"; } ?> After executing this, it shows only 4 records instead of 6, why ? One more thing is many times, first name server (e.g. ns1) shows as 2nd and 2nd NS as first, why ? Hello,
I've installed a Debian x64 minimal package and a control panel on my VPS, but after I install the name servers, the domain doesn't reach my VPS's name servers for some reason.
The minimal package comes only with the tools to run the Debian server which means it had no sudo and such.
But previously when I had Centos on before switching to Debian, it did reach the name servers.
Which in this case I suspect that it's a server-side problem, could there be any ?
When I try to connect to the domain it says that the website is not available.
I am using zpanel and the default DNS records that the zpanel generates.
P.S. I tried to find the reason why it doesn't work but I couldn't find any solution, all I found is suggestions to add www A record which also didn't work.
And yes, I did wait 24 hours and even more.
I'm stuck at trying to figure out out to complete the 3 Step scripts to accomplish passing $variables between 2 different servers. Since there will actually be 12 Non-POST $variables involved in the SERVER #1 to SERVER #2 transfer , it doesn't appear that trying to put these all in a URL string and going the 'GET' route is practical.
I'm just using 3 short test variables in the examples. My eyeballs started rolling within I ran across something about 'CURL' that might be a necessary part of the solution?
The code I have been able to hammer out so far is below as STEP 1, STEP 2 and STEP 3.
STEP 1
<?php // submit.php // STEP 1 // On (LOCAL) SERVER #1 TO relay $variables to 'process.php' on (REMOTE) SERVER #2 // To submit $variables to directly another destination server script // NOTE: The $variable are NOT the result of Form Input !!! // For login Authenticaion ALL 3 must match db entries on SERVER #2 // NOTE: (Again) The $variables are NOT the result of Form Input !!! $userid = "adam"; $passwd = "eve"; $pscode = "peterpan"; // NOTE: (Again) The $variable are NOT the result of Form Input !!! // These $variables are needed for MySQL db INSERT on the destination URL server // For testing simplicity (actual data will be 12 $variables) $a = "apple"; $b = "banana"; $u = "1234567; // // Not sure if something called 'CURL' is needed here ??? // $submit_to_url = http://www.blahblah.com/process.php"; ?>STEP 2 <?php // processor.php // STEP 2 // ON SERVER #2 TO RECEIVE DATA DIRECTLY FROM SERVER #1 'submit.php' // To receive and process the $variables into a MySQL db on SERVER #2 // NOTE: The $variables are NOT the result of Form Input !!! // First validate $userid, $passwd & $pscode against `verify` table MySQL records require '/SERVER_2_securelocation_for_database_connection/secret_mysqli.php'; if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // // Not sure if something called 'CURL' is needed here ??? // // These login $variables are from submit.php on SERVER #1 $userid $passwd $pscode $sql="SELECT `userid`, `passwd`, `pscode` FROM `verify` WHERE `userid` = '$userid'" AND `passwd` = '$passwd` AND `pscode` = '$pscode'; $result = mysqli_query($con,$sql); if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } // // Then some Authentication code if ALL 3 components match // // If Authentication = true then $passed = "YES" must sent // be sent back to the 'finalstep.php' script on SERVER #1 // If Authentication (or connection) = false ... $passed = "NO" $return_to_url = http://www.blahblah.com/finalstep.php"; // These $variables are from submit.php on SERVER #1 $a = "apple"; $b = "banana"; $u = "1234567"; $sql="INSERT INTO `data` (`a`, `b`, `u`) VALUES ('$a', '$b', '$u')"; if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } // If $SQL INSERT into `data` on SERVER #2 works ... // $status = "Pending" must be sent back to the 'finalstep.php' // script on SERVER #1 for MySQL db Table insertion // If $SQL INSERT into `data` = false, then $status = "Error" // NOTE: The '$u' $variable also needs send back to finalstep.php !!! $return_to_url = http://www.blahblah.com/finalstep.php"; mysqli_close($con); ?>STEP 3 <?php // finalstep.php // STEP 3 // ON SERVER #1 TO RECEIVE DATA DIRECTLY BACK FROM SERVER #2 process.php // To receive the $passed, $status and $u $variables for final step action // NOTE: The $variable are NOT the result of Form Input !!! require '/SERVER_1_securelocation_for_database_connection/secret_mysqli.php'; if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } // These $variables are from process.php on SERVER #2 $passed $status $u $sql="UPDATE `tracking` SET `passed` = '$passed', `status` = '$status' WHERE `uniqueid` = '$u' "; $result = mysqli_query($con,$sql); if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); } mysqli_close($con); ?>Thanks very much for any assistance and guidance. -freakingOUT Hi I am hoping someone can help. My hosting company has just moved my website to a different server, and I noticed that it was giving me blank pages, I added in some debug and now I am getting undefined variable errors and I don't know why or how to fix it. The Page which has broken currently gets its information from the database from the url. RewriteRule ^reviews/([^/]*)\/$ /bingosite.php?h1=$1 [L] The code in the broken page that is throwing out undefined variable errors is the following: <? $query = mysql_query("SELECT * FROM link where linktype='bingo' and h1 ='".StripUrl101(ucwords($h1))."'"); { while($row =mysql_fetch_assoc($query)) extract($row);?> <? if ($linkType=="bingo") { ?> <?php echo "$h1"; ?> <? } } ?> I have used this code for years so it could be that it is old but as I only know basic PHP I am very stuck and the hosting company isn't being very helpful. Just to add if I write <? $query = mysql_query("SELECT * FROM link where linktype='bingo' and h1 ='Quick Bingo'"); { while($row =mysql_fetch_assoc($query)) extract($row);?> The results for Quick Bingo appear on the page. However it needs to work dynamically like it was doing before. If anyone can help it would be appreciated. Thanks Rachael Edited by rachae1, 17 May 2014 - 04:29 PM. 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'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.
This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=351561.0 Ok I'm trying to insert multiple rows by using a while loop but having problems. At the same time, need to open a new mysql connection while running the insert query, close it then open the previous mysql connection. I managed to insert multiple queries before using a loop, but for this time, the loop does not work? I think it is because I am opening another connection... yh that would make sense actually? Here is the code: $users = safe_query("SELECT * FROM ".PREFIX."user"); while($dp=mysql_fetch_array($users)) { $username = $dp['username']; $nickname = $dp['nickname']; $pwd1 = $dp['password']; $mail = $dp['email']; $ip_add = $dp['ip']; $wsID = $dp['userID']; $registerdate = $dp['registerdate']; $birthday = $dp['birthday']; $avatar = $dp['avatar']; $icq = $dp['icq']; $hp = $dp['homepage']; echo $username." = 1 username only? :("; // ----- Forum Bridge user insert ----- $result = safe_query("SELECT * FROM `".PREFIX."forum`"); $ds=mysql_fetch_array($result); $forum_prefix = $ds['prefix']; define(PREFIX_FORUM, $forum_prefix); define(FORUMREG_DEBUG, 0); $con = mysql_connect($ds['host'], $ds['user'], $ds['password']) or system_error('ERROR: Can not connect to MySQL-Server'); $condb = mysql_select_db($ds['db'], $con) or system_error('ERROR: Can not connect to database "'.$ds['db'].'"'); include('../_phpbb_func.php'); $phpbbpass = phpbb_hash($pwd1); $phpbbmailhash = phpbb_email_hash($mail); $phpbbsalt = unique_id(); safe_query("INSERT INTO `".PREFIX_FORUM."users` (`username`, `username_clean`, `user_password`, `user_pass_convert`, `user_email`, `user_email_hash`, `group_id`, `user_type`, `user_regdate`, `user_passchg`, `user_lastvisit`, `user_lastmark`, `user_new`, `user_options`, `user_form_salt`, `user_ip`, `wsID`, `user_birthday`, `user_avatar`, `user_icq`, `user_website`) VALUES ('$username', '$username', '$phpbbpass', '0', '$mail', '$phpbbmailhash', '2', '0', '$registerdate', '$registerdate', '$registerdate', '$registerdate', '1', '230271', '$phpbbsalt', '$ip_add', '$wsID', '$birthday', '$avatar', '$icq', '$hp')"); if (FORUMREG_DEBUG == '1') { echo "<p><b>-- DEBUG -- : User added: ".mysql_affected_rows($con)."<br />"; echo "<br />-- DEBUG -- : Query used: ".end($_mysql_querys)."</b></p><br />"; $result = safe_query("SELECT user_id from ".PREFIX_FORUM."users WHERE username = '$username'"); $phpbbid = mysql_fetch_row($result); safe_query("INSERT INTO `".PREFIX_FORUM."user_group` (`group_id`, `user_id`, `group_leader`, `user_pending`) VALUES ('2', '$phpbbid[0]', '0', '0')"); safe_query("INSERT INTO `".PREFIX_FORUM."user_group` (`group_id`, `user_id`, `group_leader`, `user_pending`) VALUES ('7', '$phpbbid[0]', '0', '0')"); mysql_close($con); } include('../_mysql.php'); mysql_connect($host, $user, $pwd) or system_error('ERROR: Can not connect to MySQL-Server'); mysql_select_db($db) or system_error('ERROR: Can not connect to database "'.$db.'"'); } So I need to be able to insert these rows using the while loop.. how can I do this? I really appreciate any help. First, Happy X-Mas to all! I want to do a form for entering dog-show results. On first site of form the user is able to enter how many dogs for each class (there are youth and open class for example) he want to insert. So on second site there will be formfields for every dog in every class, created with php. User should be able to take dogname from jquery autocomplete - this works for multiple fields. But i need the according id to the dogname - and actual only one id is given - the first one is changing by choosing from autocomplete in next fields... Data came from a json array like 0: {dogidindatabase: "9892", value: "Excalibur Khali des Gardiens de la Cour ",…} dogidindatabase: "9892" label: "<img src='../main/img/female.png' height='20'>Excalibur Khali des Gardiens de la Cour " value: "Excalibur Khali des Gardiens de la Cour " 1: {dogidindatabase: "15942", value: "Excalibur from Bandit's World Kalli",…} dogidindatabase: "15942" label: "<img src='../main/img/male.png' height='20'>Excalibur from Bandit's World Kalli" value: "Excalibur from Bandit's World Kalli"all i need is inside ... the script in form is <script type='text/javascript'> //<![CDATA[ $(function() { $(".dog").autocomplete({ source: "xxx.php", minLength: 3, select: function(event, ui) { $('#dogidindatabase').val(ui.item.dogidindatabase); } }); $["ui"]["autocomplete"].prototype["_renderItem"] = function( ul, item) { return $( "<li></li>" ) .data( "item.autocomplete", item ) .append( $( "<a></a>" ).html( item.label ) ) .appendTo( ul ); }; }); //]]> </script>and the form looked like <input type='text' name='dog' class='dog' value='".strip_tags(${'dogname' .($countbabymale+1)})."' size='35' data-required='true' /><br> <input class='readonly' readonly='readonly' type='text' id='dogidindatabase' name='dogidindatabase' size='5' />I changed in script and form id='dogidindatabase' to class, but it doesn´t work. Testsite is under http://www.wolfdog-d...how.php?lang=de (only german at first) - Insert a number (higher than 1) under baby 3-6 (first box, the others are not working for testing); submit to get to page 2; you see all post-variables (for testing). Try to insert a dogname in first input-field (choose "exc") and insert first one - the id is under dogname. In second dogname inputfield you can choose second dog - the id for the first one changes to id of seond one .... How can i get both for every dog? Hello all, I am trying to learn OOP in PHP so please forgive my ignorance. I seem to be having difficulty inserting data into my database from checkbox items. My database has a column for each each fruit. I would like for each column to be populated with either a one(1) for checked or a zero(0) for not checked. Currently, my attempts have failed. I can either get all checkboxes to insert all zeros or I can get the first column to insert a one(1) while the others as zeros. Is there anybody here that can help me figure out what I am doing wrong and help me to re-work my code so I can get this to work? If anybody can help me using OOP methods that would be fantastic. Thank you all in advance.
$preffruit->create_preffruit(array( 'fruit_apple' => escape(Input::get(['fruit_selection'][0]) ? 1 : 0), 'fruit_orange' => escape(Input::get(['fruit_selection'][1]) ? 1 : 0), 'fruit_banana' => escape(Input::get(['fruit_selection'][2]) ? 1 : 0), 'fruit_pear' => escape(Input::get(['fruit_selection'][3]) ? 1 : 0), 'fruit_kiwi' => escape(Input::get(['fruit_selection'][4]) ? 1 : 0) )); <input type="checkbox" name="fruit_selection[]" value="fruit_apple"> <input type="checkbox" name="fruit_selection[]" value="fruit_orange"> <input type="checkbox" name="fruit_selection[]" value="fruit_banana"> <input type="checkbox" name="fruit_selection[]" value="fruit_pear"> <input type="checkbox" name="fruit_selection[]" value="fruit_kiwi"> public function insert_preffruit($table, $fields = array()) { $keys = array_keys($fields); $values = ''; $x = 1; foreach($fields as $field) { $values .= '?'; if($x < count($fields)) { $values .= ', '; } $x++; } $sql = "INSERT INTO preffruit (`user_id`, `" . implode('`, `', $keys) . "`) VALUES (LAST_INSERT_ID(), {$values})"; if(!$this->query($sql, $fields)->error()) { return true; } return false; } Edited September 23, 2020 by ke-jo |