[Solved] PHP wont connect to mysql database

If you are getting a connection error, chances are your problem will be found on this line: $con = mysqli_connect(“localhost”,”username”,”password”,”database_name”); Are you sure you have got the correct host address, username, password and name of your database schema? You may also want to check that you have the mysqli php extension installed on wherever this … Read more

[Solved] need help to do a mysql query [closed]

Assuming there are no PK/Unique constraint involving Staffid and branchid, follows: select branchid from table group by branchid order by count(staffid) desc limit 5 Guess this will do. 2 solved need help to do a mysql query [closed]

[Solved] How do i format this project

If you want to show the complete data in first row you can do this: $i = 0; while($job = $result->fetch_object()){ if( $i == 0 ) { echo ‘<tr>’; echo ‘<td>’ . $job->JobDate .'</td>’; echo ‘<td>’ . $job->ReportTime.'</td>’; echo ‘<td>’ .$job->StartTime.'</td>’; echo ‘<td>’.$job->CustomerName.'</td>’; echo ‘<td>’.$job->EmployeeName.'</td>’; echo ‘<td>’.$job->EquipmentNumber.'</td>’; echo ‘<td>’.$job->JobDescription.'</td>’; echo ‘<td>’.$job->JobNotes.'</td>’; echo ‘</tr>’; } else … Read more

[Solved] Build dynamic WHERE clause in mySQL

Something like this? $query .= “WHERE 1=1 AND e.id=p.employee_id AND p.office_id=o.id AND (o.office_name=””.mysqli_real_escape_string($officeName).”” OR o.office_name=””.mysqli_real_escape_string($firstName).”” OR o.office_name=””.mysqli_real_escape_string($lastName).””) “; I used mysqli_real_escape_string() here as an example, you should use the correct and necessary precautions to avoid SQL injection in your system. 5 solved Build dynamic WHERE clause in mySQL

[Solved] error mysql_query() expects parameter 1 to be string

Your query should look like this: $insertData = “INSERT INTO facebook (fdId, fullName, email, dob, location, gender, postId) VALUES (‘”.$fbId.”‘,'”.$fullName.”‘,'”.$email.”‘,'”.$new_date.”‘,'”.$location.”‘,'”.$gender.”‘,'”.$postId.”‘)”; mysql_select_db(‘noskunk1_facebook’,$vdb); $result = mysql_query($insertData); if ($result)) { echo “New record created successfully”; } else { echo “Error: ” . $insertData . “<br>” . mysql_error($vdb); } but consider using pdo 3 solved error mysql_query() expects parameter … Read more

[Solved] recurring system my sql query [closed]

Make another table called payments which has – id of payment – userid of user – date they last paid – length of payment Then, to check when a user’s set to expire, SELECT date+length as expy FROM payments WHERE userid = $userid ORDER BY date DESC LIMIT 1 Store dates & lengths as unix … Read more

[Solved] group by count in mysql [closed]

This will give you the number of employees by country. SELECT o.country, COUNT(*) FROM office o INNER JOIN employee e ON e.office_id = o.office_id GROUP BY o.country 0 solved group by count in mysql [closed]

[Solved] ECHO MYSQL RESULT DISPLAY BLANK PAGE [closed]

Rename loja.genesiseries/depoimentos/testemysql.html to loja.genesiseries/depoimentos/testemysql.php <div> <p> <font color=”#bdbdbd”> <?php $sql = “SELECT * FROM opinions ORDER BY id DESC LIMIT 15”; $resultado = mysql_query($sql); while ($linha=mysql_fetch_array($resultado)) { $depoimento = $linha[“depoimento”]; $client = $linha[“client”]; echo “$depoimento”; echo “$client”; } ?> </font> </p> </div> 3 solved ECHO MYSQL RESULT DISPLAY BLANK PAGE [closed]

[Solved] Is there a way to realtime detect if there’s new record in database?

Don’t worry about the performance of polling. With a suitable INDEX, MySQL can handle 100 polls/second — regardless of dataset size. Let’s see SHOW CREATE TABLE and the tentative SELECT to perform the “poll”; I may have further tips. Also, let’s see the admin’s query that needs to ‘trigger’ the workers into action. Surely the … Read more

[Solved] i want to save my Html table data in mysql table in php [closed]

Time to study. PHP With PDO (here you can work with databases using PHP): http://php.net/manual/pt_BR/book.pdo.php Use a POST form to save the data. You need to put each td value inside of a input. http://www.html-form-guide.com/php-form/php-form-post.html You need to create a database (http://dev.mysql.com/doc/refman/5.5/en/create-database.html) and a table (http://dev.mysql.com/doc/refman/5.1/en/create-table.html). And finally insert command, to add the values inside … Read more

[Solved] Fetching last 200 records from table [closed]

include the order by clause to get the last 200 records. SELECT c.member_id,c.message_id, fm.firstname AS fname, up.gender, TIMESTAMPDIFF( YEAR, up.dob, NOW( ) ) AS age, c.upload_img, c.image, c.message_id AS msg_id, c.message AS msg, c.posted_timestamp AS time, c.topic_id AS topic_id, u.croppedpicture_filename,u.picture_filename FROM conversation_messages_tbl c, user_profileinformation_tbl up, user_tbl u, family_member_tbl fm WHERE c.member_id = fm.family_member_id AND up.user_id … Read more

[Solved] How to pass a C# variable with apostrophe through MySql

The quick and dirty fix is to use something like: level = level.Replace(“‘”,”whatever”); but there are still problems with that. It won’t catch other bad characters and it probably won’t even work for edge cases on the apostrophe. The best solution is to not construct queries that way. Instead, learn how to use parameterised queries … Read more