rubyarat2010 Posted January 8, 2014 Share Posted January 8, 2014 This code is meant to retrieve a row in a form but it returns nothing, I have tried it many different times even with HTML in it it returns nothing at all. <?php $conn = new mysqli("****", "***", "****"); $conn->select_db('mynotesdatabase'); $result = mysqli_query($conn, "SELECT * FROM" . $_GET['Folder'] . "WHERE Name='" . $_GET['Name'] . "'") or die(mysql_error()); while($row = mysqli_fetch_array($result) or die(mysql_error())) { echo "<br>"; echo $row['Main']; echo "<br>"; } echo "<br/> <a href='javascript:history.back(-1);'>Back</a>"; ?> Quote Link to comment Share on other sites More sharing options...
GetFreaky Posted January 8, 2014 Share Posted January 8, 2014 (edited) Some issues at first glance, there is no spaces here FROM" . $_GET['Folder'] . "WHERE try <?php $conn = new mysqli("****", "***", "****"); $conn->select_db('mynotesdatabase'); $result = $conn->("SELECT * FROM " . $_GET['Folder'] . " WHERE Name='" . $_GET['Name'] . "'") or die(mysql_error()); while($row = mysqli_fetch_array($result) or die(mysql_error())) { echo "<br>"; echo $row['Main']; echo "<br>"; } echo "<br/> <a href='javascript:history.back(-1);'>Back</a>"; ?> Any reason why your table name is from a HTTP var? Also your query is susceptible to unwanted injection. Edited January 8, 2014 by GetFreaky Quote Link to comment Share on other sites More sharing options...
rubyarat2010 Posted January 8, 2014 Author Share Posted January 8, 2014 It is a little "program" I am making to help me with somthign else. I know it is not that safe of a method but only I will be using it. I tried what you put but it kind of gives me the same error you said ( ! ) Parse error: syntax error, unexpected '(', expecting T_STRING or T_VARIABLE or '{' or '$' in C:\wamp\www\NotesWebsite\ViewNote.php on line 4 Thank you for the quick reply! Quote Link to comment Share on other sites More sharing options...
Solution GetFreaky Posted January 8, 2014 Solution Share Posted January 8, 2014 It is a little "program" I am making to help me with somthign else. I know it is not that safe of a method but only I will be using it. I tried what you put but it kind of gives me the same error you said ( ! ) Parse error: syntax error, unexpected '(', expecting T_STRING or T_VARIABLE or '{' or '$' in C:\wamp\www\NotesWebsite\ViewNote.php on line 4 Thank you for the quick reply! sorry I forgot to add the $conn->query try <?php $conn = new mysqli("****", "***", "****"); $conn->select_db('mynotesdatabase'); $result = $conn->query("SELECT * FROM " . $_GET['Folder'] . " WHERE Name='" . $_GET['Name'] . "'") or die(mysql_error()); while($row = mysqli_fetch_array($result) or die(mysql_error())) { echo "<br>"; echo $row['Main']; echo "<br>"; } echo "<br/> <a href='javascript:history.back(-1);'>Back</a>"; ?> Quote Link to comment Share on other sites More sharing options...
rubyarat2010 Posted January 8, 2014 Author Share Posted January 8, 2014 Thank you so much! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.