PHP - Horizontal Scaling (how To Keep Code Identical?)
So on a cloud computing platform such as AWS, how would one keep the /html folder in Apache identical?
I can FTP into one "instance" and modify code easily enough, but how would I push reversions to multiple servers at once?
It seems like such a simple question, but the answer eludes me.
Edited by arbitrageur, 20 November 2014 - 04:43 PM. Similar TutorialsWhen I asked about adding a watermark to a video, this was suggested: "when scaling it, I'd do h/5:w/5 (of the source video), then position would be w/20 (5% from the left) and h-h/3 (75% of the way down) When I asked about adding a watermark to a video, this was suggested: "when scaling it, I'd do h/5:w/5 (of the source video), then position would be w/20 (5% from the left) and h-h/3 (75% of the way down)" I'd like to try that, but I don't know how to integrate that into my existing working code: $ffmpegCommand =''.$ffmpeg_b.' -y -i '.$video_file_full_path.' -i '.$watermark_image_full_path.' -filter_complex "scale=426:-2, overlay=10:10, " -vcodec libx264 -preset '.$pt->config->convert_speed.' -crf 26 '.$video_output_full_path_240.' 2>&1'; I've looked at the ffmpeg documentation, but need additional assistance. any help is appreciated
When a file is uploaded, I wish to determine whether an existing identical file (regardless of what it is named or what extension it has) already exists and if so don't save the newly uploaded file but just point it to the existing one. My primary reason for doing so is not really to save hard drive space but to be able to manage duplicate documents. One option is to store a hash of the documents in the DB and when a new document is uploaded, query the DB to see if an identical hash exists. How certain can one be that two hashes will never be duplicated? Another option is to compare the byte stream. For this, I would first query the DB to see if a file with same size and media type exists, and then compare the document to all existing files which have that same criteria. Or many some other approach? Recommendations? Thanks
<?php error_reporting(E_ALL); ini_set('display_startup_errors', 1); ini_set('display_errors', 1); function compareFilesTest(string $file_a, string $file_b) { $time = microtime(true); display($time, $file_a, $file_b, 'compareFilesTest', compareFiles($file_a, $file_b)); } function compareFilesTest2(string $file_a, string $file_b) { $time = microtime(true); display($time, $file_a, $file_b, 'compareFilesTest2', identical($file_a, $file_b)); } function compareFilesHashTest(string $file_a, string $file_b, string $algo = 'md5') { $time = microtime(true); display($time, $file_a, $file_b, 'compareFilesHashTest', hash_file($algo, $file_a)===hash_file($algo, $file_b), $algo); } function display(float $time, string $file_a, string $file_b, string $test, bool $status, string $algorithm=null) { printf("\n%s\nFile1: %s\nFile2: %s\nStatus: %s\nTime (uS): %d\n", $test.($algorithm?" ($algorithm)":''), $file_a, $file_b, $status?'EQUAL':'NOT EQUAL', 1000000*(microtime(true) - $time)); } function compareFiles(string $file_a, string $file_b):bool { if (filesize($file_a) == filesize($file_b)) { $fp_a = fopen($file_a, 'rb'); $fp_b = fopen($file_b, 'rb'); while (!feof($fp_a) && ($b = fread($fp_a, 4096)) !== false) { $b_b = fread($fp_b, 4096); if ($b !== $b_b) { fclose($fp_a); fclose($fp_b); return false; } } fclose($fp_a); fclose($fp_b); return true; } return false; } function identical($fileOne, $fileTwo) { if (filetype($fileOne) !== filetype($fileTwo)) return false; if (filesize($fileOne) !== filesize($fileTwo)) return false; if (! $fp1 = fopen($fileOne, 'rb')) return false; if (! $fp2 = fopen($fileTwo, 'rb')) { fclose($fp1); return false; } $same = true; while (! feof($fp1) and ! feof($fp2)) if (fread($fp1, 4096) !== fread($fp2, 4096)) { $same = false; break; } if (feof($fp1) !== feof($fp2)) $same = false; fclose($fp1); fclose($fp2); return $same; } $path = __DIR__.'/test_documents/'; //print_r(hash_algos()); compareFilesHashTest($path.'602a9c07af00c_IMG_1225.jpg', $path.'602a9c07af00c_IMG_1225.jpg'); compareFilesHashTest($path.'602a9c07af00c_IMG_1225.jpg', $path.'602a9c1c96440_MasterFormat-2016.pdf'); compareFilesHashTest($path.'602a9c07af00c_IMG_1225.jpg', $path.'x602a9c07af00c_IMG_1225.jpg'); compareFilesHashTest($path.'602a9c07af00c_IMG_1225.jpg', $path.'602a9c07af00c_IMG_1225.jpgx'); compareFilesHashTest($path.'file1.txt', $path.'file2.md'); compareFilesHashTest($path.'file1.txt', $path.'file3.txt'); compareFilesHashTest($path.'602a9c07af00c_IMG_1225.jpg', $path.'602a9c07af00c_IMG_1225.jpg', 'sha256'); compareFilesHashTest($path.'602a9c07af00c_IMG_1225.jpg', $path.'602a9c1c96440_MasterFormat-2016.pdf', 'sha256'); compareFilesHashTest($path.'602a9c07af00c_IMG_1225.jpg', $path.'x602a9c07af00c_IMG_1225.jpg', 'sha256'); compareFilesHashTest($path.'602a9c07af00c_IMG_1225.jpg', $path.'602a9c07af00c_IMG_1225.jpgx', 'sha256'); compareFilesHashTest($path.'file1.txt', $path.'file2.md', 'sha256'); compareFilesHashTest($path.'file1.txt', $path.'file3.txt', 'sha256'); compareFilesTest($path.'602a9c07af00c_IMG_1225.jpg', $path.'602a9c07af00c_IMG_1225.jpg'); compareFilesTest($path.'602a9c07af00c_IMG_1225.jpg', $path.'602a9c1c96440_MasterFormat-2016.pdf'); compareFilesTest($path.'602a9c07af00c_IMG_1225.jpg', $path.'x602a9c07af00c_IMG_1225.jpg'); compareFilesTest($path.'602a9c07af00c_IMG_1225.jpg', $path.'602a9c07af00c_IMG_1225.jpgx'); compareFilesTest($path.'file1.txt', $path.'file2.md'); compareFilesTest($path.'file1.txt', $path.'file3.txt'); compareFilesTest2($path.'602a9c07af00c_IMG_1225.jpg', $path.'602a9c07af00c_IMG_1225.jpg'); compareFilesTest2($path.'602a9c07af00c_IMG_1225.jpg', $path.'602a9c1c96440_MasterFormat-2016.pdf'); compareFilesTest2($path.'602a9c07af00c_IMG_1225.jpg', $path.'x602a9c07af00c_IMG_1225.jpg'); compareFilesTest2($path.'602a9c07af00c_IMG_1225.jpg', $path.'602a9c07af00c_IMG_1225.jpgx'); compareFilesTest2($path.'file1.txt', $path.'file2.md'); compareFilesTest2($path.'file1.txt', $path.'file3.txt');
Ok, so I have grabbed a free template and attempted to put a dynamic table into one of the div's. I've got it to work on on my index.php, but I copied and pasted the entire code into member2.php and only changed the query and altered the table just a little bit For some reason though my table doesn't show up on the member2.php even though 90% of the code is the same. Here are the pages and codes... http://www.royalfamilyhosting.com/test/index.php <div id="layoutBodyContent"> <h1>Aces Guild Donations Page </h1> <h2>Are you on top of your game? WE are!</h2> <?PHP require_once('./mylib.php'); $rank = 1; $olddate = strtotime(date("Y-m-d")); $newdate; $datecounter = 1; //connects to db dbconnect(); $query="SELECT name, date, SUM(amount) as total_money, SUM(bricks) as total_bricks FROM Aces_Donations GROUP BY Name ORDER BY total_money DESC, total_bricks DESC"; $result=mysql_query($query); //Opens the table echo "<table border = '3' width = 40% bgcolor=#A85045><caption><center>30 Day Rankings".'</center></caption>'; //Loop to run until eof while($row = mysql_fetch_array($result)){ //turns date into a comparable string $newdate = strtotime($row['date']); /*checks to see if date of new record matches date of previous record. If dates dont match the table is closed and a new table is opened for the new date. Rank is reset to reflect rankings for each specific date*/ if($newdate !== $olddate){ $olddate = $newdate; $datetracker++; if($datetracker == 30){ echo "<center><tr><td alignment = 'center'>".$rank."</td> <td alignment = 'center'>".$row['name']. "</td><td alignment = 'center'>". $row['total_money']."</td><td alignment= 'center'>".$row['total_bricks']."</tr></table></center>"; break; } } echo "<center><tr><td alignment = 'center'>".$rank."</td> <td alignment = 'center'>".$row['name']. "</td><td alignment = 'center'>". $row['total_money']."</td><td alignment= 'center'>".$row['total_bricks'].'</td></tr>'; echo '<br />'; $rank++; } echo '</table>'; ?> <br /><br /></p> </div> http://www.royalfamilyhosting.com/test/member2.php?member=Zneve08 <div id="layoutBodyContent"> <h1>Aces Guild Donations Page </h1> <h2>Are you on top of your game? WE are!</h2> <?PHP require_once('./mylib.php'); $membername = $_GET['member']; $rank = 1; $olddate = strtotime(date("Y-m-d")); $newdate; $datecounter = 1; //connects to db dbconnect(); $query = sprintf("SELECT * FROM `Aces_Donations` WHERE `name` = '%s'", $membername); //sets the results to a variable $result = mysql_query($query) or die(mysql_error()); //opens table, sets width, color, border and headers echo '<table bgcolor=#A85045 border = "3" width = 40%>'; echo "<tr><th alignment = 'center'>Member</th> <th alignment = 'center'>Amount</th><th alignment = 'center'>Date</th></tr>"; while($row = mysql_fetch_array($result)){ echo "<center><tr><td alignment = 'center'>".$row['name']. "</td><td alignment = 'center'>". $row['amount']."</td><td alignment = 'center'>".$row['date']."</td></tr></center>"; var_dump ($row['name']); var_dump ($row['amount']); echo "<br />"; } echo '</center></table>'; ?> <br /><br /></p> </div> I'm dying here and would love even shot in the dark at this point. The php code on member2.php works just fine when executed on its own page, so I don't really understand how this is happening. I put the var_dump in there just to make sure the data was being retrieved from the database, but the table should be positioned where the var_dump displays on the page I'm surely doing something wrong here, but I just cannot see it. Any assistance will be greatly appreciated. In a login script I read the following two variables from an SQL database. Both fields are defined as int. $this->ScheduleA = $rs->fetchCol('ScheduleA'); $this->SchedConst = $rs->fetchCol('SchedConstant'); Later, I retrieve these variables and attempt to compare them. $schA = $sess['ScheduleA']; $schC = $sess['SchedConst']; if ($schA == $schC) { require('Testing.php'); } else { require('NotAllowed.php'); } They never compare as equal, even though they contain the same value. What, pray tell, am I missing? Trying to create a very simple API script sending XML data. When I send the "hard coded" XML, it works perfectly. When I add a form to supply the data for the XML, I get a 500 Internal Server error. Have tried it on two different servers. No error in the logs. Stumped. Examples below are VERY simplified (and obviously won't do anything as-is) to show what I'm dealing with. This one works fine: <?php $xml = "<Order><UserId>foo</UserId><Password>foo</Password><Mode>Test</Mode><Name>Charles R. Hodges</Name>"; $xml .= "</Order>"; $url = 'http://sitename.com'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $xml = simplexml_load_string($response); print_r($xml); ?> And then I use this one and all heck breaks loose with the 500 Internal Error: <?php if (isset($_POST['submit'])) { $xml = "<Order><UserId>foo</UserId><Password>foo</Password><Mode>Test</Mode><Name>{$_POST['name']}</Name>"; $xml .= "</Order>"; $url = 'http://sitename.com'; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch); $xml = simplexml_load_string($response); print_r($xml); exit; } ?> <html>... etc <form method="post" action=""> Name: <input type="text" name="name" /> <p><input type="submit" name="submit" "Add to XML string and send" /> </form> ?>
Hello, Experts! Need you advice. Here is the code: <?php if ($var == "") { echo "text"; } if ($var == "*") { echo "text"; } else if ($var != "") { $query = "SELECT * FROM bd WHERE ....."; $data = mysql_query($query) or die(mysql_error()); $anymatches=mysql_num_rows($data); if ($anymatches != 0) { echo "text"; while($row = mysql_fetch_array($data)) { echo "text"; } } if ($anymatches == 0) { $query2 = "SELECT * FROM bd WHERE....."; $data2 = mysql_query($query2) or die(mysql_error()); $anymatches2=mysql_num_rows($data2); if ($anymatches2 != 0) { echo "text" else { mysql_query("INSERT INTO notfound (notfound) VALUES ('$var')") or die(mysql_error()); } } } ?> The last line adds two identical lines to my table. Do I run it twice? Thanks in advance! Well, the title says it all, I do have a class named Database and one Users with multiple methods (code below). When i do try to use one user method (find_all) it returns 2 identical results from the database (and there is only one record in the DB). I tried to spot some mistake in the code but i couldn't find it, if you find something please tell... Database Class: Code: [Select] <?php /** * Class Name: MySQLDatabase * * Most of the methods in this class are * database-neutral methods for code reusability. * * Author: hisk */ require_once("config.php"); class MySQLDatabase { private $connection; private $last_query; private $magic_quotes_active; private $real_escape_string; function __construct() { $this->open_connection(); $this->magic_quotes_active = get_magic_quotes_gpc(); $this->real_escape_string = function_exists("mysql_real_escape_string"); } public function open_connection() { $this->connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS); if(!$this->connection) { die("Database connection failed: " . mysql_error()); } else { $db_select = mysql_select_db(DB_NAME, $this->connection); if (!$db_select) { die("Database selection failed: " . mysql_error()); } } } public function close_connection() { if(isset($this->connection)) { mysql_close($this->connection); unset($this->connection); } } public function query($sql) { $this->last_query = $sql; $result = mysql_query($sql, $this->connection); $this->confirm_query($result); return $result; } private function confirm_query($result) { // usable only in query() function (private) if(!$result) { echo "DB Query Failed: " . mysql_error(); // The last query that might got us the problem echo "Last Query Was: " . $this->last_query; } } // agnostic public function num_rows($result) { return mysql_num_rows($result); } public function affected_rows($result) { return mysql_affected_rows($result); } public function insert_id($result) { return mysql_insert_id($result); } public function fetch_array($result) { return mysql_fetch_array($result); } public function escape_value($value) { if($this->real_escape_string) { // undo any magic quote effect so mysql_real_esc_str can work if($this->magic_quotes_active) { $value = stripslashes($value);} $value = mysql_real_escape_string($value); } else { if (!$this->magic_quotes_active) { $value = addslashes($value); } } return $value; } } $database = new MySQLDatabase(); ?> User Class: Code: [Select] <?php // smart to include the database class require_once("database.php"); class User { public static function find_by_id($id=0) { global $database; $result_set = self::find_by_sql("SELECT * FROM users WHERE id = {$id}"); $result = $database->fetch_array($result_set); return $result; } public static function find_all() { global $database; $result_set = self::find_by_sql("SELECT * FROM users"); return $result_set; } public static function find_by_sql($sql="") { global $database; $result_set = $database->query($sql); return $result_set; } } ?> TEST FILE: Code: [Select] <?php require_once("../includes/database.php"); require_once("../includes/user.php"); $users = User::find_all(); $result = $database->fetch_array($users); foreach($result as $user) { echo "<pre>" . $user . "</pre>"; } ?> I am building online dictionary with php. The following code allows the user to search a word and display the definition results from the database. The problem is the user has to input the identical words only. If the words are not exactly similar to the database words it returns error message. But in this case I need it to give a suggestion along with the error message based on the few beginning words of the submitted word. eg. if the user type a word "suggestion", and the word "suggestion" is not available in the database .... instead of just the error message to also search and include other stored data closer to the submitted word ... like "TRY the word SUGGEST". can any one help me on this please. Thank you in advance. here is the code Code: [Select] <?php $script = $_SERVER['PHP_SELF']; if(isset($_POST['sbm']) && isset($_POST['word']) ) { submited(); } else { show_form(); } function show_form() { ?> <p><center> Type <span style='font-weight:bold;'>ENGLISH</span> word Only! <span style='font-weight:bold;'>SPELL IT CORRECTLY!!!.</span></center></P> <p><center>Search</center></p> <center><form name=frm method=POST action="<?php echo $script ?>"> <p><input type=text name="word"><br /></p> <p><input type=submit name="sbm" value="Submit"> </form> </center></p> <?php } function submited() { require("dbconn.inc"); $word=$_POST['word']; $sql="select * from words where eng like '".mysql_real_escape_string($word)."'"; $result=mysql_query($sql,$link); // I assume $link is defined in dbconn.inc if(@mysql_num_rows($result)!=0) { $rows=mysql_fetch_array($result); $am=$rows["am"]; echo("<center>The Word <h1><b>$word</b></h1> in Am is : <h1><b>$am </b></h1><br></center>"); } else { echo("<center><span style='font-weight:bold;color:#FF0000;'>Could not find it! Check the spelling and try again !!</span></center>"); } // The connection will close automatically since // this is near the end of the script. mysql_close($link); show_form(); } ?> Hi there I have an image in a directory, that I need to resize on the fly but has to be a background in a div with a max width. I have to determine the correct height according to this max width. So I sucessfully I have accomplished this, but its not scaling its jsut giving me the top left corner according to my height width properties. Here is my working code to grab height and width: Code: [Select] $img_path = $CONFIG["full_url"].$CONFIG["upload_folder"].ReadDB($News["image"]); $max_width = 110; $max_height = 400; list($width, $height) = getimagesize($img_path); $ratioh = $max_height/$height; $ratiow = $max_width/$width; $ratio = min($ratioh, $ratiow); // New dimensions $mywidth = intval($ratio*$width); $myheight = intval($ratio*$height); Now using those I need to resize the image proper to get it centered up. I dont really want to save the file I just want to display it. Is this possible? My attempts have garnered a bunch of crazy characters on screen and not an image. Here is the code I added to the end: Code: [Select] // Resample $image_p = imagecreatetruecolor($mywidth, $myheight); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $mywidth, $myheight, $width, $height); // Output imagejpeg($image_p, null, 100); Then Im using it on the page like so: Code: [Select] <div class="theimg" style="display:block; width:<?php echo $mywidth;?>px; height:<?php echo $myheight;?>px; background-image:url(<?php echo $image_p; ?>); background-repeat: no-repeat;"/> </div> and heres what I get :/ What am I doing wrong?? The image is not displaying inside its rounded corner border and we have crazy crap on top. Thanks in advance Ok, first off CSS is definitely not my strong suit so bear with me here. This is my code:
<style media="screen" type="text/css"> /* <!-- */ .clear{ clear:both; } #grid{ width: 100%; } .grid-element{ width:33%; float:left; } a.clickable-div { display: block; height: 100%; width: 100%; text-decoration: none; } .img { height:auto; width:inherit; max-height:100%; max-width:100%; } .button { color: #900; font-weight: bold; font-size: 150%; text-transform: uppercase; display: block; width: 50%; } /* --> */ </style> <div id="grid"><div class="grid-element" align="center"> <img src="images/light_offline.png" class="img"> <p><h1>Hue Lamp 1 </h1></div><div class="grid-element" align="center"> <a href="action.php?light=2&state=false"> <img src="images/light_off.png" class="img"></a> <p><h1>Hue Lamp 2 </h1></div><div class="grid-element" align="center"> <a href="action.php?light=3&state=false"> <img src="images/light_off.png" class="img"></a> <p><h1>Hue Lamp 3 </h1></div></div><p> <div align="center"> <form method="POST" action="action.php"> <input type="hidden" name="scene" value="02b12e930-off-0"> <input type="submit" value="Scene 1" class="button"> </form> <p><form method="POST" action="action.php"> <input type="hidden" name="off"> <input type="submit" value="All Off" class="button"> </form> </div>This is the browser output. A couple things are wrong: 1. Why aren't the images scaling so they are all the same size? I assigned the same CSS class to each of the images but they are all appearing differently. The original images are all the same size. 2. Why are my buttons in the far right corner? I want to have them centered below the images so as to prevent the horizontal scroll bar, which I hate. Attached Files output.png 232.09KB 0 downloads how can I basically put a horizontal rule between each entry on this code.......? Code: [Select] <?php if (isset($_POST['submitted'])) { include('connect1.php'); $category = $_POST['category']; $criteria = $_POST['criteria'] ; $query = "SELECT * FROM members WHERE $category LIKE '%".$criteria."%'"; $result = mysqli_query($dbcon, $query) or die('error getting data'); $num_rows = mysqli_num_rows($result); echo "$num_rows results found"; echo "<table width=\"896\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; echo "<tr bgcolor=\"#F7E496\"><td bgcolor=\"#F7E496\"><strong>User ID</strong></td> <td bgcolor=\"#F7E496\"><strong>Name</strong></td> <td bgcolor=\"#F7E496\"><strong>email</strong></td> <td bgcolor=\"#F7E496\"><strong>City</strong></td><td bgclor=\"#F7E496\"></td></tr>"; while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo "<tr><td>"; echo $row['userid']; echo "</td><td>"; echo $row['name']; echo "</td><td>"; echo $row['email']; echo "</td><td>"; echo $row['city']; echo "</td><td>"; echo "<form action='admin.php' method='get'><input type='hidden' name='edit'><input type='hidden' name='id' value='{$row['userid']}'><INPUT TYPE='submit' name='submit' VALUE='Edit'></form>\n"; echo "</td><td>"; echo "<form action='delete_account.php' method='get'><input type='hidden' name='userid' value='{$row['userid']}'><INPUT TYPE='submit' name='submit' VALUE='Delete'></form>\n"; echo "</td></tr>"; } echo "</table>"; } ?> basically each time the code is shown is an entry...... Hello all , I have a small issue in regards to allowing for my results to be placed horizontally across the page instead of vertically. I find the code i have posted works well when it comes to finding and displaying my information as requested (vertically) , but i am having trouble with finding a way to display the results horizontally. I know i need a way to identify each result?in order to echo it out in between <td> </td> , but i am still unsure , a point in the right direction would be good as i am struggling to find a way thankyou. $title = $runrows['title']; $desc = $runrows['description']; $url = $runrows['url']; $img = $runrows['image']; $id = $runrows['id']; echo " <table width='100px'> <h4><a href='http://$url'><b>$title</b></a><br /> $desc<br> <font color='00CC00'>$url</font></h4> <tr><img src='data:image/png;base64,$img' /> $id "; I have a code that outputs a table but right now each result is under the next ex: 1 2 3 1 2 3 I would like them to be horizontal ex: 123 123 the part of the code the controls the table is: Code: [Select] echo "<table border=0 cellspacing=0 cellpadding=0>"; foreach($xml->result->rowset->row AS $name) { echo "<tr>"; echo "<td><img src=/Character/".$name['characterID']."_200.jpg></td></tr>"; echo "<tr><td>".ucwords($name['name'])."</td></tr>"; echo "<tr><td>".ucwords($name['corporationName'])."</td>"; echo "</tr>"; } echo "</table>"; How can I make a CSS3 menu like the menu placed in below website? Welcome :: Bardia Textile Co. I mean top menu that has fancy effect. please at least tell me the name of these kinds of menu in the way I could find some more examples. Hi, Mary Christmas My result of mysql database is LIMIT 8; now i have to retrieve and show this to two Horizontal columns As each columns 4 result. how to generate this Without tables!! only with DIV or UL/LI list . Thanks I have a table called parties with 3 fields - partyid, partyname, linkid. For any linkid there will be a number of parties somewhere between 2 and 10. I can get a vertical list but have a couple of issues which I can't fix: I want to have a page that displays the list of partynames (alphabetically) horizontally rather than vertically within a piece of text. For example, "The parties linked to you are Party1, Party2, Party3" Also, ideally, I would like the word 'and' before the last Party name so, using the above example, I would get "The parties linked to you are Party1, Party2 and Party3" I have no idea how to do this or if it can be done. Any ideas would be VERY gratefully received. Thanks I have the following code in html: <html> <head> <script type="text/javascript"> <!-- function delayer(){ window.location = "http://VARIABLEVALUE.mysite.com" } //--> </script> <title>Redirecting ...</title> </head> <body onLoad="setTimeout('delayer()', 1000)"> <script type="text/javascript"> var sc_project=71304545; var sc_invisible=1; var sc_security="9c433fretre"; </script> <script type="text/javascript" src="http://www.statcounter.com/counter/counter.js"></script><noscript> <div class="statcounter"><a title="vBulletin statistics" href="http://statcounter.com/vbulletin/" target="_blank"><img class="statcounter" src="http://c.statcounter.com/71304545/0/9c433fretre/1/" alt="vBulletin statistics" ></a></div></noscript> </body> </html> Is a basic html webpage with a timer redirect script and a stascounter code. I know a bit about html and javascript, but almost nothing about php. My question is: How a can convert this html code into a php file, in order to send a variable value using GET Method and display this variable value inside the javascript code where says VARIABLEVALUE. Thanks in adavance for your help. Hi, I have some code which displays my blog post in a foreach loop, and I want to add some social sharing code(FB like button, share on Twitter etc.), but the problem is the way I have my code now, creates 3 instances of the sharing buttons, but if you like one post, all three are liked and any thing you do affects all of the blog post. How can I fix this? <?php include ("includes/includes.php"); $blogPosts = GetBlogPosts(); foreach ($blogPosts as $post) { echo "<div class='post'>"; echo "<h2>" . $post->title . "</h2>"; echo "<p class='postnote'>" . $post->post . "</p"; echo "<span class='footer'>Posted By: " . $post->author . "</span>"; echo "<span class='footer'>Posted On: " . $post->datePosted . "</span>"; echo "<span class='footer'>Tags: " . $post->tags . "</span>"; echo ' <div class="addthis_toolbox addthis_default_style "> <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a> <a class="addthis_button_tweet"></a> <a class="addthis_counter addthis_pill_style"></a> </div> <script type="text/javascript">var addthis_config = {"data_track_clickback":true};</script> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=webguync"></script>'; echo "</div>"; } ?> Advance thank you. Can you help please. The error..... Warning: mysql_fetch_assoc() expects parameter 1 to be resource, string given in C:\wamp\www\test_dabase.php on line 24 code. Code: [Select] <?php //database connection. $DB = mysql_connect("localhost","root") or die(mysql_error()); if($DB){ //database name. $DB_NAME="mysql"; //select database and name. $CON=mysql_select_db($DB_NAME,$DB)or die(mysql_error()."\nPlease change database name"); // if connection. }if($CON){ //show tables. $mysql_show="SHOW TABLES"; //select show and show. $mysql_select2="mysql_query(".$mysql_show.") or die(mysql_error())"; } //if allowed to show. if($mysql_select2){ //while it and while($data=mysql_fetch_assoc($mysql_select2)){ //show it. echo $data; } } ?> |