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>"; ?> Link to comment https://forums.phpfreaks.com/topic/285191-mysqli-code-to-retrieve-info/ Share on other sites More sharing options...
GetFreaky Posted January 8, 2014 Share Posted January 8, 2014 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. Link to comment https://forums.phpfreaks.com/topic/285191-mysqli-code-to-retrieve-info/#findComment-1464387 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! Link to comment https://forums.phpfreaks.com/topic/285191-mysqli-code-to-retrieve-info/#findComment-1464400 Share on other sites More sharing options...
GetFreaky Posted January 8, 2014 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>"; ?> Link to comment https://forums.phpfreaks.com/topic/285191-mysqli-code-to-retrieve-info/#findComment-1464406 Share on other sites More sharing options...
rubyarat2010 Posted January 8, 2014 Author Share Posted January 8, 2014 Thank you so much! Link to comment https://forums.phpfreaks.com/topic/285191-mysqli-code-to-retrieve-info/#findComment-1464488 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.