Solved

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

Posted on 2008-06-09
13
183 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
Independent Software Vendors: 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

688 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