PHP - Face Book Share Button On My Php Page Selects Wrong Image
Hi,
I have a page whihc gets Daily motion URL from another page and also location of Image.
I have Face book share button on this page and want to show my inage while trying to share on FB.
unfortunatley face book picks something wrong , and I use Open Graph Debug library then temporarily this picture issue gets resolved but it re-occures again if another URL is selected for sharing purpose.
Code written in header of my page:
<meta property="og:title" content="Greate Web SIte"/>
<meta property ="og:url" content="http://www.MySIte.co...howMovie.php"/> <meta property ="og:type" content="website"/> <meta property="og:image:width" content="200" /> <meta property="og:image:height" content="200" /> <?php $selectedImage=$_GET['selectedImg']; // this param is passed from qry string whihc is sent by a previos page, I want to change this param every time parent page sends a request of new image. $ImageAddress='http://www.mySIte.com/'.$selectedImage; //creating URL of image , if i paste this URL in browser , image is fetched successfully. echo '<meta property="og:image" content="'.$ImageAddress.'"/>'; ?> <meta property="og:site_name" content="my Heading"/> <meta property="og:description" content="Bla Bla bla."/> Following is the java script that I have pasted under body tag: <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> following is button for FB sha echo '<div class="fb-post" data-href="'.$pageURL.'" data-width="500"></div>'; // URL that is passed as qry stirng are passed here. kindly do let me know that how can I display the exact image on every attelp to share something. Similar TutorialsHi guys new to this site and need some help. Im using PHP 5 in easy steps by Mike McGrath, currently creating the register and login scripts for my website. Ive manged to do the register script fine, it drops new user details into the MySQL database fine, however the login script gives the following error when loggin in: Parse error: syntax error, unexpected T_VARIABLE in /hermes/bosweb25a/b109/ipg.removalspacecom/removal space.com/loginscript.php on line 15 I copied the script word-for-word, letter-for-letter, checked and re-checked. I would like to ask you guys if you see something i dont? Here is the script: Code: [Select] <?php $username = $_POST['username']; $password = $_POST['password']; $self = $_SERVER['PHP_SELF']; $referer = $_SERVER['HTTP_REFERER']; #if either form field is empty return to the log-in page if( ( !$username ) or (!$paswword ) ) { header( "Location:$referer" ); exit(); } #connect to MySQL $conn = @mysql_connect ( "removalspacecom.ipagemysql.com", "removal", "123" ) or die("Could not connect" ); #select the specified database $rs = @mysql_select_db( "removal1", $conn ) or die( "Could not select database" ) #create sql query $sql="select * from users where user_name=\"$username\" and password = password( \"$password\" )"; #execute query $rs = myslq_query( $sql, $conn ) or die( "Could not execute query" ); #get number of rows that match username and password $num = mysql_numrows( $rs ); #if there is a match the log-in is authenticated if( $num != 0 ) { $msg = "Welcome $username - your log-in was sucessfull!"; } else #or return to the log-in page { header( "location:$referer" ); exit(); } ?> <html> <head><title>Log-in Authenticated</title></head> <body> <?php echo( $msg ); ?> </body> </html> the error is coming from line 15, the sql query line? why would there be an error from the advisory book? please help me as im stuck on this one. Thanks a lot for any help i get. MOD EDIT: code tags added. Hello everyone, I'm new to php/mysql and am trying to setup a basic online address book script that has come straight from a tutorial book. I've created the tables etc and have the correct login details. I thought that was it but somehow I keep getting 'no database selected' in the top-left of the browser. Below is the file for opening the connection, is this a job for mysql_select_db and if so where would it need to go? i've been playing around but just cant get rid of that damn message, any help is massively appreciated : (login details hidden for security) <?php function doDB() { global $mysqli; //server and database connection $mysqli = mysqli_connect("serveraddress", "user", "pass"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } } ?> Thanks for having a look! Can somebody please explain how to properly add a Facebook Share button to my site?
It's not simply a matter of generating the button and pasting the code into my pages; in order to ensure that the right information is shared, I also have to add Open Graph metatags.
But the thing that's confusing me is that one of the required Open Graph metatags is this:
<meta property="fb:app_id" content="APP_ID_NUMBER" />Questions 1) Does this mean that I have to register as an app builder before I can add the Share button? If so, why doesn't Facebook say so on the Share button page? 2) When generating the Share button, I am asked for the "URL to share". Does this mean that I have to generate a different Share button for each page? Surely not. 3) I use ShareThis at the moment. Does ShareThis work with Facebook Insights? I am trying to implement the method described in this post: http://www.addthis.com/forum/viewtopic.php?f=4&t=24637 to get my Addthis button to act the way I need it to. I have posted on the site, but have gotten no response. I cannot get it to work. Can anybody have a look at the code below and see if they can help? Thanks The PHP I need to modify is: <?php defined('C5_EXECUTE') or die(_("Access Denied.")); $html = Loader::helper('html'); $uh = Loader::helper('concrete/urls'); $bt = BlockType::getByHandle('news_list'); global $c; $rss_address = $controller->getRssUrl().'?ctID='.$ctID.'&bID='.$bID ; if (isset($_GET['pageno'])) { $pageno = $_GET['pageno']; } else { $pageno = 1; } // if ?> <div class="newsflash1"> <div class="headtitle1"> <?php echo $rssTitle ?> </div> <?php if (!function_exists('newslistParse')) { function newslistParse($url,$thumbnail,$thumbwidth,$time,$content,$title,$date){ //###################################################################################// //here we lay out they way the page looks, html with all our vars fed to it // //this is the content that displays. it is recommended not to edit anything beyond // //the content parse. Feel free to structure and re-arrange any element and adjust // //CSS as desired. // // available vars: $url,$thumbnail,$thumbwidth,$time,$content,$title,$date // //###################################################################################// ?> <div class="newsflashcontain1"> <div class="title1"><h3><?php echo $title; ?></h3> </div> <div class="time1"> <?php echo $date; ?></div> <div class="description1"><?php echo $content;?></div> <div class="addthis_toolbox addthis_default_style"> <a class="addthis_button" addthis:title="Title goes here" addthis:description="Check their site!" addthis:url="http://www.davidcunniffe.com/test3/index.php?cID=69" href="http://www.addthis.com/bookmark.php?v=250&username=dcunniffe"/> <a class="addthis_button_facebook"></a> <a class="addthis_button_twitter"></a> <a class="addthis_button_favorites"></a> <a class="addthis_button_email"></a> <a class="addthis_button_print"></a> <a class="addthis_button_facebook_like"></a> <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=dcunniffe"></script> </div> </div> <?php //#####################################################################################// //this is the end of the recommended content area. please do not edit below this line // //#####################################################################################// } } $db = Loader::db(); //go grab the posts, check if they are current, return only current posts Loader::model('newzy','simplenews'); $news = NewsCheck::getCurrentBlocks($ctID,$ordering); //count the number of current posts returned $pcount = count($news); //if no events are returned, then we display a user defined message if($pcount==0){ echo $nonelistmsg; } //now calc the last page $lastpage = ceil($pcount/$num); //set the current page min max keys -1 as array key's start @ 0 $sKey = $num * ($pageno-1) ; $eKey = ($num * ($pageno-1)) + ($num-1) ; //take each current post and treat it like a query, for each one do X foreach($news as $key => $row){ //check for external URL, if none, rout to parent page if(!empty($row['urlLink'])){ $url = $row['urlLink']; }else{ $url = $controller->grabURL($row['cParentID']); } //check if thumbnail is there, if so get it, if not, null if($row['graphic']>0){ $thumbnail = $controller->getThumbnail($row['graphic']); }else{ $thumbnail = NULL; } //set vars $time = $controller->replaceTimeString($row['nbID']); $date = date('l, jS F, Y'); $title = $row['title']; $content = $controller->translateFrom($row['content']); //$content = $controller->translateFrom($row['content']); //if truncation is enabled if($truncateSummaries == 1){ if (strlen($content) >= $truncateChars){ //truncate to suplied truncation value //$content = substr($content,0,$truncateChars).'.....'; $content = wordwrap($content, $truncateChars); $content = substr($content, 0, strpos($content, "\n")).'.....'; } } //check if paging is enabled if($isPaged){ //check to make sure the array key is within the range if($key >= $sKey && $key <= $eKey){ newslistParse($url,$thumbnail,$thumbwidth,$time,$content,$title,$date); } //if paging is not selected, use number of items designated in the list block }else{ $i += 1; newslistParse($url,$thumbnail,$thumbwidth,$time,$content,$title,$date); //once we reach the set number stop the script if($i >= $num){ break; } } } ?> </div> <?php //is iCal feed option is sellected, show it if($showfeed==1){ ?> <div class="rssfeed1"> <img src="<?php echo $uh->getBlockTypeAssetsURL($bt, 'rss.png');?>" width="14" height="14" alt="rss feed" /> <a href="<?php echo $rss_address ; ?>" id="getFeed">Get Feed</a> <link href="<?php echo $controller->getRssUrl();?>" rel="alternate" type="application/rss+xml" title="<?php echo t('RSS');?>" /> </div> <?php } //$c = Page::getCurrentPage(); $link = Loader::helper('navigation')->getLinkToCollection($c); $link = $controller->URLfix($link); //if pagination is set, if it is needed, show it if($isPaged==1){ if ($pcount > $num) { echo '<div id="pagination">'; if ($pageno == 1) { echo " FIRST PREV "; } else { echo '<a href="'.$link.'pageno=1">FIRST </a>'; $prevpage = $pageno-1; echo '<a href="'.$link.'pageno='.$prevpage.'"> PREV</a>'; } // if echo ' ( Page '.$pageno.' of '.$lastpage.' ) '; if ($pageno == $lastpage) { echo " NEXT LAST "; } else { $nextpage = $pageno+1; echo '<a href="'.$link.'pageno='.$nextpage.'">NEXT </a>'; echo '<a href="'.$link.' pageno='.$lastpage.'"> LAST</a>'; } // if echo '</div>'; } } if (isset($bID)) { echo '<input type="hidden" name="bID" value="'.$bID.'" />';} ?> Hi every one I want to share a page content(or an article) into my facebook page via php . How should I do that ? Thanks Would like to be able to click on a radio button that represents an image. Once selected and submitted, have that image display on another page. I have an idea, but need some guidance. BTW, is using php only doable? Is there a simpler or more elegant way to do this? Thanks all! I'm wondering if anyone can help me find/create a script which allows a preview of a link to be generated? Basically I need a user to be able to simply enter a url and click submit and then a preview of that link will be shown in the form of some text and an image. Very similar to what Facebook does when a user shares a link. I think they use the description tag of the site in general. Can anyone point me in the right direction in doing this? I need to be able to do it in php/javascript alone without the use of jquery or plugins. after spending many hours thinking this through and not really getting anywhere, trying to figure out how this site works, so that i can replicate it and make a single image from multiple images that are positioned overlaying with css positioning
the site in question is: http://www.dahippo.c...6360ZZ0ZZ0ZZ0ZZ
it is a type of calculator for an online game, the part that interests me is the image of the ship that is built up from many images
is also uses a php script to place all these images into on image file outputted to html, this is what interests me and i am trying to recreate, like he http://www.dahippo.c...6360ZZ0ZZ0ZZ0ZZ
here is the outputted html:
<html> <head> <meta name="viewport" content="width=device-width, minimum-scale=0.1"> <title>get.php (635x317)</title> </head> <body style="margin: 0px;"> <img style="-webkit-user-select: none; cursor: -webkit-zoom-in;" src="http://www.dahippo.com/bp/ship/get.php?image=4J01Q180O0K0E013C3A3C3A3636360ZZ0ZZ0ZZ0ZZ" width="408" height="204"> </body> </html>what php code used in the get.php script make all these images with css positioning into 1 image? i have asked the site owner, and got no reply :/ I just installed this new script here http://webhost.pro/domain-check.php it's a basic domain availability tool. I am trying to make a form that can be used on any page forward to this page with the content. The page loads with this in the url webhost.pro/domain-check.php?domain=dwhs.net and will run the page. So I can make a form that just submits to that page and sends the details. I made this page for testing http://webhost.pro/test.html But no go, here is the code: <form id="search" action="/domain-check.php" method="GET"> <input type="text" name="s"> <a onClick="document.getElementById('search').submit()" class="button1">Search</a> <div class="clear"></div> </form> Thanks! I need to make a php application for Celebrity Look Alike, where user can upload his/her picture and system will detect the closest match of celebrity. I dont know where to start. Can someone gives me basic instructions where to start from, My approach is to detect facial positions of user and then compare it celebrity facial positions., but question is where i can get the required data of celebrity or should i go for api.
Pls advice
Hey Guys,
I'm currently in a program managed by IT Department of India. My topic is Vehicle Offence Management System. Unfortunately I failed with android finger print scanning. I need to record face of every individual when registering offence and I need to retrieve data when the same face is captured. is there is any Solution in PHP ??? for matching 2 faces ?
Thanks Can someoneplease help, I need to setup an error page like IF Username and Password are wrong then show an error also if there is no username or password in the fields and I just click LOGIN, I get a blank page?! Can someone please help me here or point me to a relevant tutorial? thanks here is my page: http://www.retroandvintage.co.uk/default.php here is my code: Code: [Select] <?php session_start(); include_once("config.php"); $ebits = ini_get('error_reporting'); error_reporting($ebits ^ E_NOTICE); /* Login script: This script does the following: Checks that the user is NOT already logged in - if they are they are redirected to the members page by the 'checkLoggedIn()' function. Checks if the login form has been submitted - if so, the 'login' and 'password' fields are checked to ensure they are of the correct format and length. If there are any problems here an error is added to the $messages array and then the script executes the 'doIndex()' function - this function basically outputs the main 'index' page for this script - ie the login form. If there are no problems with the previous step, the 'login' and 'password' field data is passed to the 'checkPass' function to check that an entry exists in the 'users' table for that login/password pair. If nothing is returned from the 'checkPass()' function, an error is added to the $messages array and the 'doIndex()' function is called as above. If a row of data is returned from the 'users' table, the data is passed to the 'cleanMemberSession()' function - which initializes session variables and logs the user in. The user is then forwarded to the members page. If the form hasn't yet been submitted, then the 'doIndex()' function is called and the login page is displayed. */ // Check user not logged in already: checkLoggedIn("no"); // Page title: $title="Member Login Page"; // if $submit variable set, login info submitted: if(isset($_POST["submit"])) { // // Check fields were filled in // // login must be between 4 and 15 chars containing alphanumeric chars only: field_validator("rsUser", $_POST["rsUser"], "alphanumeric", 4, 15); // password must be between 4 and 15 chars - any characters can be used: field_validator("rsPass", $_POST["rsPass"], "string", 4, 15); // if there are $messages, errors were found in validating form data // show the index page (where the messages will be displayed): if($messages){ doIndex(); // note we have to explicity 'exit' from the script, otherwise // the lines below will be processed: exit; } // OK if we got this far the form field data was of the right format; // now check the user/pass pair match those stored in the db: /* If checkPass() is successful (ie the login and password are ok), then $row contains an array of data containing the login name and password of the user. If checkPass() is unsuccessful however, $row will simply contain the value 'false' - and so in that case an error message is stored in the $messages array which will be displayed to the user. */ if( !($row = checkPass($_POST["rsUser"], $_POST["rsPass"])) ) { // login/passwd string not correct, create an error message: $messages[]="Incorrect login/password, try again"; } /* If there are error $messages, errors were found in validating form data above. Call the 'doIndex()' function (which displays the login form) and exit. */ if($messages){ doIndex(); exit; } /* If we got to this point, there were no errors - start a session using the info returned from the db: */ cleanMemberSession($row["rsUser"], $row["rsPass"]); // and finally forward user to members page (populating the session id in the URL): header("Location: main.php"); } else { // The login form wasn't filled out yet, display the login form for the user to fill in: doIndex(); } /* This function displays the default 'index' page for this script. This consists of just a simple login form for the user to submit their username and password. */ function doIndex() { /* Import the global $messages array. If any errors were detected above, they will be stored in the $messages array: */ global $messages; /* also import the $title for the page - note you can normally just declare all globals on one line - ie: global $messages, $title; */ global $title; } // drop out of PHP mode to display the plain HTML: ?> <!doctype html> <html> <head> <title>List of Pubs and Bars in the UK</title> <meta name="description" content="Pubs and bars in the UK, nightlife for food and drink" /> <meta name="keywords" content="Pubs, bars, List, uk, nightlife, drinking, drinks, beer, lager, food" /> <meta name="Content-Language" content="en-gb" /> <meta name="robots" content="FOLLOW,INDEX" /> <meta name="revisit-after" content="2 days" /> <meta name="copyright" content="jbiddulph.com" /> <meta name="author" content="John Biddulph - Professional web site design and development in the south of england mainly worthing and brighton" /> <meta name="distribution" content="Global" /> <meta name="resource-type" content="document" /> <link rel="stylesheet" type="text/css" href="css/reset.css" /> <link rel="stylesheet" type="text/css" href="css/ui-lightness/jquery-ui-1.8.6.custom.css" title="default" /> <link rel="alternate stylesheet" type="text/css" href="css/south-street/jquery-ui-1.8.6.custom.css" title="1" /> <link rel="alternate stylesheet" type="text/css" href="css/redmond/jquery-ui-1.8.6.custom.css" title="2" /> <script type="text/javascript" src="js/stylechanger.js"></script> <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="js/jquery-ui-1.8.6.custom.min.js"></script> <script type="text/javascript"> $(function(){ // Accordion $("#accordion").accordion({ header: "h3" }); // Tabs $('#tabs').tabs(); // Dialog $('#dialog').dialog({ autoOpen: false, width: 600, buttons: { "Ok": function() { $(this).dialog("close"); }, "Cancel": function() { $(this).dialog("close"); } } }); // Dialog Link $('#dialog_link').click(function(){ $('#dialog').dialog('open'); return false; }); // Datepicker $('#datepicker').datepicker({ inline: true }); //hover states on the static widgets $('#dialog_link, ul#icons li').hover( function() { $(this).addClass('ui-state-hover'); }, function() { $(this).removeClass('ui-state-hover'); } ); }); </script> <script type="text/javascript"> function lookup(inputString) { if(inputString.length == 0) { // Hide the suggestion box. $('#suggestions').hide(); } else { $.post("rpc.php", {queryString: ""+inputString+""}, function(data){ if(data.length >0) { $('#suggestions').show(); $('#autoSuggestionsList').html(data); } }); } } // lookup function fill(thisValue) { $('#inputString').val(thisValue); setTimeout("$('#suggestions').hide();", 200); } </script> </head> <body> <?php if($messages) { displayErrors($messages); }?> <header> <div id="title"> <h1>My Pub Space <a href="#" onClick="setActiveStyleSheet('default'); return false;"><img src="images/0.gif" width="15" height="15" border="0" alt="css style" /></a> <a href="#" onClick="setActiveStyleSheet('1'); return false;"><img src="images/1.gif" width="15" height="15" border="0" alt="css style" /></a> <a href="#" onClick="setActiveStyleSheet('2'); return false;"><img src="images/2.gif" width="15" height="15" border="0" alt="css style" /></a> <span> <form method="post" class="textbox" action="search.php"> Town/City: <input type="text" size="26" class="searchbox" value="" name="rsTown" id="inputString" onKeyUp="lookup(this.value);" onBlur="fill();" /> <div class="suggestionsBox" id="suggestions" style="display: none;"> <img src="images/upArrow.png" style="position: relative; top: -36px; left: 105px; z-index:1;" alt="upArrow" /> <div class="suggestionList" id="autoSuggestionsList"> </div> </div> <input type="image" src="images/go.png" height="30" with="30" value="GO" /> </form> </span> </h1> </div> </header> <nav> <ul> <li class="selected"><a href="default.php">Home</a></li> <li><a href="#">Pubs</a></li> <li><a href="#">Members</a></li> <li><a href="#">Events</a></li> <li><a href="register.php">Register</a></li> </ul> </nav> <section id="intro"> <header> <h2>Your social guide to going down the pub, online!</h2> </header> <p>Stuck in town with nowhere to go? Not sure if up the road or down the street is best? Need to be somewhere warm, cosy and friendly. Need a drink?....<br />You've come to the right place, mypubspace has it all!</p> <img src="images/pub.jpg" alt="pub" /> </section> <div id="content"> <div id="mainContent"> <section> <article class="blogPost"> <header> <h2>Pubs and Bars UK Listing</h2> </header> <?php $tableName="pubs"; $targetpage = "default.php"; $limit = 20; $query = "SELECT COUNT(*) as num FROM $tableName"; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages['num']; $stages = 3; $page = mysql_escape_string($_REQUEST['page']); if( isset($_REQUEST['page']) && ctype_digit($_REQUEST['page']) ) { $page = (int) $_GET['page']; $start = ($page - 1) * $limit; }else{ $start = 0; } // Get page data $query1 = "SELECT * FROM $tableName LIMIT $start, $limit"; $result = mysql_query($query1); // Initial page num setup if ($page == 0){$page = 1;} $prev = $page - 1; $next = $page + 1; $lastpage = ceil($total_pages/$limit); $LastPagem1 = $lastpage - 1; $paginate = ''; if($lastpage > 1) { $paginate .= "<div class='paginate'>"; // Previous if ($page > 1){ $paginate.= "<a href='$targetpage?page=$prev'>previous</a>"; }else{ $paginate.= "<span class='disabled'>previous</span>"; } // Pages if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few? { // Beginning only hide later pages if($page < 1 + ($stages * 2)) { for ($counter = 1; $counter < 4 + ($stages * 2); $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // Middle hide some front and some back elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2)) { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $page - $stages; $counter <= $page + $stages; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // End only hide early pages else { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } } // Next if ($page < $counter - 1){ $paginate.= "<a href='$targetpage?page=$next'>next</a>"; }else{ $paginate.= "<span class='disabled'>next</span>"; } $paginate.= "</div>"; } echo $total_pages.' Results'; // pagination echo $paginate; ?> <div id="accordion"> <?php while($row = mysql_fetch_array($result)) { echo '<div><h3><a href=\"#\">'.$row['rsPubName'].'</a></h3><div>'.$row['rsAddress'].'<br />'.$row['rsTown'].', '.$row['rsCounty'].'<br />'.$row['rsPostCode'].'<br /><br />Region: '.$row['Region'].'<br /><br />Telephone: '.$row['rsTel'].'</div></div>'; } ?> </div> </article> </section> </div> <aside> <section> <header> <h3>Members Login Area</h3> </header> <form method="post" class="textbox" action="<?php print $_SERVER["PHP_SELF"]; ?>"> Username: <br /> <input type="text" class="textbox" name="rsUser" value="<?php print isset($_POST["rsUser"]) ? $_POST["rsUser"] : "" ; ?>"> Password: <br /> <input type="password" class="textbox" name="rsPass"> <br /> <br /> <input name="submit" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="submit" value="Login"> <br /> </form> <ul> <li><button id="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text"><a href="register.php">Sign up</a></span></button></li> <li><button id="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text"><a href="forgot.php">Forgot Password</a></span></button></li> </ul> </section> <section> <header> <h3>Quick Search</h3> </header> <ul> <li><a href="#">Coming Soon!</a></li> </ul> </section> </aside> </div> <footer> <div> <section id="about"> <header> <h3>About</h3> </header> <p>My Pub Space is one of the largest and newest UK Pubs and Bars Listing sites online. It is not just a list of pubs, we have added a touch of interactive social pubbing experience online! Once registered, you can view information on pubs in your area, write reviews, organise your evenings out!</p> </section> <section id="blogroll"> <header> <h3>Links</h3> </header> <ul> <li><a href="#">Coming Soon!</a></li> </ul> </section> <section id="popular"> <header> <h3>Popular</h3> </header> <ul> <li><a href="#">Coming Soon!</a></li> </ul> </section> </div> </footer> </body> </html> <?php $con=mysqli_connect("address","username","pass","db name"); // Check connection if (mysqli_connect_errno()) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } if (!(isset($pagenum))) { $pagenum = 1; } $data = mysqli_query($con,"SELECT * FROM info"); $rows = mysql_num_rows($data); $page_rows = 15; $last = ceil($rows/$page_rows); if($pagenum < 1); { $pagenum = 1; } elseif ($pagenum > $last); { $pagenum = $last; } $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; $result = mysql_query($con,"SELECT * FROM topsites $max") or die(mysql_error()); echo "<table border='1' class='boldtable' cellpadding='2'> <tr> <th>Creditor</th> <th>dd/mm/yyyy</th> <th>Credit Score</th> <th>State</th> <th>Income</th> <th>Approval</th> <th>Credit Line</th> <th>Interest</th> <th>Comment</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['creditor'] . "</td>"; echo "<td>" . $row['date'] . "</td>"; echo "<td>" . $row['fako'] . "</td>"; echo "<td>" . $row['state'] . "</td>"; echo "<td>" . $row['income'] . "</td>"; echo "<td>" . $row['approval'] . "</td>"; echo "<td>" . $row['creditline'] . "</td>"; echo "<td>" . $row['interest'] . "</td>"; echo "<td>" . $row['comments'] . "</td>"; echo "</tr>"; } echo "</table>"; echo " --Page $pagenum of $last-- <p>"; if ($pagenum == 1) { } else { echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=1'> <<-First</a> "; echo " "; $previous = $pagenum-1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$previous'> <-Previous</a> "; } echo " ---- "; if ($pagenum == $last) { } else { $next = $pagenum+1; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last ->></a> "; } mysqli_close($con); ?>All I want are the pages broken up into pages. It is going wrong somewhere before my table. Can someone help me out? Thank you! I have an image upload script where I am trying to compress an image to a lower file size. The code works. The image uploads to the directory with the correct name as intended. The only thing is that it's not compression the image as it should be. The size of the new image is the same as the old image. Here's my code. Can you spot what i'm doing wrong? // FUNCTION FOR COMPRESSION function compress_image($source_url, $destination_url, $quality) { $info = getimagesize($source_url); if($info['mime'] == 'image/jpeg') { $image = imagecreatefromjpeg($source_url); } else if ($info['mime'] == 'image/gif') { $image = imagecreatefromgif($source_url); } else if ($info['mime'] == 'image/png') { $image = imagecreatefrompng($source_url); imagejpeg($image, $destination_url, $quality); } return $destination_url; } // FORM SUBMIT CODE $errors = array(); $db->beginTransaction(); if(isset($_FILES['fileToUpload']) AND !empty($_FILES['fileToUpload']["name"])) { if(is_uploaded_file($_FILES['fileToUpload']["tmp_name"])) { // GENERATES A 10 CHARACTER STRING TO BE USED FOR AN IMAGE NAME $random_name = generateRandomString(10); $global_user_id = 10; $url_project_id = 5; $target_dir = '../members/images/'.$global_user_id.'/projects/'.$url_project_id.'/'; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = pathinfo($target_file,PATHINFO_EXTENSION); if(!is_dir($target_dir)){ mkdir($target_dir, 0775, true); } // RESIZE IMAGE $pathname = $_FILES["fileToUpload"]["tmp_name"]; $resized_image = compress_image($pathname, $random_name, 40); $new_file_path = $target_dir . $resized_image . '.' . $imageFileType; // Check if image file is a actual image or fake image $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { // echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { $errors[] = 'File is not an image!'; $uploadOk = 0; } // Check if file already exists if (file_exists($new_file_path)) { $errors[] = 'Sorry, file already exists!'; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] > 5000000) { $errors[] = 'Sorry, your file size is bigger than 5mb!'; $uploadOk = 0; } // Allow certain file formats if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" && $imageFileType != "JPG" && $imageFileType != "PNG" && $imageFileType != "JPEG" && $imageFileType != "GIF") { $errors[] = 'Sorry, only JPG, JPEG, PNG & GIF files are allowed!'; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if($uploadOk == 0) { $errors[] = 'Sorry, your file was not uploaded!'; // if everything is ok, try to upload file } else { if(move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $new_file_path)) { // SUCCESS MESSAGE } else { $errors[] = 'Sorry, there was an error uploading your file!'; } } } else { $errors[] = 'You must upload an image!'; } } if(empty($errors)) { $db->commit(); header("Location: http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"); exit; } else { $db->rollBack(); }
This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=317019.0 Hi Guys, I am a typical newbie with a twist, i program in VB, recently moved to PHP. I need help, preferable an example, but first let me explain what i have. I have a .tpl page that has 3 drop down boxes, one of these is populated from within the .tpl page itself. The other 2 i waant to pupulate from a SELECT on a database from a .php file. The .TPL file i have so far is:- Code: [Select] <style type="text/css"> <!-- .style7 { color: #006600; font-weight: bold; font-size: 18px; } .style14 {color: #003300; font-weight: bold; } .style16 { color: #000066; font-style: italic; } .style25 { color: #FF0000; font-weight: bold; font-size: 12px; } .style28 { font-size: 12px; color: #330000; } .style29 { font-size: 12px } .style31 {color: #003300; font-weight: bold; font-size: 16px; } .style33 { color: #000099; font-weight: bold; font-style: italic; font-size: 18px; } .style34 { color: #FF0000; font-weight: bold; font-size: 24px; } .style35 {font-size: 12px; color: #003300; } .style36 { color: #FF0000; font-weight: bold; font-size: 14px; font-style: italic; } .style38 {color: #003300; font-weight: bold; font-size: 16px; font-style: italic; } --> </style> <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script> <h1 align="center" class="style34">Scotbirds Alertz - Rare and Scarce</h1> <h3 align="center" class="style36">Soon Only VIP Members will be able to Access this Page</h3> <h3 align="center" class="style14">If you have seen something unusual / rare then please call it in on -- <span class="style33">Hotline: 0333 5772473</span></h3> <p align="center" class="style14"> <table width="90%" border="0" align="center" cellpadding="5"> <tr> <?php print $_SERVER['PHP_SELF']; $the_date_filter = $_GET["DATE_FILTER"];?> <td width="1%"><td width="5%"><td width="2%"><td width="2%"><td width="2%"><form action="alertz_VIP.php" method="post"> <td width="2%"><td width="2%"><td width="5%"><span class="style38">Date</span><td width="3%"></td> <td width="12%"><span class="style14"> <select name=DATE_FILTER size="1" id=DATE_FILTER onchange="this.form.submit()"> <option value="All Dates">All Dates</option> <option value="Today">Today</option> <option value="Last 48hrs">Last 48hrs</option> <option value="Last week">Last Week</option> <option value="last month">Last Month</option> </select> </span></td> <td width="1%"> </td> <td width="7%"><span class="style16"><span class="style14"><span class="style31">Region</span></span></span></td> <td width="22%"><span class="style16"><span class="style14"> <select name=REGION_FILTER size="1" id=REGION_FILTER onchange="this.form.submit()"> <option value="AllRg">All Regions</option> <option value={REGION_FILTER}></option> </select> </span></span></td> <td width="1%"> </td> <td width="8%"><span class="style16"><span class="style14"><span class="style31">Species</span></span></span></td> <td width="20%"><span class="style16"><span class="style14"> <select name=SPECIES_FILTER size="1" id=SPECIES_FILTER onchange="this.form.submit()"> <option value="AllSpec">All Species</option> <option value={SPECIES_FILTER}></option> </select> </span></span></td> <td width="9%"><input type="Submit" name="submit2" value="Search" method="get" action="alertz_VIP.php" /></td> </table> <p> </p> <table width="870" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#99CC99"> <tr> <th width="178" class="style31" scope="col">Region</th> <th width="184" class="style31" scope="col">Species</th> <th width="96" class="style31" scope="col">Date</th> <th width="96" class="style31" scope="col">Time</th> <th width = "304" class="style31" scope="col">Comments</th> </tr> <!-- BEGIN alerts --> <tr> <th class="style7 style29" scope="col">{alerts.REGION}</th> <th class="style25" scope="col">{alerts.SPECIES}</th> <th class="style35" scope="col">{alerts.DATE} </th> <th scope="col"><span class="style35">{alerts.TIME} </span></th> <th scope="col"><span class="style28">{alerts.COMMENTS} </span></th> </tr> <!-- END alerts --> </table> <p align="center" class="style14"> </p> Now from here i expect the user to select a date from the date box, ( Ideally i would like the other 2 options to only become visible once a selection on the date has been made, i would also like to retain the selected in the date box once the form has been submited. Now the code i have for the PHP so far is quite long winded as my PHP skills are not so good, although i am learning fast. Code: [Select] <?php /*************************************************************************** * Alertz.php * ------------------- * begin : 30/10/04/10 * copyright : (C) 2010 Andy Guppy * email : webmaster@scotbird.co.uk * * ***************************************************************************/ define('IN_ICYPHOENIX', true); if (!defined('IP_ROOT_PATH')) define('IP_ROOT_PATH', './'); if (!defined('PHP_EXT')) define('PHP_EXT', substr(strrchr(__FILE__, '.'), 1)); // Include files include(IP_ROOT_PATH . 'common.' . PHP_EXT); include_once(IP_ROOT_PATH . 'includes/functions_groups.' . PHP_EXT); include(IP_ROOT_PATH . '/alerts/alertsconfig.'.PHP_EXT); // Page Authorise $cms_page_id = 'scotalertz'; $cms_page_nav = (!empty($cms_config_layouts[$cms_page_id]['page_nav']) ? true : false); $cms_global_blocks = (!empty($cms_config_layouts[$cms_page_id]['global_blocks']) ? true : false); $cms_auth_level = (isset($cms_config_layouts[$cms_page_id]['view']) ? $cms_config_layouts[$cms_page_id]['view'] : AUTH_ALL); check_page_auth($cms_page_id, $cms_auth_level); // Obtain Select Criteria $temp_region_filter = $_REQUEST["REGION_FILTER"]; $temp_species_filter = $_REQUEST["SPECIES_FILTER"]; $temp_date_filter = $_REQUEST["DATE_FILTER"]; // Filter characters if required $region_filter =str_replace(" & ", "&", $temp_region_filter); $species_filter = $temp_species_filter; $date_filter = $temp_date_filter; // standard session management $userdata = session_pagestart($user_ip); // Check to see if user is logged in if ((!$userdata['session_logged_in']) ) // No he isnt { redirect(append_sid(LOGIN_MG . '?redirect=alerts.' . PHP_EXT)); } else // Yes they are { init_userprefs($userdata); // set page title $page_title = "ScotBird alerts - VIP's ONLY !! "; // standard page header include(IP_ROOT_PATH . 'includes/page_header.'.PHP_EXT); // Connect to the database $db = new sql_db($alerts_mysql_host,$alerts_mysql_username,$alerts_mysql_password,$alerts_mysql_db,false); if(!$db) { die("Database Connection Failed:- Please Contact Site Admin" . mysql_error()); } $template->set_filenames(array('body' => 'alertz_VIP.tpl')); if (!isset($_REQUEST['DATE_FILTER'])) { // if date is NOT set then perform this echo 'Date has not been set'; $sql2 = "SELECT * FROM alerts ORDER BY Date DESC, time DESC "; $sql3 = "SELECT DISTINCT species FROM alerts GROUP BY species"; $sql = "SELECT DISTINCT region FROM alerts GROUP BY region"; echo $sql2; } else { // if date is set then perform this $year =date("Y"); $month = date("m"); $day = date("d"); $theenddate = $year . '-' .$month . '-' . $day ; echo 'the choice selected was :- '.$_REQUEST['DATE_FILTER']; switch ($date_filter) { case "All Dates": $sql2 = "SELECT * FROM alerts ORDER BY Date DESC, time DESC "; break; case "Today": $sql2 = "SELECT * FROM alerts WHERE Date = '".$theenddate ."' ORDER BY Date DESC, time DESC "; $sql3 = "SELECT DISTINCT species FROM alerts WHERE Date = '".$theenddate ."' GROUP BY species"; $sql = "SELECT DISTINCT region FROM alerts WHERE Date ='".$theenddate ."' GROUP BY region"; break; case "Last 48hrs": $year =date("Y"); $month = date("m"); $day = date("d")-1; $thestartdate = $year . '-' .$month . '-' . $day ; $sql2 = "SELECT * FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' ORDER BY Date DESC, time DESC "; $sql3 = "SELECT DISTINCT species FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' GROUP BY species"; $sql = "SELECT DISTINCT region FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' GROUP BY region"; break; case "Last week": $year =date("Y"); $month = date("m"); $day = date("d")-7; $thestartdate = $year . '-' .$month . '-' . $day ; $sql2 = "SELECT * FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' ORDER BY Date DESC, time DESC "; $sql3 = "SELECT DISTINCT species FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' GROUP BY species"; $sql = "SELECT DISTINCT region FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' GROUP BY region"; break; case "last month": $year =date("Y"); $month = date("m")-1; $day = date("d"); $thestartdate = $year . '-' .$month . '-' . $day ; $sql2 = "SELECT * FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' ORDER BY Date DESC, time DESC "; $sql3 = "SELECT DISTINCT species FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' GROUP BY species"; $sql = "SELECT DISTINCT region FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' GROUP BY region"; break; case "last 3 months": $year =date("Y"); $month = date("m")-3; $day = date("d"); $thestartdate = $year . '-' .$month . '-' . $day ; $sql2 = "SELECT * FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' ORDER BY Date DESC, time DESC "; $sql3 = "SELECT DISTINCT species FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' GROUP BY species"; $sql = "SELECT DISTINCT region FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' GROUP BY region"; break; default: // Default is the last 48hrs $year =date("Y"); $month = date("m"); $day = date("d")-1; $thestartdate = $year . '-' .$month . '-' . $day ; $sql2 = "SELECT * FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' ORDER BY Date DESC, time DESC "; $sql3 = "SELECT DISTINCT species FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' GROUP BY species"; $sql = "SELECT DISTINCT region FROM alerts WHERE Date BETWEEN '".$thestartdate ."' AND '".$theenddate ."' GROUP BY region"; } } $result2 = $db->sql_query($sql2); if (!($result2 = $db->sql_query($sql2))) { die("Database Query Failed" . mysql_error()); } $i = 1; while ( $row2 = $db->sql_fetchrow($result2) ) { $template->assign_block_vars('alerts', array( 'POS' => $i , 'REGION' => str_replace("&", " & ", $row2['region']), 'SPECIES' => str_replace("%", "'",$row2['species']), 'DATE' => $row2['Date'], 'TIME' => $row2['time'], 'COMMENTS' => str_replace("'", "%",$row2['comments']), ) ); $i++; } $template->assign_vars(array( 'USERNAME' => htmlspecialchars($userdata[username]), 'REGION_FILTER' => str_replace("&", " & ", $region_filter_options), 'SPECIES_FILTER' => $species_filter_options, ) ); $result = $db->sql_query($sql); if (!($result = $db->sql_query($sql))) { die("Database Query Failed" . mysql_error()); } // This is where you would add a new VARS Array if you intend to use your own custom VARS. while ($row = $db->sql_fetchrow($result)) { $region_filter_options .= '<option value="' . $row['region'] . '">' . $row['region'] . '</option>'; } $result = $db->sql_query($sql3); if (!($result = $db->sql_query($sql3))) { die("Database Query Failed" . mysql_error()); } // This is where you would add a new VARS Array if you intend to use your own custom VARS. while ($row = $db->sql_fetchrow($result)) { $species_filter_options .= '<option value="' . $row['species'] . '">' . $row['species'] . '</option>'; } $template->assign_vars(array( 'USERNAME' => htmlspecialchars($userdata[username]), 'REGION_FILTER' => str_replace("&", " & ", $region_filter_options), 'SPECIES_FILTER' => $species_filter_options, ) ); // Build the page $template->pparse('body'); // standard page footer include(IP_ROOT_PATH . 'includes/page_tail.'.PHP_EXT); } ?> Now my questions are these:- 1) In the .tpl file hows can i submit from any of the dropdown boxes and retain the selection after submission 2) How can i have it so that the second and third drop down boxes are only visible after the previous one, ie the first box ( date ) has to have a selection before the Region ( 2nd one ) is visible and so 3) How can i reduce the amount of code to cover all options in building a select statement or is Switch - case the best way. I would greatly appreciate help with this and even more so for some example of what i am asking for so i can learn from them. Okay, I currently have a query that is like: Code: [Select] $sql = "SELECT SQL_CALC_FOUND_ROWS a.ItemID, a.spec, a.description, a.sport, a.category, a.price, a.unit_qty, a.is_visible, a.AdminID, b.name, b.ItemID as catID, c.Name as nameSport, c.ItemID as sportID FROM purchase_request_category_item as a LEFT JOIN purchase_request_category as b ON b.itemID = a.category LEFT JOIN ro_school_sports as c ON c.ItemID = a.sport WHERE a.AdminID = '".$dist."' GROUP BY a.ItemID, b.name, c.Name ORDER BY a.ItemID DESC LIMIT ". $start.",".$limit; I am building a custom search function which I intend to be able to change the WHERE line to: WHERE a.AdminID = '".$dist."' ".$query $query will be created via if statements for every element in the form which will be called either by the button on the form, or the links in my pagination. The form would have the following: Level(s): dynamic field, Multi Select Status: Both/Enabled/Disabled single select Sports: dynamic field, Multi Select Category: dynamic field, single select. the sport column is a single selected item on the add page, its of type int(11) the levels table, is also a multi select on the add item page, and is of the type set('1','2','3','4','5','12','13') So real question is I guess, how on earth do I work with these 2 multi selects to create this search? Hi I would like to know how to make a link select certain stuff from the database. For example the link called cape town with the id 11 is selected then the link must search through the events table for the city_id 11 and take that information and display it in another page. I would like to know how to do that or can you let me know of place that I can look. I have tried google but I don't know how to put what I'm looking for in words Hey guys there is probably a simple fix to this but i am just not seeing it ... Im createing a form that has error catching and self submitting valuse. I am trying to use a for loop to create all of the values and if the form is returned with an error then the correct values will still be filled out but i cant seem to get this loop to work. Every time i submit the form it doesnt matter what option i select it always comes back with the last one in the list or 30 in this case. the problem code is below.. Any help would be appreciated. Code: [Select] <?php for($i=1; $i<=30; $i++){ echo'<option value="'.$i.'"'; if(isset($_POST['petsAge'])== $i){ echo ' selected="selected"';} echo '>'.$i.'</option>'; } ?> |