0

I'm trying to make a query from my MySQL database here is the code

<?php
     $link = new MySQLi('localhost','root','Rrtynt','copy');
    if(isset($_POST['id'])){
        $name = $_POST['id'];
        $profile = 'profile';                
        $thestring = $name.$profile;
       //echo $thestring;

       $result = $link->query("SELECT Email,Name,idauth FROM user WHERE Email = '$name'");
       echo $result;
        }
?>

the code for the query

$result = $link->query("SELECT Email,Name,idauth FROM user WHERE Email = '$name'");

works in a different php script the same exact code but it keeps giving me http 500 error, I'm using this to post from a javascript file

$.post("/getfirstfolder.php", { id: value1 }, function (data) {
                            cop = data;
                            console.log("Data: " + data);
                        });

if I take out

 $result = $link->query("SELECT Email,Name,idauth FROM user WHERE Email = '$name'");

and just echo $thestring it works fine, I cant figure out the problem so thank you for your time and your help is greatly appreciated

JRowan
  • 6,824
  • 8
  • 40
  • 59

1 Answers1

0

The fact that you mentioned $thestring, makes me think that perhaps you should be using $thestring as the parameter to the query like this:

$result = $link->query("SELECT Email,Name,idauth FROM user WHERE Email = '$thestring'");
user212514
  • 3,110
  • 1
  • 15
  • 11
  • no user is the table for that query, it works in another script so I just tried to use it as a template "which doesn't work" but works in a different script, $thstring is the name of the table that I'm eventually going to query when I get working query code – JRowan Apr 17 '16 at 06:56
  • but $name will work in that query because its an email address "should work" – JRowan Apr 17 '16 at 06:58
  • Can you capture the error message? Here's an example: http://stackoverflow.com/a/15553741/212514 – user212514 Apr 17 '16 at 07:01
  • I tried to catch it but this is all I get in the console HTTP500: SERVER ERROR - The server encountered an unexpected condition that prevented it from fulfilling the request. (XHR): POST - http://localhost:50976/getfirstfolder.php – JRowan Apr 17 '16 at 07:05
  • I'm getting this error Call to a member function fetch_assoc() on a non-object – JRowan Apr 17 '16 at 07:36