Jump to content

mysqli does not work with wamp?


Recommended Posts

Just like any other extension. If it's WampServer you're using, click on it's icon in tray, go to PHP > PHP Extensions  and make sure there's a tick next to php_mysqli. If it's there already (by default it should) then there's something else wrong with what you're doing.

Link to comment
Share on other sites

here bro see

 

<?php
//check for required fields from the form
if ((!$_POST["topic_owner"]) || (!$_POST["topic_title"]) ||
(!$_POST["post_text"])) {
     header("Location: addtopic.html");
     exit;
}

//connect to server
$mysqli = mysqli_connect("localhost", "root", "demo", "forums");

//create and issue the first query
$add_topic = "INSERT INTO forum_topics (topic_title, topic_create_
              time, topic_owner) VALUES ('".$_POST["topic_title"]."',now(),
               '".$_POST["topic_owner"]."')";
$add_topic_res = mysqli_query($mysqli, $add_topic_sql)
                  or die(mysqli_error($mysqli));

//get the id of the last query
$topic_id = mysqli_insert_id($mysqli);

//create and issue the second query
$add_post_sql = "INSERT INTO forum_posts (topic_id,post_text,
                  post_create_time, post_owner) VALUES ('".$topic_id."',
                 '".$_POST["post_text"]."', now(),
                 '".$_POST["topic_owner"]."')";
$add_post_res = mysqli_query($mysqli, $add_post_sql)
                 or die(mysqli_error($mysqli));

  //close connection to mysqli
mysqli_close($mysqli);

//create nice message for user
$display_block = "<P>The <strong>".$_POST["topic_title"]."</strong>
topic has been created.</p>";
?>
<html>
<head>
<title>New Topic Added</title>
</head>
<body>
<h1>New Topic Added</h1>
<?php echo $display_block; ?>
</body>
</html>

 

the mysql errors also wont show nomore i dunno whats up with my wamp. the mysqli is l=ticked aswell but this script wont work

Link to comment
Share on other sites

  • 2 weeks later...

Comment these lines at the start out

if ((!$_POST["topic_owner"]) || (!$_POST["topic_title"]) || (!$_POST["post_text"]))
{
header("Location: addtopic.html");
exit;
}

 

And do as Mchl stated with the echo. If this works, but doesn't work when the above line is uncommented.. then theres your problem.

If the echo does get displayed, then it might be that Mysqli is having issues somewhere...

 

(Sorry for reviving old post, it hasn't been noted if the problem has been fixed)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.