Jump to content

awjudd

Staff Alumni
  • Posts

    422
  • Joined

  • Last visited

  • Days Won

    1

awjudd last won the day on July 19 2021

awjudd had the most liked content!

About awjudd

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

awjudd's Achievements

Member

Member (2/5)

3

Reputation

  1. @indie I know I'm coming fairly late, but here is your Regex: \[sharedmedia=core:attachments:(\d+)\] https://rubular.com/r/fOGRTK3l3LcLx1
  2. Looks like your specified username doesn't have access to your database. ~awjudd
  3. 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
  4. I can fly outside to the right of the screen. If I do that, I don't get hit by any enemies.
  5. 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>
  6. If you are going to do that, then you should change the LIKE to an = operator. ~awjudd
  7. 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
  8. 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
  9. 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 }
  10. There should be an "UPDATE" statement somewhere that it hits. ~awjudd
  11. 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
  12. Post the code in the PHP tags rather than forcing people to download it. ~awjudd
  13. Because I'm missing a closing bracket on that line. while (($row=mysql_fetch_assoc($result))!==FALSE) {
  14. 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>
×
×
  • 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.