mike6256 Posted February 26, 2009 Share Posted February 26, 2009 Hi all I am having some problems with this code--keeps kicking pharse error codes <?php # Connect to the database $dbLink = mysqli_connect("xx.xx.54.10", "root", "xxxxxxxx", "tools"); if(mysqli_connect_errno()) { die("MySQL connection failed: ". mysqli_connect_error()); } # Query for a list of all existing files // just one possibility... $textfield = $_POST['textfield']; $result = mysqli_query($dbLink, "SELECT FileID, FileName, FileMime, FileSize, ToolNumber, Created FROM FileStorage WHERE ToolNumber = '" . mysqli_real_escape_string($dbLink,$textfield) . "'"; # Check if it was successfull if($result) { # Make sure there are some files in there if(mysqli_num_rows($result) == 0) { echo "<p>There are no files in the database</p>"; } else { # Print the top of a table echo "<table width='100%'><tr>"; echo "<td><b>Name</b></td>"; echo "<td><b>Mime</b></td>"; echo "<td><b>Size (bytes)</b></td>"; echo "<td><b>Created</b></td>"; echo "<td><b>Tool Number</b></td>"; echo "<td><b> </b></td>"; echo "</tr>"; # Print each file while($row = mysqli_fetch_assoc($result)) { # Print file info echo "<tr><td>". $row['FileName']. "</td>"; echo "<td>". $row['FileMime']. "</td>"; echo "<td>". $row['FileSize']. "</td>"; echo "<td>". $row['Created']. "</td>"; echo "<td>". $row['ToolNumber']. "</td>"; # Print download link echo "<td><a href='get_file.php?id=". $row['FileID'] ."'>Download</a></td>"; echo "</tr>"; } # Close table echo "</table>"; } # Free the result mysqli_free_result($result); } else { echo "Error! SQL query failed:"; echo "<pre>". $dbLink->error ."</pre>"; } # Close the mysql connection mysqli_close($dbLink); ?> any help would be appreciated Link to comment https://forums.phpfreaks.com/topic/147085-solved-pharse-error/ Share on other sites More sharing options...
samshel Posted February 26, 2009 Share Posted February 26, 2009 Parse errors show line number where the problem is.. so u can easily pinpoint the problem. Link to comment https://forums.phpfreaks.com/topic/147085-solved-pharse-error/#findComment-772171 Share on other sites More sharing options...
mike6256 Posted February 26, 2009 Author Share Posted February 26, 2009 the error is on 17 this is 12-17 $result = mysqli_query($dbLink, "SELECT FileID, FileName, FileMime, FileSize, ToolNumber, Created FROM FileStorage WHERE ToolNumber = '" . mysqli_real_escape_string($dbLink,$textfield) . "'"; Link to comment https://forums.phpfreaks.com/topic/147085-solved-pharse-error/#findComment-772177 Share on other sites More sharing options...
The Little Guy Posted February 26, 2009 Share Posted February 26, 2009 mysqli_real_escape_string($dbLink,$textfield) is wrong, it should look like this: mysqli_real_escape_string($textfield) Link to comment https://forums.phpfreaks.com/topic/147085-solved-pharse-error/#findComment-772180 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.