What's new

Bakit kaya ganito error nya

loktoy

Eternal Poster
Joined
Oct 20, 2014
Posts
1,168
Solutions
2
Reaction
103
Points
497
Age
30
Parse error: syntax error, unexpected token "," in C:\xampp\htdocs\Innerjoin\user\postinsert.php on line 27

<?php
if(isset($_POST['post'])){
$page_content = $_POST['post_content'];
$slq = mysqli_prepare ($con, "INSERT INTO post (comment, date_created, user_id) values (?, ?, ?, ?)");
$mysqli_stmt_bind_param = ($slq, "sssi", $page_content, strtotime(date("Y-m-d h:i:sa")), $user_id);
$mysqli_stmt_execute($slq); }
?>
 
The error message you're seeing indicates a syntax error in your code. Specifically, there is an unexpected token "," on line 27 of your file "postinsert.php".

Looking at your code, it seems that the issue lies in the mysqli_prepare function call and the subsequent mysqli_stmt_bind_param function call. The mysqli_prepare function is used to create a prepared statement, and the mysqli_stmt_bind_param function is used to bind variables to the placeholders in the prepared statement.

However, there are a couple of issues with the code:

1. In the mysqli_prepare function call, you are specifying four placeholders in the SQL statement ("?, ?, ?, ?"), but you are only providing three values in the mysqli_stmt_bind_param function call ("sssi", $page_content, strtotime(date("Y-m-d h:i:sa")), $user_id). This is causing a mismatch in the number of placeholders and values, hence the syntax error.

To fix this, you need to remove one of the placeholders in the mysqli_prepare function call. Since you have three values to bind, you should only have three placeholders in the SQL statement. So the corrected line should be:

PHP:
$slq = mysqli_prepare($con, "INSERT INTO post (comment, date_created, user_id) values (?, ?, ?)");

2. In the mysqli_stmt_bind_param function call, you are not calling the function correctly. The correct syntax is:

PHP:
mysqli_stmt_bind_param($slq, "sssi", $page_content, strtotime(date("Y-m-d h:i:sa")), $user_id);

Note that you should not assign the function call to a variable, as you did with $mysqli_stmt_bind_param. Instead, just call the function directly.

With these corrections, your code should look like this:

PHP:
<?php
if (isset($_POST['post'])) {
    $page_content = $_POST['post_content'];
    $slq = mysqli_prepare($con, "INSERT INTO post (comment, date_created, user_id) VALUES (?, ?, ?)");
    mysqli_stmt_bind_param($slq, "ssi", $page_content, strtotime(date("Y-m-d h:i:sa")), $user_id);
    mysqli_stmt_execute($slq);
}
?>

Make sure to also check if you have initialized and established a connection to your database before executing this code.
 
The error message you're seeing indicates a syntax error in your code. Specifically, there is an unexpected token "," on line 27 of your file "postinsert.php".

Looking at your code, it seems that the issue lies in the mysqli_prepare function call and the subsequent mysqli_stmt_bind_param function call. The mysqli_prepare function is used to create a prepared statement, and the mysqli_stmt_bind_param function is used to bind variables to the placeholders in the prepared statement.

However, there are a couple of issues with the code:

1. In the mysqli_prepare function call, you are specifying four placeholders in the SQL statement ("?, ?, ?, ?"), but you are only providing three values in the mysqli_stmt_bind_param function call ("sssi", $page_content, strtotime(date("Y-m-d h:i:sa")), $user_id). This is causing a mismatch in the number of placeholders and values, hence the syntax error.

To fix this, you need to remove one of the placeholders in the mysqli_prepare function call. Since you have three values to bind, you should only have three placeholders in the SQL statement. So the corrected line should be:

PHP:
$slq = mysqli_prepare($con, "INSERT INTO post (comment, date_created, user_id) values (?, ?, ?)");

2. In the mysqli_stmt_bind_param function call, you are not calling the function correctly. The correct syntax is:

PHP:
mysqli_stmt_bind_param($slq, "sssi", $page_content, strtotime(date("Y-m-d h:i:sa")), $user_id);

