Jump to content

awjudd

Staff Alumni
  • Posts

    422
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by awjudd

  1. @indie I know I'm coming fairly late, but here is your Regex: \[sharedmedia=core:attachments:(\d+)\] https://rubular.com/r/fOGRTK3l3LcLx1
  2. FAIL ... total fail
  3. Looks like your specified username doesn't have access to your database. ~awjudd
  4. You are missing the definition of what you are actually joining your two tables on as well as you need to prefix your tables in your WHERE clause (which is actually defining your join predicate). SELECT forename, surname, coursetitle FROM srs_student AS s INNER JOIN srs_course AS c ON s.coursecode = c.coursecode
  5. I can fly outside to the right of the screen. If I do that, I don't get hit by any enemies.
  6. As mac_gyver said, you need to change $ID. Right now it is the result from a query, you will need to first grab the row. Or you can change your second query to join against the User table. <!DOCTYPE html> <html> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> User<input type="text" name="user"> <input type="submit"> </form> <?php $user=$_POST['user']; if(isset($user)){ // You need some SQL injection protection here $con=mssql_connect("SERVER","USER","PASSWORD"); $item=mssql_query("select ItemID from PS_GameData.dbo.UserItem AS ui JOIN PS_UserData.dbo.Users AS u ON ui.UserUID = u.UserUID where UserID = '$user' order by MakeTime"); } ?> </body> </html>
  7. If you are going to do that, then you should change the LIKE to an = operator. ~awjudd
  8. Change your original query to grab a COUNT of the rows instead of the actual rows. Then if that count is > 0, then you do your update. <?php $id = ''; $name = "ed"; $year = 2013; $month = "may"; $wins = 48; if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error());exit();} $stmt = $mysqli->prepare("SELECT COUNT(name) AS rowcount FROM compare WHERE name = ? AND month = ? AND year = ?"); $stmt->bind_param('ssi', $name, $month, $year); $stmt->execute(); $count=$stmt->get_result(); printf("Affected rows (SELECT): %d\n", $count['rowcount']); if ($count['rowcount'] > 0) { $stmt = $mysqli->prepare("UPDATE compare SET wins = ? WHERE name = ? AND month = ? AND year = ?"); $stmt->bind_param('isii', $wins, $name, $month, $year); $stmt->execute(); $stmt->close(); } else { $stmt = $mysqli->prepare("INSERT INTO compare VALUES (?, ?, ?, ?, ?)"); $stmt->bind_param('isisi', $id, $name, $year, $month, $wins); $stmt->execute(); $stmt->close(); } ?> Or you could use MySQL's built-in support for doing just that: http://www.kavoir.com/2009/05/mysql-insert-if-doesnt-exist-otherwise-update-the-existing-row.html ~awjudd
  9. One big query. It can hit the index once and do it's business. Since you are doing ORs, you may want to consider switching it to an IN clause. SELECT * FROM `table` WHERE `id` IN ( $id1, $id2 ) ~awjudd
  10. Keep track of the 'previous' value (i.e. previous name) in a variable and then if the current value is the same as the previous value, don't emit it. $previous_name=NULL; foreach($array as $value) { if($value['name']!=$previous_name) { echo $value['name']; $previous_name=$value['name']; } // Display the rest }
  11. There should be an "UPDATE" statement somewhere that it hits. ~awjudd
  12. You are statically calling the find_by_id function but it isn't a static function (i.e. you need an instance to do that). Change it from public function to public static function. ~awjudd
  13. Post the code in the PHP tags rather than forcing people to download it. ~awjudd
  14. Because I'm missing a closing bracket on that line. while (($row=mysql_fetch_assoc($result))!==FALSE) {
  15. You copied my query wrong. You included the aliased field in your backticks. Because of that it is looking for `d.label` verbatim. Also your script is wrong because they don't come out with the alias up front, they come out with the names as they appears. <html> <body> <?php $username="root"; $password=""; $database="db"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT d.label, d.serial, d.exe, d.eal, d.epl, dt.Model, m.Manufacturer FROM fac_Device AS d JOIN fac_DeviceTemplates AS dt ON d.TemplateID = dt.TemplateID JOIN fax_Manufacturer AS m ON dt.ManufacturerID = m.ManufacturerID"; $result=mysql_query($query)or die(mysql_error()); $num=mysql_numrows($result)or die(mysql_error()); mysql_close(); ?> <IMG SRC="http://localhost/dcim/images/logo.png"></IMG> <h2><B>Report<BR></h2></B> <b></B><BR><BR> <table border="0" cellspacing="2" cellpadding="2"> <tr> <td><B><font face="Arial, Helvetica, sans-serif">Device Name</font></B></td> <td><B><font face="Arial, Helvetica, sans-serif">Model</font></B></td> <td><B><font face="Arial, Helvetica, sans-serif">Manufacturer</font></B></td> <td><B><font face="Arial, Helvetica, sans-serif">OS Version</font></B></td> <td><B><font face="Arial, Helvetica, sans-serif">EPL</font></B></td> <td><B><font face="Arial, Helvetica, sans-serif">EAL</font></B></td> <td><B><font face="Arial, Helvetica, sans-serif">EXEMPT</font></B></td> </tr> <?php $i=0; while (($row=mysql_fetch_assoc($result))!==FALSE { echo '<tr> <td><font face="Arial, Helvetica, sans-serif">', $row['label'], '</font></td> <td><font face="Arial, Helvetica, sans-serif">', $row['Model'], '</font></td> <td><font face="Arial, Helvetica, sans-serif">', $row['Manufacturer'], '</font></td> <td><font face="Arial, Helvetica, sans-serif">', $row['serial'], '</font></td> <td><font face="Arial, Helvetica, sans-serif">', $row['exe'], '</font></td> <td><font face="Arial, Helvetica, sans-serif">', $row['eal'], '</font></td> <td><font face="Arial, Helvetica, sans-serif">', $row['epl'], '</font></td> </tr>'; } ?> </table> </body> </html>
  16. SELECT d.label, d.serial, d.exe, d.eal, d.epl, dt.Model, m.Manufacturer FROM fac_Device AS d JOIN fac_DeviceTemplates AS dt ON d.TemplateID = dt.TemplateID JOIN fax_Manufacturer AS m ON dt.ManufacturerID = m.ManufacturerID WHERE d.label = 'server1' A few simple joins and you are good to go. ~awjudd
  17. Happy Pi Day!

    1. Philip
    2. Barand

      Barand

      This side of the pond it's on 22/7

    3. awjudd

      awjudd

      It's both according to Wikipedia ;) ... why not celebrate it twice? :P

       

  18. I agree with KevinM1. If you haven't done good to learn the fundamentals, you won't be ready for frameworks. I started using Laravel recently and haven't minded using it ~awjudd
  19. You have ticks in your query when I'm guessing they should be quotes. // Current $select = "SELECT * FROM games WHERE game=`$get`"; // Should be (if $get is a string) $select = "SELECT * FROM games WHERE game='$get'"; // Should be (if $get is a int) $select = "SELECT * FROM games WHERE game=$get"; Please note: you should either be validating the value in $_GET['game'], using an escape-string type function or database parameters. Otherwise there will be SQL injection. ~awjudd
  20. You need to JSON.parse the array coming back. It reads in from the AJAX call a string, so it doesn't know that it is actually supposed to be an array.
  21. In order to use PDO you don't need to learn how to learn object oriented programming. All you need to do is learn how to use the API which there are a fair number of tutorials laying around. I found this one: http://www.phpro.org/tutorials/Introduction-to-PHP-PDO.html fairly helpful. ~awjudd
  22. But that list isn't a list of entries with a unique category ID. 1 matches dog and horse, while 2 matches cat and bird. If anything, the query you are talking about should only return "bird". One way you could do it is but not 100% correct ... SELECT c.category, c.article_id, c2.name FROM ( SELECT category,MIN(article_id) AS article_id FROM categories GROUP BY category ) AS c JOIN categories AS c2 ON c.category = c2.category AND c.article_id = c2.article_id This will get you the MINIMUM article id for each category and then you can do your match on it. ~awjudd
  23. No you cannot do what you are wanting. Just give up looking. Essentially what you are saying is ... "I need my computer to access the internet when the internet isn't available". ~judda
  24. Those are warnings and they are PHP warnings, nothing to do with mysql ... your paths appear to be wrong for your include. ~awjudd
  25. Please show us your table structure. Should be a simple WHERE clause with an AND in it. ~awjudd
×
×
  • 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.