Jump to content

Recommended Posts

Parse error: syntax error, unexpected $end in /home/mamabear/public_html/wordpressdate.php on line 46

 

I have googled this as well as combed through several forums. I have tried editing this code, but for the life of me I just can't seem to figure out what is casuing this error. I am sure by now everything is starting to look the same after staring at it for hours.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body><?php  // define mysql connect
$dbname = "*****";
$dbuser = "*****";
$dbpass = "*****";
$dbhost = "localhost"; // this will usually stay 'localhost'

$my_table = "pa-videos"; // define wordpress table name

$gmt_offset = '-6'; // -8 for California, -5 New York, -6 Missouri etc.

// I'm setting into the future year so WordPress can publish as , else I would use 1 for min and 60 for max, for last 2 months.
$min_days_old = -365; // the minimum number of days old
$max_days_old = 7; // the maximum number of days old

// connect to db
mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname);

$result = mysql_query("SELECT ID FROM $my_table") or die(mysql_error());
while ($l = mysql_fetch_array($result)) {
$post_id = $l['ID']; 
echo "Updating: $post_id
“;

$day = rand($min_days_old, $max_days_old);
$hour = rand(0, 23);

$new_date = date;( ‘Y-m-d H:i:s’, strtotime(“-$day day -$hour hour” ) );
$gmt_new_date = date( ‘Y-m-d H:i:s’, strtotime(“-$day day -$hour hour -$gmt_offset hour” ) );

mysql_query(“UPDATE $my_table SET date=’$new_date’ WHERE ID=’$post_id’” )
or die(mysql_error)));

}

echo “
DONE!”;

?> 

 

 

PLEASE help. I appreciate any help and support someone is able to offer. TY

Link to comment
https://forums.phpfreaks.com/topic/236570-unexpected-end/
Share on other sites

Ok I went through and corrected the smart quotes. and the echo and now i am getting this

Parse error: syntax error, unexpected T_STRING in /home/mamabear/public_html/wordpressdate.php on line 35

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body><?php  // define mysql connect
$dbname = "*****";
$dbuser = "*****";
$dbpass = "*****";
$dbhost = "localhost"; // this will usually stay 'localhost'

$my_table = "pa-videos"; // define wordpress table name

$gmt_offset = '-6'; // -8 for California, -5 New York, -6 Missouri etc.

// I'm setting into the future year so WordPress can publish as , else I would use 1 for min and 60 for max, for last 2 months.
$min_days_old = -365; // the minimum number of days old
$max_days_old = 7; // the maximum number of days old

// connect to db
mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname);

$result = mysql_query("SELECT ID FROM $my_table") or die(mysql_error());
while ($l = mysql_fetch_array($result)) {
$post_id = $l['ID']; 
echo "Updating: $post_id
";

$day = rand($min_days_old, $max_days_old);
$hour = rand(0, 23);

$new_date = date;( ‘Y-m-d H:i:s’, strtotime("-$day day -$hour hour" ) ); 
$gmt_new_date = date( ‘Y-m-d H:i:s’, strtotime("-$day day -$hour hour -$gmt_offset hour" ) );

mysql_query("UPDATE $my_table SET date=’$new_date’ WHERE ID=’$post_id’" )
or die(mysql_error)));

}

echo "DONE!";

?> 

 

Line 35

 $new_date = date;( ‘Y-m-d H:i:s’, strtotime("-$day day -$hour hour" ) ); 

Link to comment
https://forums.phpfreaks.com/topic/236570-unexpected-end/#findComment-1216153
Share on other sites

you have an extra semi-colon after date

 

$new_date = date;(

 

There's still more smart quotes there, open the file in a word editor such as notepad2 and you will see them.

http://sourceforge.net/projects/notepad2/

 

Maq beat me, lol

Link to comment
https://forums.phpfreaks.com/topic/236570-unexpected-end/#findComment-1216163
Share on other sites

well i got almost all the errors over with. now its telling me

 

No database selected

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body><?php  // define mysql connect
$dbname = "*****";
$dbuser = "*****";
$dbpass = "*****";
$dbhost = "localhost"; // this will usually stay 'localhost'

$my_table = "pa_videos"; // define wordpress table name

$gmt_offset = '-6'; // -8 for California, -5 New York, -6 Missouri etc.

// I'm setting into the future year so WordPress can publish as , else I would use 1 for min and 60 for max, for last 2 months.
$min_days_old = -365; // the minimum number of days old
$max_days_old = 7; // the maximum number of days old

// connect to db
mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($dbname);

$result = mysql_query("SELECT ID FROM $my_table") or die(mysql_error());
while ($l = mysql_fetch_array($result)) {
$post_id = $l['ID']; 
echo "Updating: $post_id
";

$day = rand($min_days_old, $max_days_old);
$hour = rand(0, 23);

$new_date = date( 'Y-m-d H:i:s', strtotime("-$day day -$hour hour" ) );
$gmt_new_date = date( 'Y-m-d H:i:s', strtotime("-$day day -$hour hour -$gmt_offset hour" ) );

mysql_query("UPDATE $my_table SET date='$new_date' WHERE ID='$post_id'" )
or die(mysql_error());

}

echo "DONE!";

?> 

 

Am i missing something somewhere. What this is suppose to do is randomize post dates for a wordpress blog. I already have the code for pulling the posts out of myphpadmin. I just want to randomize dates for the posts.

 

Ty so much for your help.

Link to comment
https://forums.phpfreaks.com/topic/236570-unexpected-end/#findComment-1216168
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.