PHP MySQL INSERT Help

I try to insert into database yet I get an error message even though all the data is inserted into database.

I don’t know why am I getting the error message “mysql_fetch_array(): supplied argument is not a valid MySQL result resource” on this line “if($row=mysql_fetch_array($result))”

Again, all the information is being inserted into the database correctly
[php]<?php

require ‘db.php’;

$title=urldecode($_GET[‘title’]);
$address=urldecode($_GET[‘address’]);
$county=urldecode($_GET[‘county’]);
$city=urldecode($_GET[‘city’]);
$state=urldecode($_GET[‘state’]);
$zipcode=urldecode($_GET[‘zipcode’]);
$start_date=urldecode($_GET[‘start_date’]);
$end_date=urldecode($_GET[‘end_date’]);
$start_time=urldecode($_GET[‘start_time’]);
$end_time=urldecode($_GET[‘end_time’]);
$mainitems=urldecode($_GET[‘mainitems’]);

$sql = (“INSERT INTO posting (title,address,city,start_date,end_date,start_time,end_time,mainitems) VALUES
(’$title’,’$address’,’$city’,’$start_date’,’$end_date’,’$start_time’,’$end_time’,’$mainitems’)”);

$result=mysql_query($sql);

if($row=mysql_fetch_array($result))

{

include ‘post_succesful.php’;

}

else {

echo “ERROR” . mysql_error() ;

}

mysql_close();

?>
[/php]

You are writign the code wrong

[php]if(mysql_num_rows($result) > 0) {
while($row = mysql_fetch_array($result)) { … }
} else {
// show link
} [/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service