mamabear0604 Posted May 16, 2011 Share Posted May 16, 2011 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 Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted May 16, 2011 Share Posted May 16, 2011 First replace all the "smart quotes" with normal quotes: “ ” is not the same as " " That error is usually caused by mis-matched curly braces "{ }" or mis-matched quotes. Ken Quote Link to comment Share on other sites More sharing options...
Maq Posted May 16, 2011 Share Posted May 16, 2011 You need regular double quotes. echo "DONE!"; In the future, please place tags around your code. Quote Link to comment Share on other sites More sharing options...
mamabear0604 Posted May 16, 2011 Author Share Posted May 16, 2011 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" ) ); Quote Link to comment Share on other sites More sharing options...
Maq Posted May 16, 2011 Share Posted May 16, 2011 You have a semi-colon and you're using weird quotes again. Change them to ' $new_date = date;( ‘Y-m-d H:i:s’, strtotime("-$day day -$hour hour" ) ); Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted May 16, 2011 Share Posted May 16, 2011 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 Quote Link to comment Share on other sites More sharing options...
mamabear0604 Posted May 16, 2011 Author Share Posted May 16, 2011 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. Quote Link to comment Share on other sites More sharing options...
Maq Posted May 16, 2011 Share Posted May 16, 2011 Change this line to: mysql_select_db($dbname) or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
mamabear0604 Posted May 16, 2011 Author Share Posted May 16, 2011 got that fixed forgot to add my user. Quote Link to comment Share on other sites More sharing options...
mamabear0604 Posted May 16, 2011 Author Share Posted May 16, 2011 I also corrected the line of code that you said. and now it says Updating: 1 Unknown column 'date' in 'field list' Boy the site I pulled this off of had some big errors in it. Ty for your help Quote Link to comment Share on other sites More sharing options...
mamabear0604 Posted May 16, 2011 Author Share Posted May 16, 2011 Got it done thread can be closed. TY for all your help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.