Solved

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

Posted on 2008-06-09
13
175 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
  • 5
  • 5
  • 3
13 Comments
 
LVL 4

Accepted Solution

by:
albuitra earned 250 total points
Comment Utility
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
Comment Utility
its not working
0
 
LVL 4

Expert Comment

by:albuitra
Comment Utility
put the all code of the page
what error do you obtain ?
0
 

Author Comment

by:mgtm3
Comment Utility
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
Comment Utility
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
Comment Utility

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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 12

Expert Comment

by:Rok-Kralj
Comment Utility
just use



echo mysql_error();

Open in new window

0
 
LVL 12

Assisted Solution

by:Rok-Kralj
Rok-Kralj earned 250 total points
Comment Utility
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
Comment Utility
excuseme
I wrote link1, where is linkl
what is the line 40 in your script ?
0
 
LVL 4

Expert Comment

by:albuitra
Comment Utility
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
Comment Utility
its not working :(

please help
0
 
LVL 12

Expert Comment

by:Rok-Kralj
Comment Utility
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
Comment Utility
u have been very helpfull
0

Featured Post

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now