Note that you should not assign the function call to a variable, as you did with $mysqli_stmt_bind_param. Instead, just call the function directly.

With these corrections, your code should look like this:

PHP:
<?php
if (isset($_POST['post'])) {
    $page_content = $_POST['post_content'];
    $slq = mysqli_prepare($con, "INSERT INTO post (comment, date_created, user_id) VALUES (?, ?, ?)");
    mysqli_stmt_bind_param($slq, "ssi", $page_content, strtotime(date("Y-m-d h:i:sa")), $user_id);
    mysqli_stmt_execute($slq);
}
?>

Make sure to also check if you have initialized and established a connection to your database before executing this code.
ito po bagong error nya

Notice: Only variables should be passed by reference in C:\xampp\htdocs\Innerjoin\user\postinsert.php on line 26

Fatal error
: Uncaught mysqli_sql_exception: Unknown column 'regisration.user_id' in 'on clause' in C:\xampp\htdocs\Innerjoin\user\postinsert.php:33 Stack trace: #0 C:\xampp\htdocs\Innerjoin\user\postinsert.php(33): mysqli_query(Object(mysqli), 'SELECT * FROM p...') #1 {main} thrown in C:\xampp\htdocs\Innerjoin\user\postinsert.php on line 33
ito po code ko

<?php
// include navigation with connection and session
include "../partials/newnav.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Posted</title>
<link href="You do not have permission to view the full content of this post. Log in or register now." rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="You do not have permission to view the full content of this post. Log in or register now." integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="You do not have permission to view the full content of this post. Log in or register now." integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
<script src="You do not have permission to view the full content of this post. Log in or register now."
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</head>
<body>
<?php
if (isset($_POST['post'])) {
$page_content = $_POST['post_content'];
$slq = mysqli_prepare($con, "INSERT INTO post (comment, date_created, user_id) VALUES (?, ?, ?)");
mysqli_stmt_bind_param($slq, "ssi", $page_content, strtotime(date("Y-m-d h:i:sa")), $user_id);
mysqli_stmt_execute($slq);
}
?>
<?php
// display query from post database
$post_query = mysqli_query($con, "SELECT * FROM post left join registration on regisration.user_id = post.user_id order by dated_posted DESC limit 1 ") or die(mysqli_error());
$result = mysqli_num_rows($post_query);
if($result > 0) {
while ($post_row = mysqli_fetch_array($post_query)){
$id = $post_row['comment_id'];
$uid = $post_row['user_id'];
$postedby = $post_row['username'];
}

} else {
echo "No Existing Comment";
}
?>
<!-- body of posted -->
<div class="container col-md-6 bg-body-tertiary border">
<h5>Posted by: <a href="#" style= "margin-left:10px; text-decoration:none;"> <?php echo $posted_by; ?></a></h5>
<h1><?php echo $post_row['comment'] ?></h1>
</div>

</body>
</html>
 
ito po bagong error nya

Notice: Only variables should be passed by reference in C:\xampp\htdocs\Innerjoin\user\postinsert.php on line 26

Fatal error
: Uncaught mysqli_sql_exception: Unknown column 'regisration.user_id' in 'on clause' in C:\xampp\htdocs\Innerjoin\user\postinsert.php:33 Stack trace: #0 C:\xampp\htdocs\Innerjoin\user\postinsert.php(33): mysqli_query(Object(mysqli), 'SELECT * FROM p...') #1 {main} thrown in C:\xampp\htdocs\Innerjoin\user\postinsert.php on line 33
ito po code ko

