PHP - Differences In Servers?
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 Similar TutorialsI 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; } ?> 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. 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! 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. 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! 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 ? 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" ?> 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 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. 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 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 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.
Hi, I have 2 db fields with timestamp datatype (ClockingInDate and ClockingOutDate) and i am trying to get the difference between them then update the new db called duration with float datatype field. PHP: if (isset($_POST["clockout"])){ $result3=mysqli_query($con, "select * from attendance_records where OracleID='$session_id'")or die('Error In Session'); $row3=mysqli_fetch_array($result3); $end_date = $row3['ClockingOutDate']; $startdate = $row3['ClockingInDate']; $diff = strtotime($end_date) - strtotime($startdate); $fullDays = floor($diff/(60*60*24)); $fullHours = floor(($diff-($fullDays*60*60*24))/(60*60)); $fullMinutes = floor(($diff-($fullDays*60*60*24)-($fullHours*60*60))/60); $duration = $fullMinutes; $query3=mysqli_query($con, "update attendance_records set Duration = '$duration' where OracleID='$session_id' and isdone='$isdone'")or die('Error In Session'); header('location:index.php'); }
* come to think of that again, i always get zero, is it because it never reaches days in my program! I am using this for attendance system so only hours and minutes are used. Please help. Edited March 13, 2020 by ramiwahdanthoughts After being forced to have the server upgraded I am having problems with my 'reset password' pages. What I wondered is, has there been any changes to PHP or MySQL between these versions ? The PHP version was 5.2.9 and is now 5.2.14 The MySQL version was Client API version 5.0.45 and is now Client API version 5.0.90 Some one clicks a link like this. www.site.com/resetpw.php?pwr=a1b2c3d4e5f6 the code would be a 32 char hash that is checked against the database, but my code now (which was never changed before or after the server change) seems to find the database line and update it but show the message that it was invalid ? instead of showing the the message, your password will be sent to you after changing the DB does anyone have any ideas ? Code: [Select] <?php include('includes/connection.php'); include('includes/functions.php'); date_default_timezone_set('Europe/London'); if(isset($_POST['reset']) && trim($_POST['reset']) == 'Reset') { $email = mysql_real_escape_string($_POST['email']); $checkVerify = mysql_query("SELECT account_id FROM customers WHERE email='$email' AND verified='No' LIMIT 1"); $checkBanned = mysql_query("SELECT account_id FROM customers WHERE email='$email' AND suspended='Yes' LIMIT 1"); if(!$email) { $thisError = 'Please enter your e-mail address.'; } else if(!$password) { $thisError = 'Please enter your password.'; } else if(mysql_num_rows($checkVerify)) { $thisError = 'Your account has not been approved by an Admin.'; } else if(mysql_num_rows($checkBanned)) { $thisError = 'Your account has been suspended by an Admin.'; } else { $password = md5($password); $checkAccount = mysql_query("SELECT account_id FROM customers WHERE email='$email' AND password='$password' LIMIT 1"); if(mysql_num_rows($checkAccount)) { $_SESSION['FM_user'] = $email; header('Location: members.php'); exit; } else { $thisError = 'Your e-mail address and/or password is incorrect.'; } } } include('includes/header.php'); ?> <body> <div class="headerBar"> <?php include('includes/navigation.php');?> </div> <?php headerText(); ?> <div class="content"> <div class="widthLimiter contentStyle"> <div class="formWrapper"> <?php if(isset($thisError)) { echo '<div class="errorDiv">',$thisError,'</div>'; } ?> <?php if(isset($thisSuccess)) { echo '<div class="successDiv">',$thisSuccess,'</div>'; } ?> <span class="subHeader">Initiate Password Reset</span> <?php // include("sendmail2010.php"); $securitycode = ($_GET['pwr']); //echo("53:security:".$securitycode.":<br>"); if ($securitycode != "") { $sql = "SELECT * FROM `customers` WHERE `changeofpasswordcode` = '".mysql_real_escape_string($securitycode)."' LIMIT 1"; //echo("54:sql:".$sql.":<br>"); $res = mysql_query($sql) or die(mysql_error()); //echo("57:<br>"); if (mysql_num_rows($res) != 0) { //echo("59:sql:".$sql.":<br>"); $customerName = mysql_result($res, 0 ,'fullname'); $email = mysql_result($res, 0 ,'email'); $yourpasswordtologin = CreateNewPassword(); $format = 'Y-m-d H:i:s'; $date = date( $format ); $sql = "UPDATE `customers` SET `password` = '" . md5($yourpasswordtologin) . "', `password2` = '" . mysql_real_escape_string($yourpasswordtologin) . "', `changeofpasswordcode` = '', `newpasswordrequestedon` = '" . $date . "' WHERE `changeofpasswordcode` = '" . mysql_real_escape_string($securitycode) . "' LIMIT 1"; //echo("65:sql:".$sql.":<br>"); $res = mysql_query($sql) or die(mysql_error()); $_SESSION['customerName'] = $customerName; $_SESSION['customerEmail'] = $email; $_SESSION['generatePass'] = $yourpasswordtologin; //echo("send email"); $sendemailnow = createEmailSend('newPassword', 'Your new password', 'customer'); //echo("email sent ".$sendemailnow); ?><div style="margin: 30px;">Thank you for completing your password reset process.<br><br>An email with a randomly generated password has been sent to your email address, please check your email account for this email as you will need this password to access your <?=$_SESSION['siteName'];?> account.<br><br><strong><em>Please check your 'spam folder' in case our emails are showing up there.</em></strong><br><br>You may now <a href="<?=$_SESSION['webAddress'];?>">sign in</a> to your account.</div><?php //echo("72:end of IF send email<br>"); } else { //echo("74 bad link<br>"); ?><div style="margin: 20px;">Sorry the link you clicked is and old password reset link or is not valid, please delete the email.<br><br>If you were trying to reset your password, please click the<br>'Member Login' link on our site and then click the 'Reset Password' link.</div><?php //echo("end of IF bad<br>"); } //echo("78:end of first IF<br>"); } ?> </div> </div> </div> <?php include('includes/footer.php');?> </body> </html> With a prior version of Php, this code was acceptable.
$query = sqlsrv_query($conn, $sql);if ($query === false){ exit("<pre>".print_r(sqlsrv_errors(), true));}while ($row = sqlsrv_fetch_array($query)){ $sumUsageKWH += $row[totalUsage];}sqlsrv_free_stmt($query);?>Now, with php 5.6.3, I have to add a couple of things. $query = sqlsrv_query($conn, $sql);if ($query === false){ exit("<pre>".print_r(sqlsrv_errors(), true));}while ($row = sqlsrv_fetch_array($query)){ $sumUsageKWH += $row['totalUsage'];}sqlsrv_free_stmt($query);?>due to an error prompt. Once I make the corrections, I have a new errors all over the place. Is there a difference in defining a variable with 5.6.3? Edited by Butterbean, 10 January 2015 - 01:49 PM. I am making a php/ajax chat, when a post is sent to the chat, a timestamp using mktime() is stored in the database to show when that post was sent. My concern is that I am from England and my timestamp is GMT +0. Will people from different locations around the world see the wrong times that other users post into the chat? If so what do I need to do to make this work ideally? Thanks |