lauren_etherington Posted March 19, 2014 Author Share Posted March 19, 2014 Also, echoing the query also returns a WSOD..... Quote Link to comment https://forums.phpfreaks.com/topic/286889-catchable-fatal-error-object-of-class-mysqli-could-not-be-converted-to-string/page/2/#findComment-1473152 Share on other sites More sharing options...
Solution lauren_etherington Posted March 19, 2014 Author Solution Share Posted March 19, 2014 Okay so I have an update for anyone else who has this problem. I actually have the query working now and pulling the info based on the ID thanks to changing an i to an s. So when the user clicks Edit on the list of news articles it runs this code: function editnews($i) { ini_set('display_errors',1); error_reporting(E_ALL); $conn = mysqli_connect("mysqli connection string"); if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } $enquery = "SELECT * FROM news WHERE newsid='$i'"; $enresult = mysqli_query($conn, $enquery) or trigger_error($enquery . ' - has encountered an error at:<br />'); if ($enresult) { while ($enrow = mysqli_fetch_array($enresult)) { echo " <form enctype='multipart/form-data' action='functions/newsedit.php' method='post'> <table> <tr> <td>News Ref:</td> <td>" . $i . "<input type='hidden' name='newsid' value='" . $i . "' /><input type='hidden' name='oldim' value='" . $enrow['newsimage'] . "' /></td> </tr> <tr> <td>Title:</td> <td><input type='text' name='title' value='" . $enrow['newstitle'] . "' size='100' /></td> </tr> <tr> <td>Author:</td> <td><input type='text' name='author' value='" . $enrow['newsauthor'] . "' size='100' /></td> </tr> <tr> <td>Status:</td> <td><select name='stat'><option value='enabled' "; if ($enrow['newsstatus'] == "enabled") { echo "selected='selected' "; } echo ">Enabled</option><option value='disabled' "; if ($enrow['newsstatus'] == "disabled") { echo "selected='selected' "; } echo "}>Disabled</option></select> </td> </tr> <tr> <td>Snippettext:</td> <td><textarea name='snip' rows='6' cols='80'>" . $enrow['newssnippet'] . "</textarea></td> </tr> <tr> <td>News story:</td> <td><textarea name='stry' rows='20' cols='80'>" . $enrow['newsarticle'] . "</textarea></td> </tr> <tr> <td>Current image:</td> <td>" . $enrow['newsimage'] . " - <a href='news/" . $enrow['newsimage'] . "' target='_blank'>View Image</a></td> </tr> <tr> <td>Change Image:</td> <td><input type='file' name='file'></td> </tr> <tr> <td colspan='2'><input type='submit' name='submit' value='Edit' /></td> </tr> </table> </form> "; } } else { echo "Oh noes, an error!"; } } ?> This directs to the HTML page where the form will be displayed with this code (This code is disaplyed at the very top of the document - above the doc type: <?php include_once("functions/newseditform.php"); $s = $_GET['i']; ?> While this little bit of code sits somewhere in the body. <?php editnews($s) ?> -- Thanks for all the help guys!!! Quote Link to comment https://forums.phpfreaks.com/topic/286889-catchable-fatal-error-object-of-class-mysqli-could-not-be-converted-to-string/page/2/#findComment-1473162 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.