-
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
![](https://forums.phpfreaks.com/uploads/team_phpf_alumni.png)
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
![Rank: Member (2/5) Member](https://forums.phpfreaks.com/uploads/set_resources_1/84c1e40ea0e759e3f1505eb1788ddf3c_default_rank.png)
Member (2/5)
3
Reputation
-
@indie I know I'm coming fairly late, but here is your Regex: \[sharedmedia=core:attachments:(\d+)\] https://rubular.com/r/fOGRTK3l3LcLx1
-
FAIL ... total fail
-
Looks like your specified username doesn't have access to your database. ~awjudd
-
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
-
I can fly outside to the right of the screen. If I do that, I don't get hit by any enemies.
-
MSSQL and PHP Incorrect syntax near 'id'. (severity 15
awjudd replied to NewSQLDev's topic in Microsoft SQL - MSSQL
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> -
If you are going to do that, then you should change the LIKE to an = operator. ~awjudd
-
mysqli: select rows, update if >0 else insert
awjudd replied to wright67uk's topic in PHP Coding Help
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 -
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
-
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 }
-
There should be an "UPDATE" statement somewhere that it hits. ~awjudd
-
Need help fetching an array with a static method
awjudd replied to eldan88's topic in PHP Coding Help
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 -
Post the code in the PHP tags rather than forcing people to download it. ~awjudd
-
Because I'm missing a closing bracket on that line. while (($row=mysql_fetch_assoc($result))!==FALSE) {
-
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>