[Solved] Unable to insert data in MySQL database [duplicate]

I suggest using PDO or MYSQLi because MySQL_ is depreciated. Not only that, you’re not escaping your values and are exposing yourself to some issues such as MySQL injection $pdo = new PDO(“mysql:host=localhost;dbname=db”,”root”,”password”); $query = $pdo->prepare(“INSERT INTO `metabase` (url, title, image, description) VALUES(:url, :title, :image, :descr)”); $query->bindValue(“:url”, “http://www.imgur.com”, PDO::PARAM_STR); $query->bindValue(“:title”, $title, PDO::PARAM_STR); $query->bindValue(“:image”, $image, PDO::PARAM_STR); … Read more

[Solved] SELECT from table with three foregin keys to one table [closed]

Okay, it’s Saturday night and I’m feeling mellow enough to tackle this without a data model. You have given us the names of the three lookup tables (subjects, opinions, users) but not the actual structures and columns. So I’m making some guesses. select subjects.name as subject_name , opinions.value , o_users.name as opinion_guy , p_users.name as … Read more

[Solved] SQL Multiple request

Try this instead: $result = doQuery(“SELECT DISTINCT c.PkID, c.CategoryName FROM ” . HC_TblPrefix . “categories c WHERE c.IsActive = 1 AND c.PkID IN (‘”. implode(“‘, ‘”, explode(“,”, $catIDs)) .”‘) ORDER BY c.CategoryName”); The reason your loop is only returning the last result is because you overwrite $resultCat every time, so when your loop is done, … Read more

[Solved] Error in PHP Search [duplicate]

You should check if $_POST[‘searchterm’] is set first. It will only be set when the form is submitted. Also don’t use Mysql_ functions. They are deprecated. Would advice you to use MySQLI since they have protection against SQL Injection attacks etc. if(isset($_POST[‘searchterm’])) { $search = mysql_real_escape_string($_POST[‘searchterm’]); $find_books = mysql_query(“SELECT * FROM `listings` WHERE `title` LIKE … Read more

[Solved] Setting up a log-in for a website using PHP [closed]

in a nutshell: login.php <?php session_start(); function hhb_tohtml($str) { return htmlentities($str, ENT_QUOTES | ENT_HTML401 | ENT_SUBSTITUTE | ENT_DISALLOWED, ‘UTF-8’, true); } $accounts=array( //username =>password ‘smith’=>’smell’, ‘admin’=>’password’, ‘guest’=>’guestpass’ ); if(array_key_exists(‘submit’,$_POST)){ if(!array_key_exists(‘username’,$_POST)){ $username=””; } else { $username=$_POST[‘username’]; } if(!array_key_exists(‘password’,$_POST)){ $password=”; }else { $password=$_POST[‘password’]; } if(!array_key_exists($username,$accounts)){ die(‘This username does not exist.’); } if($accounts[$username]!==$password){ die(‘wrong password!’); } $_SESSION[‘logged_in’]=true; $_SESSION[‘username’]=$username; … Read more

[Solved] Insert into a table MYSQL

Ok, there was a syntax error. mysql_query(“INSERT INTO privado (usuario_nombre, titulo, partitura, video, instrumentos, valoracion, votos, descripcion, etiquetas) VALUES (‘”.$nick.”‘, ‘”.$titulo.”‘, ‘”.$partitura.”‘, ‘”.$video.”‘, ‘”.$instrumentos.”‘, 0, 0, ‘”.$descripcion.”‘, ‘”.$etiquetas.”‘)”); There was a braket missing. Thanks for your help. 1 solved Insert into a table MYSQL

[Solved] How do I convert this Access Query to mySQL query

The query works in MySQL when the statement is as generated by Access iteself. No change required. Here is the answer below: FROM qryvw_employees INNER JOIN (tbl_clients INNER JOIN tbl_assignments ON tbl_clients.`PAN` = tbl_assignments.`PAN` INNER JOIN tbl_tasks ON tbl_assignments.`Assignment_ID` = tbl_tasks.`Assignment_ID` INNER JOIN qryvw_subtasks ON tbl_tasks.`TaskID` = qryvw_subtasks.`TaskID`) ON qryvw_employees.`ID` = tbl_tasks.`Assigned_To` solved How do … Read more

[Solved] Display the different salary figures earned by faculty members arranged in descending order [closed]

As I understand it you want to have a list of unique salary values in descending order. This is how you can achieve it: SELECT Salary FROM faculty group by Salary order by Salary desc Alternative: SELECT distinct(Salary) FROM faculty order by Salary desc This will give you all the salaries in descending order. If … Read more

[Solved] Update Table1 From table 2

You can join the two tables in your UPDATE query (read about it in the documantation): UPDATE `Table 1` t1 JOIN `Table 2` t2 ON t1.ID = t2.ID SET t1.endtime = t2.starttime 2 solved Update Table1 From table 2

[Solved] How to list all ratings received by user

Ok, some people here thinks is funny to downvote a post, well i’m posting the solution cause i know that it can be helpfull to. This is the Query i built: SELECT u.usuario, u.id_usuario, d.id, v.valoracion, v.fecha FROM icar_valoraciones v JOIN icar_dibujos d ON v.id_dibujo = d.id JOIN icar_usuarios u ON v.id_quien = u.id_usuario WHERE … Read more

[Solved] How to get second MAXIMUM DATE in MYSQL

It wasn’t fun to read your query, but I think the problem is here: LEFT JOIN ( SELECT max(notification_date) notification_date, client_id FROM og_ratings WHERE notification_date NOT IN ( SELECT max(notification_date) FROM og_ratings ) if you want the maximum date for every client you need to GROUP BY client_id: SELECT client_id, max(notification_date) notification_date FROM og_ratings GROUP … Read more

[Solved] php code for multiple search box after connecting to mysql [closed]

So you can try change it to something like this: <form method=”post” action=”example.php” id=”searchform”> <input type=”text” name=”keyword”> <input type=”submit” name=”submit” value=”submit”> </form> if(isset($_POST[‘submit’])){ $name=$_POST[‘keyword’]; $statement = $myconnection->prepare(“SELECT * FROM OL_trans WHERE (ort LIKE ‘%$name%’) OR (plz LIKE ‘%$name%’) OR (vorname LIKE ‘%$name%’)”); $statement->execute(); $key = $statement->fetchall(); foreach($key as $value){ echo ‘<br/>’.$value[‘vorname’]. ‘ – ‘.$value[‘nachname’]. ‘ … Read more