
rvdveen27
Members-
Posts
91 -
Joined
-
Last visited
Everything posted by rvdveen27
-
This: <?php $inconvoy = false; $query = " SELECT 1 FROM convoysignup WHERE username = :username "; $query_params = array( ':username' => $_SESSION['userid'] ); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $count = $stmt->rowcount(); if($count->rowcount() > 0) { $inconvoy = true; } is giving me: Fatal error: Call to a member function rowcount() on integer in/home/emerald/domains/emeraldimmersiontrucking.com/public_html/convoy.php on line 118
-
That does indeed show the message, but it does not replace the button and it also doesn't stop the query from being ran again, thus allowing multiple rows for the same user. (replacing the button is optional, would be great if that could be done, but not necessary. Stopping the query from running again if there's already a row in the table from that user is necessary.)
-
Thanks, that worked perfectly. I'm now trying to show a message when the person has already signed up for the convoy instead of the signup button. So far I got the code shown below, but the "die" causes it to end the whole page after that, thus not showing the user who signed up etc. Is there a way that I can just show the message "You have already signed up for the convoy" instead of the button, while still showing the rest of the page? <?php $query = " SELECT 1 FROM convoysignup WHERE username = :username "; $query_params = array( ':username' => $_SESSION['userid'] ); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $row = $stmt->fetch(); if($row) { die("You have already signed up for the convoy."); } if(isset($_POST['addConvoyUser'])) { /* if(!is_numeric($_POST['price'])) { header("Location: errorjob.php?id=002"); exit; } if(!is_numeric($_POST['distance'])) { header("Location: errorjob.php?id=001"); exit; } if(!is_numeric($_POST['costs'])) { header("Location: errorjob.php?id=003"); exit; }*/ $query = " INSERT INTO convoysignup ( username ) VALUES ( :username ) "; $query_params = array( ':username' => $_SESSION['userid'] ); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } header("Location: convoy.php"); exit; } ?> <div class="container" style="width:450px;"> <form class="form-signin" role="form" action="convoy.php" method="post"> <button class="btn btn-lg btn-primary btn-block" name="addConvoyUser" type="submit">Sign up for this convoy</button> </form>
-
Cool, that did indeed fix it. Thanks a lot I have one more question. I'm trying to get it so that users can sign up with the press of a button. When they press the button, their username should automatically be entered into the convoysignup table. My code seems to be working (no errors or anything), except nothing gets put into the database. $query = " SELECT u.username ,cv.date as 'date' FROM convoy cv, convoysignup cvsu INNER JOIN users u ON u.id = cvsu.name "; try { $stmt = $db->prepare($query); $result = $stmt->execute(); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $rows = $stmt->fetchAll(); $count = $stmt->rowcount(); ?> <center><img src="images/underconstruction.jpg" width="15%"><br> Information shown on this page might be not properly shown, incorrect or incomplete.<br> </center> <br> <br> <center><h2>The next convoy will be at:</h2><br> <h1><?php echo $rows[0]['date']; ?> GMT +1</h1><br> </center> <br> <br> <?php if(!empty($_POST)) { /* if(!is_numeric($_POST['price'])) { header("Location: errorjob.php?id=002"); exit; } if(!is_numeric($_POST['distance'])) { header("Location: errorjob.php?id=001"); exit; } if(!is_numeric($_POST['costs'])) { header("Location: errorjob.php?id=003"); exit; }*/ $query = " INSERT INTO convoysignup ( username ) VALUES ( :username ) "; $query_params = array( ':username' => $_SESSION['userid'] ); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } header("Location: myjobs.php"); exit; } ?> <div class="container" style="width:450px;"> <form class="form-signin" role="form" action="convoy.php" method="post"> <button class="btn btn-lg btn-primary btn-block" type="submit">Sign up for this convoy</button> </form> <br> <br> <br> <h1>Sign ups</h1><br> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr> <th width="7%">#</th> <th>Name</th> </tr> </thead> <?php $rank = 0; foreach($rows as $row): ++$rank; ?> <tbody> <tr> <td><?php echo $rank; ?></td> <td><?php echo $row['username']; ?></td> </tr> </tbody> <?php endforeach; ?> </table> </div>
-
Hello all, This is probably going to be a really simple question, but for a page I'm making I cannot figure out how to put out the date of the convoy. I'm getting the error: Notice: Undefined index: date in/home/emerald/domains/emeraldimmersiontrucking.com/public_html/convoy.php on line 84 Here's the code: $query = " SELECT u.username ,cv.date as 'date' FROM convoy cv, convoysignup cvsu INNER JOIN users u ON u.id = cvsu.name "; try { $stmt = $db->prepare($query); $result = $stmt->execute(); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $rows = $stmt->fetchAll(); $count = $stmt->rowcount(); ?> <center><img src="images/underconstruction.jpg" width="15%"><br> Information shown on this page might be not properly shown, incorrect or incomplete.<br> </center> <br> <br> <center><h2>The next convoy will be at:</h2><br> <h1><?php echo $rows['date']; ?> GMT +1</h1><br> </center> <br> <br> <br> <div class="container" style="width:450px;"> <h1>Sign ups</h1><br> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr> <th>#</th> <th>Name</th> </tr> </thead> <?php $rank = 0; foreach($rows as $row): ++$rank; ?> <tbody> <tr> <td><?php echo $rank; ?></td> <td><?php echo $row['username']; ?></td> </tr> </tbody> <?php endforeach; ?> </table> </div> <br> <br> Hoping someone can help me in solving this issue, thanks in advance.
-
Hello all, I've been searching for a code that allows me to put images in the php code that can be clicked to get a zoomed-view of the picture within the same page. (image below for clarification of what I mean) Now it doesn't need to be entirely the same as in the picture. As long as if the image on the page is clicked it shows a zoomed-view of the picture like that and when the picture is click again or there's a click outside of the zoomed-view, the picture should go back to normal again. So far I haven't been able to find a code for this, I understand this might work with jquery? The only things I've managed to find on this topic is extra files which I need to download, which, I rather have raw code. I'm hoping someone here can help me with this. EDIT: Basically I'm requesting what this forum has too when you click the picture, which I just got reminded off.
-
@Barand - You're golden.
-
The page for reviewing looks like this: Because there are multiple applications being shown at the same time it seems impossible to get the URL to be something like: "http://mysite.com/mypage.php?username=myusername"? The code for the reviewing page looks like this: <?php ob_start(); require('extra/header.php'); if(empty($_SESSION['user'])) { header("Location: login.php"); exit; } if($_SESSION['adminlevel'] == 0) { header("Location: dashboard.php"); exit; } ini_set('display_errors', 1); error_reporting(E_ALL); $query = " SELECT id ,username ,steamprofile ,age ,timezone ,description ,playtime ,CASE othervtc WHEN 1 THEN 'Yes' WHEN 2 THEN 'No' END as othervtc ,vtcreason ,CASE teamspeak WHEN 11 THEN 'Yes' WHEN 22 THEN 'Yes, with headset' WHEN 33 THEN 'No' END as teamspeak ,tsreason ,CASE aboutedim WHEN 1 THEN 'ETS2MP Company forums' WHEN 2 THEN 'ETS2C Convoy' WHEN 3 THEN 'Google or another search engine' WHEN 4 THEN 'EDIM website' WHEN 5 THEN 'EDIM Teamspeak' END as aboutedim FROM applications "; $query_params = array( ':id' => "0", ); $query .= " WHERE status = :id "; try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $rows = $stmt->fetchAll(); $count = $stmt->rowcount(); ?> <div class="container2"> <h1>Pending Applications</h1> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr> <th>#</th> <th>Username</th> <th>Steamprofile</th> <th>Age</th> <th>Timezone</th> <th>Description</th> <th>Playtime</th> <th>Other VTC's?</th> <th>VTC reasons</th> <th>Teamspeak?</th> <th>Teamspeak reason</th> <th>About EDIM</th> <th>Action</th> </tr> </thead> <?php if($count == 0) {?> <tr> <td></td> <td></td> <td></td> <td></td> <td>There</td> <td>are</td> <td>currently</td> <td>no pending</td> <td>applications.</td> <td></td> <td></td> <td></td> <td></td> </tr> <?php } else foreach($rows as $row): //Get the username $query = " SELECT * FROM users WHERE id = ". $row['username'] ." "; try { $stmt = $db->prepare($query); $result = $stmt->execute(); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $driverid = $stmt->fetch(); ?> <tbody> <tr> <td><?php echo $row['id']; ?></td> <td><?php echo $driverid['username']; ?></td> <td><a href="<?php echo htmlentities($row['steamprofile'], ENT_QUOTES, 'UTF-8'); ?>" target="_blank">steamprofile</a></td> <td><?php echo $row['age']; ?></td> <td><?php echo $row['timezone']; ?></td> <td><?php echo $row['description']; ?></td> <td><?php echo $row['playtime']; ?></td> <td><?php echo $row['othervtc']; ?></td> <td><?php echo $row['vtcreason']; ?></td> <td><?php echo $row['teamspeak']; ?></td> <td><?php echo $row['tsreason']; ?></td> <td><?php echo $row['aboutedim']; ?></td> <td><a href="acceptuser.php?id=<?php echo $row['id']; ?>">ACCEPT</a> - <a href="denyjob.php?id=<?php echo $row['id']; ?>">DENY</a></td> </tr> </tbody> <?php endforeach; ?> </table> </div> </div> <?php require('extra/footer.php'); ?> It echoes the ID to the acceptuser.php page, which is the ID for the application. Except it should elso send the "username" to the acceptuser.php page. I understand I need to change something in the code on the pendverify.php page at line 146. The difficulty is in the fact that two values need to be send to the next page I guess. EDIT: I changed line 146 to: <td><a href="acceptuser.php?id=<?php echo $row['id']; ?>?username=<?php echo $row['username']; ?>">ACCEPT</a> - <a href="denyjob.php?id=<?php echo $row['id']; ?>">DENY</a></td> Now on the acceptuser.php it runs through the whole code (I can tell this because it sends me to the profile of the user with ID 3, which is at the bottom of the code), but the user doesn't get verified = 1 and verifypend = 0 in the database.
-
Hello all, I've recently made an application form, based on that I created another page where application forms can be reviewed and then accepted/denied. Now I'm working on the code where an application should be accepted. What I want to achieve, is that if on the page where applications can be reviewed the action "accept" is chosen, it sets the application status to "2" (which is accepted) and at the same time sets the user's (creator of the application) verifypend to "0" and verified to "1". For that I use the code below. However, it doesn't run through the code fully. I have concluded that it runs it fine, then stops at line 58. I understand that's it's unable to get the username, but I do not know how to solve that issue. <?php ob_start(); require('extra/header.php'); if(empty($_SESSION['user'])) { header("Location: login.php"); exit; } else if($_SESSION['adminlevel'] == 0) { header("Location: dashboard.php"); exit; } else { if(empty($_GET['id'])) { header("Location: index.php"); exit; } $id = $_GET['id']; $id = intval($id); if(!is_numeric($id)) { header("Location: index.php"); exit; } $query = " UPDATE applications SET status = 2 "; $query_params = array( ':id' => $id, ); $query .= " WHERE id = :id "; try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } // Verify the user if(empty($_GET['username'])) { header("Location: inforules.php"); exit; } $id = $_GET['username']; $id = intval($id); if(!is_numeric($id)) { header("Location: index.php"); exit; } $query = " UPDATE users SET verifypend = 0, verified = 1 "; $query_params = array( ':id' => $id, ); $query .= " WHERE id = :id "; try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } header("Location: editprofile.php?id=". $id .""); exit; } ?>
-
Hello all, Is it possible to change the database output? For example I have a selection which puts either 1, 2 or 3 into the database for an answer. Now I want to get that 1, 2 or 3 out of the database again but then I want it in the code to be changed for example to: 1 = yes 2 = no 3 = maybe Could anyone tell me how to do this?
-
Yeah I understood, the point was, I should not be inserting a record into the drive_routes table. But anyways, see my edit, that's fixed now.. Now I'm having the next issue. EDIT: Got it fully working now. The problem was ':driver' => $_SESSION['userid'] which was supposed to be ':user' => $_SESSION['userid'] I guess I overlooked this since I was rushed... (I'm trying to reach a deadline which is in 1,5 hours from now).
-
There is no "start" column in the "applications" table. But the "start" column is in the "drive_routes" table, that's why I know it's trying to input the data in the wrong table. Therefor it shouldn't even do anything at all with a "start" column and I don't see where it's getting that from. EDIT: Found the issue it was in: <form class="form-signin" role="form" action="submitjob.php" method="post"> forgot to change that to application.php Now I'm getting this error, which is even more unclear to me: Failed to run query: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined
-
Thank you, that worked perfectly. Now I'm running into the following problem: With the code below I tried filling in the form and see if it enters the data correctly into the database, but I get an error instead saying: Failed to run query: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'start' cannot be null Now it seems for some reason it's trying to enter the data from the form into the drive_routes table instead of the applications table. But I have no idea why since the code (according to me) doesn't say anywhere that it should put the data into the drive_routes table? $query = " INSERT INTO applications ( user ,steamprofile ,age ,timezone ,description ,playtime ,othervtc ,vtcreason ,teamspeak ,tsreason ,aboutedim ) VALUES ( :user ,:steamprofile ,:age ,:timezone ,:description ,:playtime ,:othervtc ,:vtcreason ,:teamspeak ,:tsreason ,:aboutedim ) "; $query_params = array( ':driver' => $_SESSION['userid'] ,':steamprofile' => $_POST['steamprofile'] ,':age' => $_POST['age'] ,':timezone' => $_POST['timezone'] ,':description' => $_POST['description'] ,':playtime' => $_POST['playtime'] ,':othervtc' => $_POST['othervtc'] ,':vtcreason' => $_POST['vtcreason'] ,':teamspeak' => $_POST['teamspeak'] ,':tsreason' => $_POST['tsreason'] ,':aboutedim' => $_POST['aboutedim'] ); try { $stmt = $db->prepare($query); $result = $stmt->execute($query_params); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } header("Location: index.php"); exit; }
-
Too be honest, in my inexperience I have no idea where that element should be? Like I said, I looked up how to do it and found this. Then like usually I fiddle around with it a bit to see if I can et it to work, this time that seemed not possible for me.
-
Hello all, For an application form I'm trying to put together a form with some hidden fields that become visible based on earlier selection choices. I've looked up some info about this on the internet and it seems to be done with a javascript. So I've added a script in my code, played around with it a bit but I seem not able to get it to work. The second box seems to visible with me anyways. I hope one of you can help me in getting this to work. Code: <script> $(document).ready(function() { $.viewMap = { '0' : $([]), 'YES' : $('#YES'), 'NO' : $('#NO') }; $('#viewSelector').change(function() { // hide all $.each($.viewMap, function() { this.hide(); }); // show current $.viewMap[$(this).val()].show(); }); }); </script> Have you been part of any other VTC's before this application?<br> <select id="viewSelector"> <option value="0">---Select one---</option> <option value="YES">Yes</option> <option value="NO">No</option> <div id="view1"> If so, which VTC's have you been in and what was your reason for quitting?<br> <input type="text" name="otherVTC" class="form-control" placeholder="Example: <vtc name>: reason, <vtc name>: reason, etc." required><br /> </div><br> Thanks in advance!
-
Hello, Like the title says, it seems that all firefox users can't see the images on my website. Chrome and IE works just fine. Since I have no lead on anything that could possibly be an issue to cause this problem, I think it might be the best idea to just put a link to the website here so you can check it for yourself. I have done some looking into this problem. The results I got were to fix it client side (which did not work). Next to that, it happens on multiple computers and with those computers it's only my website that doesn't show the images. link to website: http://emeraldimmersiontrucking.com/index.php If anyone could tell me why this problem is happening and how to solve it, that would be greatly appreciated.
-
Trying to get a several rows and colums with data.
rvdveen27 replied to rvdveen27's topic in MySQL Help
Can't believe it was THAT simple! That's the rankings page working completly as I wanted it to. Thanks so much for all the help! -
Trying to get a several rows and colums with data.
rvdveen27 replied to rvdveen27's topic in MySQL Help
See the EDIT in my post Now.. I'm coming to the next bit... I would like to have the results filtered by the current month. Every entry into the drive_routes database recieves CURRENT_TIMESTAMP. Now I did some looking into this and it seems it would be possible with something called "Epoch Unix Time". But I have no idea how I could do this and if this is even applicable on any database? -
Trying to get a several rows and colums with data.
rvdveen27 replied to rvdveen27's topic in MySQL Help
Taking the code exactly as you said it, results in the following: It gives the rows a rank, but it's all the same rank and there's no increasing it. EDIT: I did a little swap arround in your code, seems if I do it the following way, it does it correctly: <?php $rank = 0; foreach($rows as $row): ++$rank; ?> <tbody> <tr> <td><?php echo $rank; ?></td> <td><?php echo $row['username']; ?></td> <td>€<?php echo htmlentities($row['profit'], ENT_QUOTES, 'UTF-8'); ?></td> <td><?php echo $row['deliveries']; ?></td> <td><?php echo htmlentities($row['distance'], ENT_QUOTES, 'UTF-8'); ?> KM</td> </tr> </tbody> <?php endforeach; ?> -
Trying to get a several rows and colums with data.
rvdveen27 replied to rvdveen27's topic in MySQL Help
Here you go: <?php ob_start(); require('extra/header.php'); if(empty($_SESSION['user'])) { header("Location: login.php"); exit; } if($_SESSION['verifypend'] == 1) { header("Location: verifypend.php"); exit; } ini_set('display_errors', 1); error_reporting(E_ALL); $query = " SELECT u.username ,SUM(price) as price ,SUM(costs) as costs ,SUM(cargodamage) as cargodamage ,SUM(price - costs - cargodamage) as profit ,COUNT(driver) as 'deliveries' ,SUM(distance) as 'distance' FROM drive_routes dr INNER JOIN users u ON u.id = dr.driver WHERE status = 2 GROUP BY driver ORDER BY profit DESC "; try { $stmt = $db->prepare($query); $result = $stmt->execute(); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $rows = $stmt->fetchAll(); $count = $stmt->rowcount(); $rank = 1; while ($rows) { // output row with $rank ++$rank; // increment it } ?> <center><img src="http://pro-quest.co.uk/ITRecruitmentAgencyImages/Under_Construction-section.jpg" width="15%"></center><br> <div class="container"> <h1>Current rankings</h1> <div class="table-responsive"> <table class="table table-striped"> <thead> <tr> <th>#</th> <th>Driver</th> <th>Profit</th> <th>Deliveries</th> <th>Distance</th> </tr> </thead> <?php foreach($rows as $row): ?> <tbody> <tr> <td><?php echo $rank['rank']; ?></td> <td><?php echo $row['username']; ?></td> <td>€<?php echo htmlentities($row['profit'], ENT_QUOTES, 'UTF-8'); ?></td> <td><?php echo $row['deliveries']; ?></td> <td><?php echo htmlentities($row['distance'], ENT_QUOTES, 'UTF-8'); ?> KM</td> </tr> </tbody> <?php endforeach; ?> </table> </div> </div> <?php require('extra/footer.php'); ?> -
Trying to get a several rows and colums with data.
rvdveen27 replied to rvdveen27's topic in MySQL Help
Okay I managed to fix the problem, it seems that there was an "}" too many in the code that wasn't attached to anything. Now with the following code: $query = " SELECT u.username ,SUM(price) as price ,SUM(costs) as costs ,SUM(cargodamage) as cargodamage ,SUM(price - costs - cargodamage) as profit ,COUNT(driver) as 'deliveries' ,SUM(distance) as 'distance' FROM drive_routes dr INNER JOIN users u ON u.id = dr.driver WHERE status = 2 GROUP BY driver ORDER BY profit DESC "; try { $stmt = $db->prepare($query); $result = $stmt->execute(); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $rows = $stmt->fetchAll(); $count = $stmt->rowcount(); $rank = 1; while ($rows) { // output row with $rank ++$rank; // increment it } ?> I get the following error: -
Trying to get a several rows and colums with data.
rvdveen27 replied to rvdveen27's topic in MySQL Help
To be honest, I have no idea how or where to do that. -
Trying to get a several rows and colums with data.
rvdveen27 replied to rvdveen27's topic in MySQL Help
True, but if I put it as done below, the page breaks and I get a white page with nothing. $query = " SELECT u.username ,SUM(price) as price ,SUM(costs) as costs ,SUM(cargodamage) as cargodamage ,SUM(price - costs - cargodamage) as profit ,COUNT(driver) as 'deliveries' ,SUM(distance) as 'distance' FROM drive_routes dr INNER JOIN users u ON u.id = dr.driver WHERE status = 2 GROUP BY driver ORDER BY profit DESC "; try { $stmt = $db->prepare($query); $result = $stmt->execute(); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } } $rows = $stmt->fetchAll(); $count = $stmt->rowcount(); $rank = 1; while ($rows) { // output row with $rank ++$rank; // increment it } ?> -
Trying to get a several rows and colums with data.
rvdveen27 replied to rvdveen27's topic in MySQL Help
I added that like you said as following: $query = " SELECT u.username ,SUM(price) as price ,SUM(costs) as costs ,SUM(cargodamage) as cargodamage ,SUM(price - costs - cargodamage) as profit ,COUNT(driver) as 'deliveries' ,SUM(distance) as 'distance' FROM drive_routes dr INNER JOIN users u ON u.id = dr.driver WHERE status = 2 GROUP BY driver ORDER BY profit DESC "; try { $stmt = $db->prepare($query); $result = $stmt->execute(); } catch(PDOException $ex) { die("Failed to run query: " . $ex->getMessage()); } $rank = 1; while ($rows) { // output row with $rank ++$rank; // increment it } $rows = $stmt->fetchAll(); $count = $stmt->rowcount(); ?> Which results in: I just have no idea what to fill in for the while? -
Trying to get a several rows and colums with data.
rvdveen27 replied to rvdveen27's topic in MySQL Help
Please disregard the above, I managed to get it to work. There's only one more problem. I'd like the query to auto number the results it's getting. Starting from 1. Currently I'm getting the following: