Jump to content

JonnyDriller

Members
  • Content Count

    25
  • Joined

  • Last visited

Community Reputation

0 Neutral

About JonnyDriller

  • Rank
    Member
  1. No way... facepalm... ahh well I think I learned a good bit. Legend @ginerjm thx m8
  2. I have a situation were I need to just get a simple location. I don't want any while loops or any of that jazz. I just want 1 string location every time. <?php $ider = $_GET['id']; $conn = mysqli_connect("localhost", "Me", "pass", "MyDB"); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT Location FROM LifeSaver1 WHERE id =$ider"; $result = $conn->query($sql); $obj = mysqli_fetch_object($result); $obj2 = $obj->Location; var_dump($obj); ?> This is what it outputs I just need Boston. Can anyone give me a hint?
  3. I also think this stupid code has fried my database - with the following error... The phpMyAdmin configuration storage is not completely configured, some extended features have been deactivated. To find out why click here...sigh....so tired
  4. I just combined them as you see it @Kicken. Only all one script, saved as a PHP file. I've gotten a bit further with the troubleshooting. I've taken just code one and put it on it's own page. Something weird happens If I have blank <?php?> tags the page displays as a blank white page. So I put in the script - shown in Code 1. Now If I use the echo statements - if I echo $thisloc it displays the page with the echo eg. New york if I echo the $JSONloc it prints again only like this - "New York" However if I switch off all the echo statements - it says the page cannot be displayed. All I need is one value matched to the id. This is probably a bad way to do the PHP script. But after a few hours struggling I found this which prints out an array. then I just trimmed it down till I found the variable that I needed.
  5. I've tried another test where I remove my PHP code. Gave it php tags told it to echo "test"; and it loads it and the google map file fine. I might see if I can call this Json var from another file
  6. I've created both the scripts below. Which seem to work well on their own. The scripts are not interacting at the moment, however I do intend to use this lil $JSONloc (json encoded variable) from code 1, in Code 2. But they are not interacting atm. The Json variable is just a return from a database eg. "New York." and it returns whatever id I give it working fine. This map script = code 2: Will eventually plot a number of locations. Only 1 is set atm, but I've tested it with more, and it runs fine again on its own. The problem is when I run both scripts together I get problems. In this case it echos the location fine but it doesn't load the map. Ok so remove the echo statement... and then it says Page cannot be displayed Ok so remove the PHP and the map works fine. Like WTH? Do these things even work together? I'm at this 1 day and a half. Please help I've changed the personal details for security. Code 1 <?php $ider = $_GET['id']; $host = "localhost"; $user = "user"; $password ="pass"; $database = "DB1"; mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT); // connect to mysql database try{ $connect = mysqli_connect($host, $user, $password, $database); } catch (mysqli_sql_exception $ex) { echo 'Error'; } $sql = "SELECT id, Location FROM Db1 WHERE id =$ider"; $result = $connect->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { $thisloc = $row["Location"]; //get array data $JSONloc = json_encode($thisloc); //change to JSON echo $JSONloc; //test } } else { echo "0 results"; } $conn->close(); ?> Code 2 <!DOCTYPE html> <html> <head> <title>Custom Markers</title> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <style> /* Always set the map height explicitly to define the size of the div * element that contains the map. */ #map { height: 100%; } /* Optional: Makes the sample page fill the window. */ html, body { height: 90%; width: 70% margin: 0; padding: 0; } </style> </head> <body> <div id="map"></div> <script> var map; function initMap() { map = new google.maps.Map( document.getElementById('map'), {center: new google.maps.LatLng(64.009094, -7.316163), zoom: 13}); var iconBase = 'https://developers.google.com/maps/documentation/javascript/examples/full/images/'; var iconBase2 = 'http://icons.iconarchive.com/icons/paomedia/small-n-flat/32/'; var icons = { // different icons for the map equipment: { icon: 'http://icons.iconarchive.com/icons/icons-land/vista-map-markers/32/Map-Marker-Marker-Outside-Azure-icon.png' }, library: { icon: iconBase2 + 'map-marker-icon.png' }, info: { icon: iconBase + 'info-i_maps.png' } }; var dormant = 'equipment'; var active = 'library'; var later = 64.013376; var longer = -7.307036; // static variables for testing var features = [ { position: new google.maps.LatLng(later, longer), type: active } ]; // Create markers. for (var i = 0; i < features.length; i++) { var marker = new google.maps.Marker({ position: features.position, icon: icons[features.type].icon, map: map }); }; } </script> <script async defer src="https://maps.googleapis.com/maps/api/js?key=bla&callback=initMap"> </script> </body> </html>
  7. Soz guys I wrapped it in a Div and stuck it at the bottom of my code. Seems to have worked out <?php $uri = $_SERVER['REQUEST_URI']; $uri_dir = getcwd(); ?> <!DOCTYPE html> <html> <head> <link href="/LifeSaverHTML/Details/Database/stylevid2.css" rel="stylesheet" type="text/css"> <h1 class = "titler"> LifeTube </h1> <p></p> <nav> <ul> <li> <a href="/home.php">Home</a> </li> <li> <a href="/LifeSaverHTML/Database.php">Database</a> </li> <li> <a href="/LifeSaverHTML/mapper.php">GPS Map</a> </li> <li> <a href="/LifeSaverHTML/UpdateSearch.php">Update and Search</a> </li> <li> <a href="/LifeSaverHTML/Details/Database/index.php">Video</a> </li> </ul> </nav> <p></p> </head> <body> <video class = "tube" controls src="examplevid.mp4"> Your browser does not support the video tag. </video> <p></p> <div style="margin: 0 auto; text-align: center"> <a href='/PHPMailer/index.php?id=<?=$uri?>&dire=<?=$uri_dir?>' class="linker">Email Security</a> </div> </body> </html> ?php if(isset($_GET['Message'])){ echo "<div id='emailmess'>"; echo $_GET['Message']; echo "</div>"; } ?>
  8. I've been working on my email screen, adding a video to it, and some Css. Which seems to work quite fine. However when the page returns to the original screen (represented by the code 1.) It collapses the video image. Makes it really long horizontally and thin vertically. If I remove this first piece, showing that the email was sent successfully. if(isset($_GET['Message'])){ echo $_GET['Message']; } It returns to the screen fine and the video looks as it should. Code1:- <?php if(isset($_GET['Message'])){ echo $_GET['Message']; } $uri = $_SERVER['REQUEST_URI']; $uri_dir = getcwd(); ?> <!DOCTYPE html> <html> <head> <link href="/LifeSaverHTML/Details/Database/stylevid2.css" rel="stylesheet" type="text/css"> <h1 class = "titler"> LifeTube </h1> <p></p> </head> <body> <video class = "tube" controls src="examplevid.mp4"> Your browser does not support the video tag. </video> <p></p> <div style="margin: 0 auto; text-align: center"> <a href='/PHPMailer/index.php?id=<?=$uri?>&dire=<?=$uri_dir?>' class="linker">Email Security</a> </div> </body> </html> I'm using this piece of CSS = Code2. I've set all the defaults padding etc to default for testing. * { margin: 0; padding: 0; } As I say it looks great. Apart from when it returns with the email successful message. The whole thing just deflates. Code2:- * { margin: 0; padding: 0; } body { background: url('/LifeSaverHTML/Details/Database/backround.jpg') no-repeat center center fixed; height: 100%; background-position: center; background-repeat: no-repeat; background-size: cover; } .tube { display: block; margin: auto; width: 50%; height: 20%; border: 10px solid green; } .button { margin: 0 auto; display:block; text-align: center; } .linker { background-color: #23b83c; border: 2px solid #020353; color: whitesmoke; padding: 1em 1.5em; text-align: center; text-decoration: none; font-size: 1em; display: inline-block; width: 12%; border-radius: 5px; box-shadow: 3px 3px 8px 0 #000; /* h-offset v-offset blur spread color */ } .linker:hover { color: red; } .titler { width: 20%; text-align: center; margin: 0 auto; color: #FFFFFF; border: 5px ridge rgba(124,252,0); border-radius: 36px; background: #232323; text-shadow: 0 0 5px #FFF, 0 0 10px #FFF, 0 0 15px #FFF, 0 0 20px #49ff18, 0 0 30px #49FF18, 0 0 40px #49FF18, 0 0 55px #49FF18, 0 0 75px #49ff18; } nav { width: 80%; margin: 0 auto; } nav ul { list-style: none; overflow: hidden; } nav ul li { float: left; width: 20%; } nav ul li a { text-align: center; padding: 8px 0; display: block; width: 100%; background: #cdeb8e; /* Old browsers */ background: -moz-linear-gradient(top, #cdeb8e 0%, #b0ca34 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#cdeb8e), color-stop(100%,#b0ca34)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #cdeb8e 0%,#b0ca34 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #cdeb8e 0%,#b0ca34 100%); /* Opera 11.10+ */ background: linear-gradient(to bottom, #cdeb8e 0%,#b0ca34 100%); /* W3C, IE10+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=’#cdeb8e’, endColorstr=’#b0ca34′,GradientType=0 ); /* IE6-9 */ } nav ul li a, nav ul li a:focus, nav ul li a:visited, nav ul li a:hover, nav ul li a:active { color: #000; text-decoration: none; } nav ul li a:hover, nav ul li a:active { background: #b0ca34; /* Old browsers */ background: -moz-linear-gradient(top, #b0ca34 0%, #96c40d 100%); /* FF3.6+ */ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b0ca34), color-stop(100%,#96c40d)); /* Chrome,Safari4+ */ background: -webkit-linear-gradient(top, #b0ca34 0%,#96c40d 100%); /* Chrome10+,Safari5.1+ */ background: -o-linear-gradient(top, #b0ca34 0%,#96c40d 100%); /* Opera 11.10+ */ background: linear-gradient(to bottom, #b0ca34 0%,#96c40d 100%); /* W3C, IE10+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=’#b0ca34′, endColorstr=’#96c40d’,GradientType=0 ); /* IE6-9 */ } nav ul li:first-child a { border-top-left-radius: 8px; border-bottom-left-radius: 8px; } nav ul li:last-child a { border-top-right-radius: 8px; border-bottom-right-radius: 8px; }
  9. Thanks guys for the great advise. When all this is over and done, I'm gonna revisit web development on a nice platform, with a proper text editor... i.e not a Raspberry pi that existed 2 decades ago This IOT project is gonna sit on a localhost...yeh I know... So it doesn't have to be super secure. I'm gonna do a screen recording of it and then I'm going to trim it down to make it have a much functionality as possible for a demo on the university Lan. The thing doesn't have wifi and things are not allowed on the Uni network...😂 the joys...
  10. Interestingly I actually needed the whole path for that one. It wanted the complete path to send an attachment in PHPMailer. It wouldn't take the /LifeSaverHTML/Details/20 It wanted the whole /var/www/html/LifeSaverHTML/Details/20 This code does it though there's probably one of those server commands would work too. $uri_dir = getcwd();
  11. Sorry guys I got it: - $uri_dir = dirname($_SERVER['REQUEST_URI']); echo $uri_dir; Might come in handy for someone in future
  12. I need to assign my current folder path to a variable. I keep getting this:- What I want is this:- That full path does weird stuff. Sometimes when I'm editing files, it's like I'm editing a ghost copy but not the actual file... Weird anyways. Below is some of the attempts I've tried... If I use this command:- //$uri = $_SERVER['REQUEST_URI']; It will give me what I need but with index.php tacked onto the end:- <?php //$pa = $_SERVER['PATH_TRANSLATED']; //echo $pa; //$uri = string dirname ( $path ); //echo $uri; //$ echo $PWD // current directory // current directory //echo getcwd() . "\n"; //chdir('cvs'); // current directory //echo getcwd() . "\n"; //$pa = basename(__DIR__); //echo $pa; //$pa = dirname(__FILE__); //echo $pa; $cur_dir = explode('\\', getcwd()); echo $cur_dir[count($cur_dir)-1]; ?> This first one returns a blank page without error, there's one that will return just the directory most are the www stuff. I suppose I could edit the string but surely there must be a function?
  13. Maxxd thx for the extra info. Sorry I've had this link open all this time, buried deep in my multiple research windows. I'm stuck at a part of this that I thought would be as easy as pie. Seeming not... sigh... gonna open another thread for it though as it's kind of unrelated.
  14. That's worked out nicely to send that variable. I'm not sure if Href will tell the phpmailer page to send the email though. I seem to remember it needed the form post method... but I could be wrong. I've some test to set up here and see if it works. . Thanks once again, I definitely wouldn't be sitting at this point without your help. 3 months to go and am freeeeee from uni...soon this project will be done. Enjoyable but can't wait to get finished... I'll let you know if it works.
  15. Nice, so the <??> is telling it to use the php variable... kk I'll give it a whirl.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.