0

This query doesn't show only first row, others work fine. It was working 2 days ago, and it was fine. I dont rememeber that i have changed code in a past days.

        $query='SELECT * FROM cv.users
                LEFT JOIN cv.users_goal on users.user_id =  users_goal.user_id
                LEFT JOIN cv.users_info on users.user_id =  users_info.user_id
                LEFT JOIN cv.users_images on users.user_id =  users_images.user_id
                WHERE users.user_id ='.$user_id.';';


        $data = mysql_query ($query)or die(mysql_error());
        $result = mysql_query($query);

        while($row = mysql_fetch_assoc($result)){
            echo'<div class="cv-info-field cv-field">
                    <div class="cv-info-name">'
                        .$row['user_name'].' '.$row['user_surname'].'
                    </div><div class="cv-info-imgwrap">
                        <img class="cv-info-img" src="'.$row['user_image'].'">
                    </div>'
                    .$row['user_profession'].
                   '<div class="cv-info-userdata">'.$row['user_mobile'].'</br>'
                        .$row['user_email'].'</br>'.$row['user_pc'].'</br>'.$row['user_country'].' - '.$row['user_city'].' - '.$row['user_adress'].'
                    </div>

                </div>
                <b>Goal:</b>
                <div class="cv-goal-field cv-field">'
                    .$row['goal'].
                '</div>';
        }
John Conde
  • 217,595
  • 99
  • 455
  • 496
DimonVersace
  • 325
  • 1
  • 2
  • 7
  • Why are you calling `mysql_query($query)` twice? – John Conde Jun 17 '15 at 17:30
  • My bad. But still doesnt work – DimonVersace Jun 17 '15 at 17:36
  • 1) small suggestion, Use " " in query 2) ` symbol for field name and table name – Karthik Keyan Jun 17 '15 at 17:37
  • There's nothing wrong with this code. You need to make sure the query is actually returning the proper dataset by running your query from the command line or in a tool like phpMyAdmin. – John Conde Jun 17 '15 at 17:38
  • @KarthikKeyan That won't make a difference – John Conde Jun 17 '15 at 17:38
  • @John I am one time suffer this problem i have used this ` symbol form field name to solve the problem just the suggestion – Karthik Keyan Jun 17 '15 at 17:40
  • @KarthikKeyan adding ticks to the column names won't affect this query – John Conde Jun 17 '15 at 17:43
  • @john Surely not affect the query – Karthik Keyan Jun 17 '15 at 17:43
  • If you can, you should [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) [statements](http://php.net/manual/en/pdo.prepared-statements.php) instead, and consider using PDO, [it's really not hard](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Jun 17 '15 at 17:45
  • You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '0,1' at line 5 – DimonVersace Jun 17 '15 at 17:45
  • $query="SELECT * FROM `cv.users` LEFT JOIN `cv.users_goal` on `users.user_id` = `users_goal.user_id` LEFT JOIN `cv.users_info` on `users.user_id` = users_info.user_id LEFT JOIN `cv.users_images` on `users.user_id` = users_images.user_id WHERE `users.user_id` ='.$user_id.' "; – Karthik Keyan Jun 17 '15 at 17:46
  • Its very strange, I havent changed anything – DimonVersace Jun 17 '15 at 17:46
  • Add error reporting to the top of your file(s) right after your opening PHP tag for example ` – Funk Forty Niner Jun 17 '15 at 17:48
  • @DimonVersace after you code do this: `print_r(error_get_last());` to show the error. – alexandreferris Jun 17 '15 at 17:51
  • What error do u got ? – Karthik Keyan Jun 17 '15 at 17:52
  • 3
    you need to update your question with the code you are now using, seeing you were using `mysql_query()` twice. – Funk Forty Niner Jun 17 '15 at 17:56
  • 'Array ( [type] => 8192 [message] => mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead [file] => D:\Software\XAMPP\htdocs\diplomka\pages\etc\DBconnect.php [line] => 3 )' – DimonVersace Jun 17 '15 at 17:57
  • There is **no more support** for `mysql_*` functions, they are [**officially deprecated**](https://wiki.php.net/rfc/mysql_deprecation), **no longer maintained** and will be [**removed**](http://php.net/manual/en/function.mysql-connect.php#warning) in the future. You should update your code with [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) to ensure the functionality of your project in the future. – DarkBee Jun 17 '15 at 18:24
  • thank you for help, guys – DimonVersace Jun 17 '15 at 19:02

0 Answers0