Solved

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

Posted on 2008-06-09
13
177 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
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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

920 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

12 Experts available now in Live!

Get 1:1 Help Now