I dont know what i am missing... Anyone help me to fix this.Thanks in advancethoufiq"> Getting Warning when inserting datas manually to DB table - Forums

Forums

Getting Warning when inserting datas manually to DB table

mj_web 02 Oct, 2013
Hi,

I am using chronoform "form wizard" and i am inserting my form details to the database table manually. So, I used php script in the custom code action on the submit event. Whenever am submitting the form, the datas are inserting to db table succesfully but it is giving this warning.

warning mysql_fetch_array() expects parameter 1 to be resource boolean given in.....



My code is

<?php
$connect = mysql_connect("localhost", "name", "password");
if(!$connect)
{
die ("Could not connect".mysql_error());
}
$select_db = mysql_select_db("db_name",$connect);
if(!$select_db)
{
die ("Could not connect".mysql_error());
}
$name = $_POST['your_name'];
$email = $_POST['your_email'];
$location = $_POST['your_location'];
$code = $_POST['chrono_verification'];
$enq_ques = $_POST['enq_ques'];
$query = mysql_query("INSERT INTO form_enquiry (name, email, location, code, enq_ques) VALUES ('$name', '$email', '$location', '$code', '$enq_ques')", $connect);
if(!$query)
{
die ("Query failed".mysql_error());
}

while ($result = mysql_fetch_array($query))
{
echo $result['name']."<br />";
echo $result['email']."<br />";
echo $result['location']."<br />";
echo $result['code']."<br />";
echo $result['enq_ques']."<br />";
}
mysql_close($connect);
?>


I dont know what i am missing... Anyone help me to fix this.

Thanks in advance
thoufiq
GreyHead 03 Oct, 2013
Hi mj_web,

This isn't code that I would write - or anything like code that I would write, nothing wrong with that but I can't usefully make any comments.

If you use the Joomla! DB code (the older J1.5-2.5 version) then I'm pretty familiar with that and may be able to spot bugs. I'm slowly learning the Joomla! 3 version too.

Bob
This topic is locked and no more replies can be posted.