<?php
// include navigation with connection and session
include "../partials/newnav.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Posted</title>
<link href="You do not have permission to view the full content of this post. Log in or register now." rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="You do not have permission to view the full content of this post. Log in or register now." integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="You do not have permission to view the full content of this post. Log in or register now." integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
<script src="You do not have permission to view the full content of this post. Log in or register now."
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</head>
<body>
<?php
if (isset($_POST['post'])) {
$page_content = $_POST['post_content'];
$slq = mysqli_prepare($con, "INSERT INTO post (comment, date_created, user_id) VALUES (?, ?, ?)");
mysqli_stmt_bind_param($slq, "ssi", $page_content, strtotime(date("Y-m-d h:i:sa")), $user_id);
mysqli_stmt_execute($slq);
}
?>
<?php
// display query from post database
$post_query = mysqli_query($con, "SELECT * FROM post left join registration on regisration.user_id = post.user_id order by dated_posted DESC limit 1 ") or die(mysqli_error());
$result = mysqli_num_rows($post_query);
if($result > 0) {
while ($post_row = mysqli_fetch_array($post_query)){
$id = $post_row['comment_id'];
$uid = $post_row['user_id'];
$postedby = $post_row['username'];
}

} else {
echo "No Existing Comment";
}
?>
<!-- body of posted -->
<div class="container col-md-6 bg-body-tertiary border">
<h5>Posted by: <a href="#" style= "margin-left:10px; text-decoration:none;"> <?php echo $posted_by; ?></a></h5>
<h1><?php echo $post_row['comment'] ?></h1>
</div>

</body>
</html>
The new error you're encountering is a "Notice: Only variables should be passed by reference" on line 26, and a "Fatal error: Uncaught mysqli_sql_exception: Unknown column 'regisration.user_id' in 'on clause'" on line 33.

1. Notice: Only variables should be passed by reference:
The notice on line 26 is caused by passing the result of a function directly as a parameter in the mysqli_query function call. To resolve this, you need to assign the result of the function to a variable before passing it as a parameter. Modify the line 26 like this:

PHP:
$post_query = mysqli_query($con, "SELECT * FROM post left join registration on registration.user_id = post.user_id order by dated_posted DESC limit 1 ") or die(mysqli_error($con));

By adding the $con variable as a parameter to the mysqli_error function, you will be able to see the specific error message returned by MySQL, if any.

2. Fatal error: Unknown column 'regisration.user_id' in 'on clause':
The fatal error on line 33 is caused by a typo in the SQL query. You misspelled "registration" as "regisration" in the JOIN condition. Modify the query on line 33 like this:

PHP:
$post_query = mysqli_query($con, "SELECT * FROM post left join registration on registration.user_id = post.user_id order by dated_posted DESC limit 1 ") or die(mysqli_error($con));

Make sure to update the spelling of "registration" in both the JOIN condition and the table name.

After making these changes, save the file and try running your code again. The errors should be resolved.
 
The new error you're encountering is a "Notice: Only variables should be passed by reference" on line 26, and a "Fatal error: Uncaught mysqli_sql_exception: Unknown column 'regisration.user_id' in 'on clause'" on line 33.

1. Notice: Only variables should be passed by reference:
The notice on line 26 is caused by passing the result of a function directly as a parameter in the mysqli_query function call. To resolve this, you need to assign the result of the function to a variable before passing it as a parameter. Modify the line 26 like this:

PHP:
$post_query = mysqli_query($con, "SELECT * FROM post left join registration on registration.user_id = post.user_id order by dated_posted DESC limit 1 ") or die(mysqli_error($con));

By adding the $con variable as a parameter to the mysqli_error function, you will be able to see the specific error message returned by MySQL, if any.

2. Fatal error: Unknown column 'regisration.user_id' in 'on clause':
The fatal error on line 33 is caused by a typo in the SQL query. You misspelled "registration" as "regisration" in the JOIN condition. Modify the query on line 33 like this:

PHP:
$post_query = mysqli_query($con, "SELECT * FROM post left join registration on registration.user_id = post.user_id order by dated_posted DESC limit 1 ") or die(mysqli_error($con));

Make sure to update the spelling of "registration" in both the JOIN condition and the table name.

After making these changes, save the file and try running your code again. The errors should be resolved.
ito na lang po isa ito po error

Notice: Only variables should be passed by reference in C:\xampp\htdocs\Innerjoin\user\postinsert.php on line 26
code ko

