Solved

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

Posted on 2008-06-09
13
181 Views
Last Modified: 2013-12-13
$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
Comment
Question by:mgtm3
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 3
13 Comments
 
LVL 4

Accepted Solution

by:
albuitra earned 250 total points
ID: 21744774
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
 

Author Comment

by:mgtm3
ID: 21744880
its not working
0
 
LVL 4

Expert Comment

by:albuitra
ID: 21744894
put the all code of the page
what error do you obtain ?
0
Industry Leaders: 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!

 

Author Comment

by:mgtm3
ID: 21744942
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
 
LVL 4

Expert Comment

by:albuitra
ID: 21744988
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
 

Author Comment

by:mgtm3
ID: 21745014

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
 
LVL 12

Expert Comment

by:Rok-Kralj
ID: 21745043
just use



echo mysql_error();

Open in new window

0
 
LVL 12

Assisted Solution

by:Rok-Kralj
Rok-Kralj earned 250 total points
ID: 21745055
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
 
LVL 4

Expert Comment

by:albuitra
ID: 21745051
excuseme
I wrote link1, where is linkl
what is the line 40 in your script ?
0
 
LVL 4

Expert Comment

by:albuitra
ID: 21745065
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
 

Author Comment

by:mgtm3
ID: 21745070
its not working :(

please help
0
 
LVL 12

Expert Comment

by:Rok-Kralj
ID: 21745072
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
 

Author Closing Comment

by:mgtm3
ID: 31465462
u have been very helpfull
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question