• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 188
  • Last Modified:

how can i know if the mysqli worked or not ? is there an error reporting function?

$f = "INSERT INTO poll3 (op1,op2,op3,op4,op5,subject,gen) VALUES ($op1,$op2,$op3,$op4,$op5,$subject,$gen)";
include 'cpoll.php';
mysqli_query($link,$f);

i am doing this and nothing happens so is there any function to get the error'?
0
mgtm3
Asked:
mgtm3
  • 5
  • 5
  • 3
2 Solutions
 
albuitraCommented:
you can capture the result of mysql_query
$result = $mysql_query(...)
IF there is a problem, it returns FALSE and you can use mysql_error ($link) to get the text
0
 
mgtm3Author Commented:
its not working
0
 
albuitraCommented:
put the all code of the page
what error do you obtain ?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
mgtm3Author Commented:
this is what i do and nothing goes to table poll3
$link1 = mysqli_connect("localhost" , "root", "232323113" , "poll");
 
$f = "INSERT INTO poll3 (op1,op2,op3,op4,op5,subject,gen) VALUES ($op1,$op2,$op3,$op4,$op5,$subject,$gen)";
 
$result = mysqli_query($link1,$f);
echo $result;

Open in new window

0
 
albuitraCommented:
Are you sure the session is open ?
Try with this
$link1 = mysqli_connect("localhost" , "root", "232323113" , "poll");
if ( $link1 )
{
$f = "INSERT INTO poll3 (op1,op2,op3,op4,op5,subject,gen) VALUES ($op1,$op2,$op3,$op4,$op5,$subject,$gen)";
 $result = mysqli_query($link1,$f);
if ($result == FALSE )
echo mysql_error($link1);
}
else
{
echo mysql_error($link1);
}
0
 
mgtm3Author Commented:

Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in C:\wamp\www\poll\makepoll1.php on line 40


this what i got
why?
0
 
Rok-KraljCommented:
just use



echo mysql_error();

Open in new window

0
 
Rok-KraljCommented:
or:

 or die(mysql_error());
$link1 = mysqli_connect("localhost" , "root", "232323113" , "poll");
 
$f = "INSERT INTO poll3 (op1,op2,op3,op4,op5,subject,gen) VALUES ($op1,$op2,$op3,$op4,$op5,$subject,$gen)";
 
$result = mysqli_query($link1,$f) or die(mysql_error());
echo $result;

Open in new window

0
 
albuitraCommented:
excuseme
I wrote link1, where is linkl
what is the line 40 in your script ?
0
 
albuitraCommented:
sorry,  i don't post the correction
$linkl = mysqli_connect("localhost" , "root", "232323113" , "poll");
if ( $linkl )
{
$f = "INSERT INTO poll3 (op1,op2,op3,op4,op5,subject,gen) VALUES ($op1,$op2,$op3,$op4,$op5,$subject,$gen)";
 $result = mysqli_query($linkl,$f);
if ($result == FALSE )
echo mysql_error($linkl);
}
else
{
echo mysql_error();
}

Open in new window

0
 
mgtm3Author Commented:
its not working :(

please help
0
 
Rok-KraljCommented:
Try my upper solution or this:

mysqli_* functions are deprecated, use mysql_* instead.
$link1 = mysql_connect("localhost" , "root", "232323113" , "poll");
 
$f = "INSERT INTO poll3 (op1,op2,op3,op4,op5,subject,gen) VALUES ($op1,$op2,$op3,$op4,$op5,$subject,$gen)";
 
$result = mysql_query($link1,$f) or die(mysql_error());
echo $result;

Open in new window

0
 
mgtm3Author Commented:
u have been very helpfull
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now