Jump to content

Catchable fatal error: Object of class mysqli could not be converted to string


Recommended Posts

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!!! :happy-04:

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.