<?php
if (isset($_POST['post'])) {
$page_content = $_POST['post_content'];
$slq = mysqli_prepare($con, "INSERT INTO post (comment, date_created, user_id) VALUES (?, ?, ?)");
mysqli_stmt_bind_param($slq, "ssi", $page_content, strtotime(date("Y-m-d h:i:sa")), $user_id);
mysqli_stmt_execute($slq);
}
?>
 
ito na lang po isa ito po error

Notice: Only variables should be passed by reference in C:\xampp\htdocs\Innerjoin\user\postinsert.php on line 26
code ko

<?php
if (isset($_POST['post'])) {
$page_content = $_POST['post_content'];
$slq = mysqli_prepare($con, "INSERT INTO post (comment, date_created, user_id) VALUES (?, ?, ?)");
mysqli_stmt_bind_param($slq, "ssi", $page_content, strtotime(date("Y-m-d h:i:sa")), $user_id);
mysqli_stmt_execute($slq);
}
?>
The error you're encountering is a "Notice: Only variables should be passed by reference" on line 26.

This notice is usually triggered when a function expects a parameter passed by reference, but a non-variable value is provided instead. In your case, it seems that the issue is with the mysqli_stmt_bind_param function call.

To resolve this, you need to assign the result of the mysqli_prepare function to a variable before passing it as a parameter to the mysqli_stmt_bind_param function. Here's the corrected code:

PHP:
<?php
if (isset($_POST['post'])) {
    $page_content = $_POST['post_content'];
    $slq = mysqli_prepare($con, "INSERT INTO post (comment, date_created, user_id) VALUES (?, ?, ?)");
    mysqli_stmt_bind_param($slq, "ssi", $page_content, strtotime(date("Y-m-d h:i:sa")), $user_id);
    mysqli_stmt_execute($slq);
}
?>

Make sure that you have established a valid database connection and that the $con variable is set properly before executing this code.
 
The error you're encountering is a "Notice: Only variables should be passed by reference" on line 26.

This notice is usually triggered when a function expects a parameter passed by reference, but a non-variable value is provided instead. In your case, it seems that the issue is with the mysqli_stmt_bind_param function call.

To resolve this, you need to assign the result of the mysqli_prepare function to a variable before passing it as a parameter to the mysqli_stmt_bind_param function. Here's the corrected code:

PHP:
<?php
if (isset($_POST['post'])) {
    $page_content = $_POST['post_content'];
    $slq = mysqli_prepare($con, "INSERT INTO post (comment, date_created, user_id) VALUES (?, ?, ?)");
    mysqli_stmt_bind_param($slq, "ssi", $page_content, strtotime(date("Y-m-d h:i:sa")), $user_id);
    mysqli_stmt_execute($slq);
}
?>

Make sure that you have established a valid database connection and that the $con variable is set properly before executing this code.
ayaw pa rin mawala
 
ayaw pa rin mawala
I apologize for the confusion. It seems that the error still persists even after the previous suggestions. Let's try a different approach to resolve the issue.

The "Notice: Only variables should be passed by reference" notice is related to the second parameter of the mysqli_stmt_bind_param function, which expects variables to be passed by reference.

To fix this, you can assign the values of strtotime(date("Y-m-d h:i:sa")) and $user_id to separate variables before calling the mysqli_stmt_bind_param function. Here's the updated code:

```php
<?php
if (isset($_POST['post'])) {
$page_content = $_POST['post_content'];
$date_created = strtotime(date("Y-m-d h:i:sa"));
$uid =
 
I apologize for the confusion. It seems that the error still persists even after the previous suggestions. Let's try a different approach to resolve the issue.

The "Notice: Only variables should be passed by reference" notice is related to the second parameter of the mysqli_stmt_bind_param function, which expects variables to be passed by reference.

To fix this, you can assign the values of strtotime(date("Y-m-d h:i:sa")) and $user_id to separate variables before calling the mysqli_stmt_bind_param function. Here's the updated code:

```php
<?php
if (isset($_POST['post'])) {
$page_content = $_POST['post_content'];
$date_created = strtotime(date("Y-m-d h:i:sa"));
$uid =
parang putol po
 

Similar threads

Back
Top