PHP - Syntax Error Driving Me Crazy!
Ok, so the error I get is Parse error: syntax error, unexpected $end in /home/a3868616/public_html/skin_files/skin_manager.php on line 168. In dreamweaver, it tells me there is an error on line 141, which is the first line to be returned ( Code: [Select]
<table cellspacing="0" class="tableborder" width="85%" align="center">) in the contract function. I've looked at this over and over, and I can't find any brackets that aren't closed. All of the lines of code seem to be in their correct syntax. I was thinking maybe the EOF in the else after the while was causing it, but same errors different line numbers when I removed that. What the hell can it be!? The whole php file is below. <?php class skin_manager{ function show(){ global $DB, $projectx, $func, $game; return <<<EOF <table cellspacing="0" cellpadding="0" width="100%"> <tr> <td width="40%" valign="top"> <table cellspacing="0" class="tableborder" width="100%"> <tr> <td class="mainrow">Manager Page</td> </tr> <tr> <td> <div class="tablepad"> <table cellspacing="0" cellpadding="3" width="100%"> <tr> <td class="row1"><a href="#">Finances</a></td> </tr> <tr> <td class="row2"><a href="manager.php?act=contracts">Contracts</a></td> </tr> <tr> <td class="row1"><a href="#">Holiday Mode</a></td> </tr> </table> </div> </td> </tr> </table> </td> <td width="2%"></td> <td width="40%"> <table cellspacing="0" class="tableborder" width="100%"> <tr> <td class="mainrow">Manager Releases</td> </tr> <tr> <td> <div class="tablepad"> <table cellspacing="0" cellpadding="3" width="100%"> <tr> <td class="rowheader" colspan="2">Singles</td> </tr> <tr> <td class="row2" width="25%">Gold:</td> <td class="row2" width="75%">{$band_name}</td> </tr> <tr> <td class="row1" width="25%">Platinum:</td> <td class="row1" width="75%">{$band_genre}</td> </tr> <tr> <td class="row2" width="25%">Multi-Platinum:</td> <td class="row2" width="75%">{$band_status}</td> </tr> <tr> <td class="row1" width="25%">Number 1:</td> <td class="row1" width="75%">{$band_created}</td> </tr> <tr> <td class="row1" width="25%">Total:</td> <td class="row1" width="75%">{$band_created}</td> </tr> <tr> <td class="rowheader" colspan="2">Albums</td> </tr> <tr> <td class="row2" width="25%">Gold:</td> <td class="row2" width="75%">{$band_name}</td> </tr> <tr> <td class="row1" width="25%">Platinum:</td> <td class="row1" width="75%">{$band_genre}</td> </tr> <tr> <td class="row2" width="25%">Multi-Platinum:</td> <td class="row2" width="75%">{$band_status}</td> </tr> <tr> <td class="row1" width="25%">Number 1:</td> <td class="row1" width="75%">{$band_created}</td> </tr> <tr> <td class="row1" width="25%">Total:</td> <td class="row1" width="75%">{$band_created}</td> </tr> </table> </div> </td> </tr> </table> </td> <td width="18%"></td> </tr> </table> EOF; } // end function show function contract(){ global $DB, $projectx, $func; $contracts_q = $DB->query("SELECT * FROM `contracts` RIGHT JOIN `bands` ON (contracts.contract_band = bands.band_id) LEFT JOIN `labels` ON (contracts.contract_from = labels.label_id) WHERE contracts.contract_manager='{$projectx->member['id']}'"); if($DB->get_num_rows()){ while($row = $DB->fetch_array($contracts_q)){ $pcontracts .= "<tr>"; if($style != 2){ $class = "row2"; $style = 1; }else{ $class = "row1"; $style = 2; } $pcontracts .= "<td class=\"{$class}\" width=\"20%\">{$row['band_name']}</td>"; $pcontracts .= "<td class=\"{$class}\" width=\"20%\">{$row['label_name']}</td>"; $clength = explode(",", $row['contract_length']); $csingles = explode("|", $clength[0]); $calbums = explode("|", $clength[1]); $pcontracts .= "<td class=\"{$class}\" width=\"30%\">{$csingles[0]} singles ({$csingles[1]}% cut), {$calbums[0]} albums ({$calbums[1]}% cut)</td>"; $pcontracts .= "<td class=\"{$class}\" width=\"10%\">{$row['contract_amount']}</td>"; $pcontracts .= "<td class=\"{$class}\" width=\"20%\">Accept / Reject</td>"; $pcontracts .= "</tr>"; } }else{ $pcontracts = <<<EOF <tr> <td class="row2" colspan="5">You have no contracts.</td> </tr> EOF; } return <<<EOF <table cellspacing="0" class="tableborder" width="85%" align="center"> <tr> <td class="mainrow">Contracts</td> </tr> <tr> <td> <div class="tablepad"> <table cellspacing="0" cellpadding="3" width="100%"> <tr> <td class="rowheader" width="20%">Band</td> <td class="rowheader" width="20%">From</td> <td class="rowheader" width="30%">Terms</td> <td class="rowheader" width="10%">Amount</td> <td class="rowheader" width="20%">Decision</td> </tr> </table> </div> </td> </tr> </table> EOF; } // end function contract } // end class skin_manager ?> Similar TutorialsHey guys! The error is that it seems to display EVERYTHING regardless of the if and else statements. Also, it seems to stop evaluating the rest of the document that "includes" this as soon as its done with this one. dbconnect works and all the session vars carry properly... WTF is going on!? <?php session_start(); include 'dbconnect.php'; $username = $_SESSION['username']; $q = mysql_query("SELECT User_type FROM account WHERE username = '$username'") or die(mysql_error()); $permission = mysql_fetch_row($q); $permission = $permission[0]; if(isset($_SESSION['username']) && $permission >= 2){ echo"<div id='page-section-mainmenu'><ul><li><a href=''><span>"; echo $menu001; echo "</span></a></li><li><a href=''><span>"; echo $menu002; echo "</span></a></li><li><a href=''><span>"; echo $menu003; echo "</span></a></li><li><a href=''><span>"; echo $menu004; echo "</span></a></li><li><a href=''><span>"; echo $menu006; echo "</span></a></li>";} elseif($permission <= 1){ echo"<div id='page-section-mainmenu'><ul><li><a href=''><span>"; echo $menu001; echo "</span></a></li><li><a href=''><span>"; echo $menu002; echo "</span></a></li><li><a href=''><span>"; echo $menu003; echo "</span></a></li><li><a href=''><span>"; echo $menu004; echo "</span></a></li>";} else{ echo"<div id='page-section-mainmenu'><ul><li><a href=''><span>"; echo $menu001; echo "</span></a></li><li><a href=''><span>"; echo $menu002; echo "</span></a></li><li><a href=''><span>"; echo $menu003; echo "</span></a></li><li><a href=''><span>"; echo $menu005; echo "</span></a></li>"; echo "<span> <form action='login.php' method='POST'> <input type='text' value='username' name='username'> <input type='text' value='password' name='password'> <input type='submit'> </form> </span> </li> </ul> </div> </div>";} ?> Hi, The code below is not yet finished but i left it today and went to do something came back and forgot where i left off half way through code. It says Parse error: syntax error, unexpected $end in C:\wamp\www\member\login.php on line 305. Not on line 305 thou as that is the last line. I think i have missed a parentheses or curly bracelet. My eyes are watering now i have looked over and over. Please someone help. Like i say it's not yet finished or formatted to it's best but hopefully one of you people on here can help me Thanks <?php //ob_start(); // Include config.php require_once("".$_SERVER['DOCUMENT_ROOT']."/lib/config.php"); // top.inc.php require_once($top_inc); ?> <!-- Meta start --> <title><?php echo $websitename; ?> - Member Login</title> <meta name="description" content="<?php echo $websitename; ?> - Member Login" /> <meta name="keywords" content="<?php echo $websitename; ?>, login, signup, register, sign in, signin, sign up" /> <!-- Meta end --> <?php // main.inc.php require_once($main_inc); ?> <!-- CONTENT HERE --> <?php // Check if form has been submitted if(isset($_POST['submit']) && $_SERVER['REQUEST_METHOD'] == 'POST'){ # Connect to databse sql_con(); # Get form data and cleanse $username = msqls(trim($_POST['username'])); $password = msqls(trim($_POST['password'])); $ip = msqls($_SERVER['REMOTE_ADDR']); # Validate form data if (utfstrlen($username) < 1) { $error .= "Please enter your username <br />"; } if (utfstrlen($username) > 0 && !preg_match(constant("USERNAME_REGEX"), $username)) { $error .= "Username invalid format <br />"; } if (utfstrlen($password) < 1) { $error .= "Please enter your password <br />"; } if (utfstrlen($password) > 0 && !preg_match(constant('PASSWORD_REGEX'), $password)) { $error .= "Password invalid format<br />"; } # If error founds display them if(isset($error)){ $SiteErrorMessages = "$error"; SiteErrorMessages(); } # else no errors found continue processing else { # Check if user has activated there account $status_check = mysql_query("SELECT username FROM ".constant("TBL_USERS")." WHERE username = '$username' AND status = '".constant("USER_STATUS_VERIFY")."' LIMIT 1"); # Check if user has requested account to be deleted $delete_check = mysql_query("SELECT username FROM ".constant("TBL_USERS")." WHERE username = '$username' AND status = '".constant("USER_STATUS_DELETE")."' AND password = '".sha1($password)."' LIMIT 1"); # Check if user has been suspended $username_status_check = mysql_query("SELECT username, suspended_note FROM ".constant("TBL_USERS")." WHERE username = '$username' AND status = '".constant("USER_STATUS_SUSPENDED")."' AND password = '".sha1($password)."' LIMIT 1"); # Check above queries if error occurs notify user if(!$delete_check || !$status_check || !$username_status_check){ echo '<h1>Oops something went wrong :(</h1>'; $SiteErrorMessages = "Something went wrong while processing your request. Please try again later. <br /> $websitename has been notified of this error and will investigate further."; SiteErrorMessages(); # This variable will be passed to the site_errors_email_notification function $site_error_email_message_notification = "User Login Failure <br /> A user tried to login but the verify, suspended or delete query check failed. <br /><br /><b>".mysql_error()."</b><br /><br /> There details are below. <br /><br /> Username: <b>$username</b> <br />"; # This function will pass the above variable (message) to the admin error notify function # to send admin an email to notify them of an error site_errors_email_notification(); include("$footer_inc"); exit; } # else queries ok continue processing else { # Check delete query if (mysql_num_rows($delete_check) == 1) { echo '<h1>Account Deletion In Process</h1>'; echo "<p><b>Sorry, you cannot login to your account as you requested your account to be deleted.</b> <b>Your account is queued for deletion from the $websitename database and will be deleted within 24 hours.</b></p>"; echo "<p><b>$websitename sent you a confirmation email when you requested your account to be removed.</b> <b>If you did not make this request via your account please <a href=\"../contactus.php\">contact us</a> immediately.</b></p>"; echo "<p><b>Please note that it may not be possible to recover your account as the process is automated.</b></p>"; header( 'refresh: 60; url=$websiteaddress' ); include ("$footer_inc"); exit; } # Check status query elseif (mysql_num_rows($status_check) == 1) { echo "<h1>Account Activation Required</h1>"; echo "<p><b>You must activate your account via email before you can login.</b></p>"; header( 'refresh: 10; url=resendactivationemail.php' ); include ("$footer_inc"); exit; } # Check username status query elseif (mysql_num_rows($username_status_check) == 1) { $row = mysql_fetch_row($username_status_check); echo "<h1>Account Suspended</h1>"; echo "<p>Dear <b>" . $row[0] . "</b>, <br /> Your account has been suspended. The administrator has left the following message:</p>"; $no_suspended_note = "The administrator has not left a message. <br /> If you feel your account has been suspended in error please contact $websitename <a href=\"/contactus.php\">here</a>."; if (utfstrlen($row[1]) < 1) { $SiteWarningMessages = "$no_suspended_note"; SiteWarningMessages(); include ("$footer_inc"); exit; } else { $SiteWarningMessages = " . $row[1] . "; SiteWarningMessages(); echo '<p>If you feel your account has been suspended in error please contact ' . $websitename . ' <a href="/contactus.php">here</a>.<br /> <b>Please include your username when contacting ' . $websitename . '.</b></p>'; include ("$footer_inc"); exit; } } # else user must be ok to login so continue ... else { # Login Query $query = mysql_query("SELECT id, admin, username, first_name, last_name, email, last_visited, date_time, websiteurl, msn, aim, yim, twitter, gender FROM ".constant("TBL_USERS")." WHERE username = '$username' AND password = '".sha1($password)."' LIMIT 1"); # Check login query if(!$query){ echo '<h1>Oops something went wrong</h1>'; $SiteErrorMessages = "Something went wrong while trying to log you in. Please try again later. <br /> $websitename has been notified of this error and will investigate further."; SiteErrorMessages(); // This variable will be passed to the site_errors_email_notification function $site_error_email_message_notification = "User Login Failure <br /> A user tried to login but the Login Verification Check failed. <br /><br /><b>".mysql_error()."</b><br /><br /> There details are below. <br /><br /> Username: <b>$username</b> <br />"; # This function will pass the above variable (message) to the admin error notify function # to send admin an email to notify them of an error site_errors_email_notification(); include("$footer_inc"); exit; } # else login query ok so continue else { # Validate credentials against DB if (mysql_num_rows($query) == 1) { $found_user = mysql_fetch_array($query); # Tell them they are being logged in echo '<h1>Your now being logged in ...</h1>'; $SiteSuccessMessages = '<a href=\"/member/cp.php\">Click here if you do not automatically redirect</a>'; SiteSuccessMessages(); # User logged in succesfully reset failed login number to 0 $failed_login_reset = mysql_query("UPDATE ".constant("TBL_USERS")." SET `failed_login_count` = '0', `ip` = '" . $ip . "' WHERE `username` = '" . $username . "' LIMIT 1"); # check failed login query if(!$failed_login_reset){ // This variable will be passed to the site_errors_email_notification function $site_error_email_message_notification = "User Login Failure <br /> A user logged in but the failed login reset counter query failed. <br /><br /><b>".mysql_error()."</b><br /><br /> There details are below. <br /><br /> Username: <b>$username</b> <br />"; # This function will pass the above variable (message) to the admin error notify function # to send admin an email to notify them of an error site_errors_email_notification(); } # Store all member data into session to use for later on other areas of the website $_SESSION['username'] = $found_user['username']; $_SESSION['id'] = $found_user['id']; $_SESSION['admin'] = $found_user['admin']; $_SESSION['last_visited'] = date('l dS F Y, g:i:s A', $found_user['last_visited']); $_SESSION['first_name'] = $found_user['first_name']; $_SESSION['last_name'] = $found_user['last_name']; $_SESSION['email'] = $found_user['email']; $_SESSION['websiteurl'] = $found_user['websiteurl']; $_SESSION['msn'] = $found_user['msn']; $_SESSION['aim'] = $found_user['aim']; $_SESSION['yim'] = $found_user['yim']; $_SESSION['twitter'] = $found_user['twitter']; $_SESSION['gender'] = $found_user['gender']; $_SESSION['date_time'] = date('l dS F Y, g:i:s A', $found_user['date_time']); $_SESSION['date_time_for_profile'] = $found_user['date_time']; $_SESSION['time'] = time(); if (isset($_GET['redirect'])) { redirect($websiteaddress . $_GET['redirect'], 2); } else { redirect("cp.php", "0"); } include ("$footer_inc"); exit; } # else login details invalid else { # Login Details Invalid Error echo 'Login Details Invalid'; # If user fails 3 logins lock there account $login_failure_query = mysql_query("SELECT username, email, failed_login_count, status FROM ".constant("TBL_USERS")." WHERE username = '$username' AND status = '".constant("USER_STATUS_ACTIVATED")."' LIMIT 1"); # Check if query ok if(!$login_failure_query){ # This variable will be passed to the site_errors_email_notification function $site_error_email_message_notification = "Login Failure Query <br /> A user tried to login but the Login Failure Query Check failed. <br /><br /><b>".mysql_error()."</b><br /><br /> There details are below. <br /><br /> Username: <b>$username</b> <br />"; # This function will pass the above variable (message) to the admin error notify function # to send admin an email to notify them of an error site_errors_email_notification(); include("$footer_inc"); exit; } # else login_failure_query ok so continue ... else { # Check if (mysql_num_rows($login_failure_query) == 1) { # Fetch user row $row = mysql_fetch_row($login_failure_query); # Store data in variables $username_ = $row[0]; $email = $row[1]; # Increment failed login row by 1 on each failed login $login_count = $row[2] + 1; # Update failed_login_count row each time login fails $update_login_number = mysql_query("UPDATE ".constant("TBL_USERS")." SET `failed_login_count` = '" . $login_count . "' WHERE `username` = '" . $username . "'"); # Fetch total failed logins $login_count_total = $row[2]; } } } } ?> <h1>Login</h1> <form action="login.php<?php if (isset($_GET['redirect'])) { echo "?redirect=" . $_GET['redirect']; } ?>" method="post" id="frmcontact"> <label for="username">Username</label> <input type="text" name="username" id="username" value="<?php if (isset($username)) { echo $username; } ?>" class="textboxcontact" /> <label for="password">Password</label> <input type="password" name="password" id="password" class="textboxcontact" /> <label for="submit"> </label> <input type="submit" name="submit" id="submit" value="Sign In" class="submitcontact" /> </form> <!-- CONTENT FINISH --> <?php // footer.inc.php require_once($footer_inc); //ob_end_flush(); ?> This is absolutely stupid. I'm debugging PHP in Eclipse PDT with XDebug and XAMPP on Windows 7. A section of code has been working for weeks. Suddenly I'm told the following is a syntax error (line 226) $forumtitle = $forum['title']; $threadtitle = $thread['title']; Eclipse matches bracket and normally clipse would highlight [ when I put the cursor behind ]. Not here. On similar statements before this I changed ' (single quote) to (double quote)". The brackets [ and ] highlighted correctly but the " produced a louder syntax error.. Then I simply removed the single quotes. No syntax error. Brackets match. But I will probably get a syntax error. Usually stupidity like this indicates a quote problem somewhere before this code. After looking very hard, I see none. It feels like something is wrong with the Eclipse editor and something has to be reset. But what? I would appreciate any help. I'm trying to setup my database class so that by default it will create all of the tables and triggers required for my application to run. I've got everything working except for it adding the trigger. Here's the relevant code (slightly obfuscated for security reasons): private function check_consistency() { $database_query = <<<QUERY CREATE TABLE IF NOT EXISTS d2b_users ( id INT NOT NULL AUTO_INCREMENT, obfuscated INT NOT NULL, obfuscated VARCHAR(50) NOT NULL, obfuscated VARCHAR(32) NOT NULL, obfuscated VARCHAR(32) NOT NULL, obfuscated VARCHAR(32) NOT NULL, obfuscated BOOL NOT NULL DEFAULT '1', UNIQUE KEY(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; CREATE TABLE IF NOT EXISTS d2b_statistics ( id INT NOT NULL, obfuscated BIGINT NOT NULL DEFAULT '0', UNIQUE KEY(id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ; delimiter | CREATE TRIGGER d2b_auto_statistics AFTER INSERT ON d2b_users FOR EACH ROW BEGIN INSERT INTO d2b_statistics SET id = NEW.id; END; | delimiter ; QUERY; if(!$consistency = $this->link->multi_query($database_query)) { die("Failed to create/verify the default database tables."); } return true; } I've also tried removing the delimiter and the colon after the INSERT line in the trigger and I still can't get it to add properly. What's annoying is that I'm able to take the code for the trigger from above and go into phpmyadmin and paste it into the SQL and it will add and work correctly. However, I'm trying to get my class to do that automatically so the php application automatically installs itself on other servers. What am I doing wrong? hi guys when a match is over, two result fields have to be edited the first update goes well but the second one is failing, not allways, sometimes it gives the loser xp, but not the winner (with two players) the script should give the winner 100 xp second 95, third 90,... only the first two controls at the end are working the thirth one is not, and its being used to make the first two so it is doing its job there ... <?php include("./includes/egl_inc.php"); $secure = new secure(); $secure->secureGlobals(); page_protect(); global $config; $matchidcheck = $_SESSION['matchid']; $maks = '100'; $players=mysql_query("SELECT playerid FROM ffa_points WHERE matchid='$matchidcheck' order by killsdeaths DESC"); while(list($playerid)=mysql_fetch_array($players)) { $playerspoints=mysql_query("SELECT points FROM members WHERE id='$playerid'"); while(list($points)=mysql_fetch_row($playerspoints)) { $userpoints = $points; } $newpoints = $userpoints + $maks; mysql_query("UPDATE members SET points = $newpoints WHERE id='$playerid'"); mysql_query("UPDATE ffa_points SET xppoints = $maks WHERE id='$playerid' and matchid='$matchidcheck'"); if ($totalxp > 51) { $maks = $maks - 5; } } $mes="$newpoints $points $maks All Results have been stored succesfully !! Thank You !"; return success($mes,'./ffamatchesarchive.php'); include("$config"); ?> any help would be greatly appreciated thanks Hello, If anyone can help please let me know. The 2 files below are what's used to render the "Frickster's ListRave Posts" at the following URL http://www.listrave.com/member/profile.php?id=24. You can see that under Antiques it lists the same ads under both York and Altoona. The script is identifying all ads posted by User ID 24 but I don't know why it is duplicating those ads in the 2 different cities. There should actually be 2 ads for York and one for Altoona. The code is below. Again, please help Here's the code to pull the info from the data base (called memberall_listings.php) $conn = mysql_connect($dbhost1, $dbuser1, $dbpass1) or die ('Error connecting to mysql'); mysql_select_db($dbname1) or die('Could not connect: ' . mysql_error()); $tables = mysql_list_tables($dbname1); while (list($table) = mysql_fetch_row($tables)) { $site["tablename"][] = $table; } if($_REQUEST["id"]!='') $getmemberId = $_REQUEST["id"]; else $getmemberId = $_SESSION["memberid"]; //$x = getTableDetailsByTableName1(""); // echo count($site["tablename"]); $zz=-1; for($ww=0;$ww<count($site["tablename"]);$ww++) { $ValidTable = array("baltperm4w", "balt_yellowpages","boats"); if(!in_array($site["tablename"][$ww],$ValidTable)) { if (count(getTableDetailsByTableName2($site["tablename"][$ww])) >0) $zz++; for($kk=0;$kk<count(getTableDetailsByTableName2($site["tablename"][$ww]));$kk++) { // echo $site["tablename"][$zz]."<br></br>"; $getTableDetails = getTableDetailsByTableName($site["tablename"][$ww],$kk); //echo $getTableDetails["city"]; if ($kk > 0) if ($getTableDetails['city']==$lastcity && $getTableDetails['state']==$laststate) { continue; } $getAllArray[$zz][$kk]["Titlename"] = "<a href='http://www.listrave.com'>ListRave</a> --> <a href=".$getTableDetails["stateurl"].">".$getTableDetails["state"]."</a> --> <a href=".$getTableDetails["cityurl"].">".mysql_real_escape_string($getTableDetails["city"])."</a> --> <a href=".$getTableDetails["maincaturl"].">".$getTableDetails["maincat"]."</a> --> <a href=".$getTableDetails["caturl"].">".$getTableDetails["cat"]."</a>"; $getAllArray[$zz][$kk]["PostURL"] = $getTableDetails["SitePostUrl"]; $getAllArray[$zz][$kk]["AgeFormat"] = $getTableDetails["DisplayFormat"]; $getAllArray[$zz][$kk]["TableName"] = $site["tablename"][$ww]; $getAllArray[$zz][$kk]["SiteRealPath"] = $getTableDetails["SiteRealPath"]; $lastcity = $getTableDetails["city"]; $laststate = $getTableDetails["state"]; $GetAdlists[$zz]["MainArray"] = GetMemberAdLists($site["tablename"][$ww],$getmemberId); if($GetAdlists[$zz]["MainArray"]!=""){ $getAllArray[$zz][$kk]["ArrayExist"] = "Yes"; }else{ $getAllArray[$zz][$kk]["ArrayExist"] = "No"; } for($k=0;$k<count($GetAdlists[$zz]["MainArray"]);$k++) { $getdate = explode(",",$GetAdlists[$zz]["MainArray"][$k]["Posted_date"]); $getAllArray[$zz][$kk][$k]['day'] = date("l",strtotime($getdate[0])); $getAllArray[$zz][$kk][$k]['month'] = date("F",strtotime($getdate[0])); $getAllArray[$zz][$kk][$k]['date'] = date("d",strtotime($getdate[0])); $getAllArray[$zz][$kk][$k]['ListArray'] = getMemberAddetails($getdate[0],$site["tablename"][$ww],$getmemberId, $getTableDetails["city"], $getTableDetails["state"]); for($mn=0;$mn<count($getAllArray[$zz][$kk][$k]['ListArray']);$mn++) { if($getAllArray[$zz][$kk][$k]['ListArray'][$mn]["Picture0"]!='' || $getAllArray[$zz][$kk][$k]['ListArray'][$mn]["Picture1"]!='' || $getAllArray[$zz][$kk][$k]['ListArray'][$mn]["Picture2"]!='' || $getAllArray[$zz][$kk][$k]['ListArray'][$mn]["Picture3"]!='' || $getAllArray[$zz][$kk][$k]['ListArray'][$mn]["Picture4"]!='' || $getAllArray[$zz][$kk][$k]['ListArray'][$mn]["Picture5"]!='') $getAllArray[$zz][$kk][$k]['ListArray'][$mn]["ImageArray"] = 'Yes'; else $getAllArray[$zz][$kk][$k]['ListArray'][$mn]["ImageArray"] = 'No'; } } } } } /* if($_SERVER['REMOTE_ADDR'] = '122.165.56.46') { printArray($getAllArray); exit; } */ function SelectQry1($Qry) { $result = mysql_query($Qry) or die ("QUERY Error:".$Qry."<br>".mysql_error()); $numrows = mysql_num_rows($result); if ($numrows == 0){ return; } else { $row = array(); $record = array(); while ($row = mysql_fetch_array($result)){ $record[] = $row; } } return $record; } function getTableDetailsByTableName($tablename, $kk) { global $global_config; $Qry = "select * FROM ".$tablename.""; $getListingdetail = SelectQry1($Qry); return $getListingdetail[$kk]; } function getTableDetailsByTableName2($tablename) { global $global_config; $Qry = "select * FROM ".$tablename.""; $getListingdetail = SelectQry1($Qry); return $getListingdetail; } function GetMemberAdLists($tablename,$getmemberId) { global $global_config; $Qry = "select Posted_date FROM ".$tablename." where memberid='".$getmemberId."' group by SUBSTRING_INDEX(Posted_date,',',1) Order by Posted_date DESC"; $getimagedetail = SelectQry1($Qry); return $getimagedetail; } function getMemberAddetails($date,$tablename,$getmemberId) { global $global_config; $Qry = "select * from ".$tablename." WHERE `Posted_date` like '%".$date."%' AND ActivationStatus = 'Active' AND PublishedStatus='Active' AND memberid='".$getmemberId."' group by Posted_date Order by Ident DESC"; $getimagedetail = SelectQry1($Qry); return $getimagedetail; } ?> Here's the code to display it. Remember, this is just for "Frickster's ListRave Posts" <?php // start session ob_start(); session_start(); include "../includes/config.php"; //include('incsec/inccheckifadmin.php'); include ('incsec/incconn.php'); include ('incsec/incsettings.php'); include ('incfunctions.php'); if($_REQUEST["id"]!='') $ActiveMemberID = $_REQUEST["id"]; else $ActiveMemberID = $_SESSION["memberid"]; $query="SELECT * FROM tblmembers where memberid = '".$ActiveMemberID."'"; $result11 = mysql_query($query,$dbconnection); $members = mysql_fetch_array($result11); $pagetitle = 'ListRave - '.$members["username"]." 's".' Profile Page'; include("memberall_business.php"); include('memberall_listings.php'); //printArray($getAllArray); //exit; ?> <?php include('header_member2.php') ?> <div style="height:50px;"> </div> <table border="0" cellpadding="2" cellspacing="0" width="80%" align="center"> <tr> <td valign="top" width="30%" align="left"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td valign="top" align="left"> <table width="100%"> <tr> <td valign = "top" style="text-align: center;"> <?php include ('incsec/incconn.php'); $dbconnection = mysql_connect($dbhost,$dbusername,$dbpassword); mysql_select_db($database,$dbconnection); $query="SELECT * FROM tblmembers where memberid = '".$ActiveMemberID."'"; $result = mysql_query($query,$dbconnection); $numrecs=mysql_num_rows($result); $myrow = mysql_fetch_array($result); $currentmemberid = $myrow['memberid']; $qry="SELECT * FROM tbl_listrave_ad where memberid = '".$ActiveMemberID."' and PublishedStatus='Active'"; $result1 = mysql_query($qry,$dbconnection); $getcnt =mysql_num_rows($result1); ?> <?php if($numrecs!=0) { ?> <table height="100" width="90%" border="0" cellpadding="6" cellspacing="0" align="center"> <tr> <td valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="0" style="border:1px solid #0166FF;"> <tr> <td align="left" class="profilefheader" width="100%" colspan="2" style="padding-left:5px; padding-top:0px; height:20px; line-height:20px;" valign="middle"><?php echo $myrow["username"]; ?>'s Profile</td> </tr> <tr> <td align="left" valign="top"> <table width="100%" border="0" cellpadding="10" cellspacing="0" id="profilecontainer" align="left" style="margin-left: 10%"> <tr> <td valign = "top" width="10%"> <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td width="20%" align="left" valign="top" style="padding-right:35px"> <?php if($myrow["memberphoto"]!='') { ?> <a target="_blank" href="imageview.php?id=<?php echo $myrow["memberid"]; ?>"> <img width="180" height="180" class="Imageborder" src="<?php echo $config["sitepath"]."memberphotos/".$myrow["memberphoto"].""; ?>"> </a> <?php } else { ?> <img src="no-image.gif" border="0" width="180" height="180" class="Imageborder" /> <?php } ?> </td> </tr> <tr> <td height="30"> </td> </tr> <?php /*?><tr> <td width="80%" align="center" valign="top"> <?php if($myrow["memberphoto"]!='') { ?> <img src="upload.gif" border="0" /> <?php } else { ?> <img src="change-photo.gif" border="0" /> <?php } ?> </td> </tr><?php */?><tr valign="bottom"><td> </td></tr><tr><td align="left"><img src="addcontact.gif" alt="Add This Member To Your Contacts" /></td></tr></table> </td> <td valign = "top"> <table width="90%" border="0" cellpadding="6" cellspacing="0" align="left"> <tr> <td align="left" valign="top" colspan="2"> <table width="90%" border="0" cellpadding="0" cellspacing="0"> <tr> <td valign="top" width="15%" nowrap="nowrap"> <span id="profilecontainer">Personal Information </span> </td> <td width="88%" valign="top"> <div style="border-top: #CCCCCC solid 1px; position:relative; top:7px;"> </div> </td> </tr> </table> </td> </tr> <?php if($myrow["firstname"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>First Name</strong> </td> <td align="left" valign="top"> <?php echo $myrow["firstname"]; ?> </td> </tr> <?php } ?> <?php if($myrow["othernames"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Last Name</strong> </td> <td align="left" valign="top"> <?php echo $myrow["othernames"]; ?> </td> </tr> <?php } ?> <?php if($myrow["gender"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Gender</strong> </td> <td align="left" valign="top"> <?php echo $myrow["gender"]; ?> </td> </tr> <?php } ?> <?php if($myrow["age"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Age</strong> </td> <td align="left" valign="top"> <?php echo $myrow["age"]; ?> </td> </tr> <?php } ?> <?php if($myrow["pobox"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Location</strong> </td> <td align="left" valign="top"> <?php echo $myrow["pobox"]; ?> </td> </tr> <?php } ?> <?php if($myrow["relationship_status"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Relationship Status</strong> </td> <td align="left" valign="top"> <?php echo $myrow["relationship_status"]; ?> </td> </tr> <?php } ?> <?php if($myrow["registrationdate"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Member Since</strong> </td> <td align="left" valign="top"> <?php echo date('M d, Y', strtotime($myrow["registrationdate"])); ?> </td> </tr> <?php } ?> <?php if($myrow["username"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>User Name</strong> </td> <td align="left" valign="top"> <?php echo $myrow["username"]; ?> </td> </tr> <?php } ?> <?php if($myrow["about_me"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>About me</strong> </td> <td align="left" valign="top" style="padding-right:80px"> <?php echo $myrow["about_me"]; ?> </td> </tr> <?php } ?> <?php if($myrow["hobbies"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Hobbies</strong> </td> <td align="left" valign="top" style="padding-right:80px"> <?php echo $myrow["hobbies"]; ?> </td> </tr> <?php } ?> <?php if($myrow["movies"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Favorite Movies</strong> </td> <td align="left" valign="top" style="padding-right:80px"> <?php echo $myrow["movies"]; ?> </td> </tr> <?php } ?> <?php if($myrow["music"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Favorite Music</strong> </td> <td align="left" valign="top" style="padding-right:80px"> <?php echo $myrow["music"]; ?> </td> </tr> <?php } ?> <?php if($myrow["books"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Favorite Books</strong> </td> <td align="left" valign="top" style="padding-right:80px"> <?php echo $myrow["books"]; ?> </td> </tr> <?php } ?> <tr> <td height="15"> </td> </tr> <tr> <td align="left" valign="top" colspan="2"> <table width="90%" border="0" cellpadding="0" cellspacing="0" > <tr> <td valign="top" width="15%" nowrap="nowrap" > <span id="profilecontainer">Contact Information </span> </td> <td width="88%" valign="top"> <div style="border-top: #CCCCCC solid 1px; position:relative; top:7px;"> </div> </td> </tr> </table> </td> </tr> <?php if($myrow["emailaddress"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Email</strong> </td> <td align="left" valign="top"> <?php echo $myrow["emailaddress"]; ?> </td> </tr> <?php } ?> <?php if($myrow["phonenumber"]!='') { ?> <tr> <td width="20%" align="left" valign="top"> <strong>Mobile Number</strong> </td> <td align="left" valign="top"> <?php echo $myrow["phonenumber"]; ?> </td> </tr> <?php } ?> & Okay here's the simple thing I'm trying to do. I have a time in a db on my server .. let's say its March 1st 2011 at 12:00AM. This time is dynamically set by the server, so it's on server time. Now, lets say today is Feb 28th 2011 at 12:00AM on the server. I'm trying to write a dynamic script that will count down that time .. in this case I would want to show 23:59:59. Every count down script i've found online gives me an option to use local time (browser) or server time. Each time i plug in server time it is always set to my browse time ... I echo everything out and I basically get this: Server time: Feb 28th 2011 at 12:00AM My browser time: Feb 28th 2011 at 2:00AM Script time remaining: 21:59:59 So why does this keep happening? When I echo the date() from the server it's always 2 hours ahead of my time but the script never adjusts. Any ideas or does anyone know of a good working script? I'm on eastern time and the server is on pacific. Here's my last try, you'll see I place the php date into this towards the bottom but I've also tried jquery and SSI methods too. <!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> <script language="JavaScript"> TargetDate = "2/1/2011 12:00 AM"; BackColor = "palegreen"; ForeColor = "navy"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds."; FinishMessage = "It is finally here!"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"> */ function calcage(secs, num1, num2) { s = ((Math.floor(secs/num1))%num2).toString(); if (LeadingZero && s.length < 2) s = "0" + s; return "<b>" + s + "</b>"; } function CountBack(secs) { if (secs < 0) { document.getElementById("cntdwn").innerHTML = FinishMessage; return; } DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000)); DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24)); DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60)); DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60)); document.getElementById("cntdwn").innerHTML = DisplayStr; if (CountActive) setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod); } function putspan(backcolor, forecolor) { document.write("<span id='cntdwn' style='background-color:" + backcolor + "; color:" + forecolor + "'></span>"); } if (typeof(BackColor)=="undefined") BackColor = "white"; if (typeof(ForeColor)=="undefined") ForeColor= "black"; if (typeof(TargetDate)=="undefined") TargetDate = "12/31/2020 5:00 AM"; if (typeof(DisplayFormat)=="undefined") DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds."; if (typeof(CountActive)=="undefined") CountActive = true; if (typeof(FinishMessage)=="undefined") FinishMessage = ""; if (typeof(CountStepper)!="number") CountStepper = -1; if (typeof(LeadingZero)=="undefined") LeadingZero = true; CountStepper = Math.ceil(CountStepper); if (CountStepper == 0) CountActive = false; var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990; putspan(BackColor, ForeColor); var dthen = new Date(TargetDate); var dnow = new Date("<!--config timefmt='%c' --><!--echo var='DATE_LOCAL' -->"); if(CountStepper>0) ddiff = new Date(dnow-dthen); else ddiff = new Date(dthen-dnow); gsecs = Math.floor(ddiff.valueOf()/1000); CountBack(gsecs); </script> <br /> <?php $now = new DateTime(); echo $now->format("M j, Y H:i:s O")."\n"; ?> </body> </html> Hi all, i was trying to include a php file in an index file into another files and those included file is including one file also. But for some reason the database connection file is not included. this is the map structure www/index.php <---- the file that uses include www/newsletter/newsletter.php <---- has a form with action process.php www/newsletter/process.php <--- this has an include referring to database.php www/newsletter/database.php <--- the databasefile This is what i did but it gives a server error in index.php include('newsletter/newsletter.php'); innewsletter.php <form action="newsletter/process.php" method="post"><!--- some form stuff--></form> in process.php include('database.php'); I really don't understand why it doesn't work and it's giving a server error 500. The form loads like it should in the index.php but the rest doesn't any help is appreciated. Hi People. I am trying to insert data from a form into my database. Now I have the following code to connect to the DB to update a table so I know that I can connect to the DB ok Code: [Select] <?php // this code I got from the new boston, PHP tutorial 25 in selecting a mysql db // opens connection to mysql server $dbc = mysql_connect('localhost', 'VinnyG', 'thepassword'); if (!$dbc) { die("Not Connected:" . mysql_error ()); } // select database $db_selected = mysql_select_db ("sitename",$dbc); if(!$db_selected) { die("can not connect:" . mysql_error ()); } // testing code $query="UPDATE users SET username = 'testing testing' WHERE user_id = '2'"; $result=mysql_query($query); ?> Now here is the code from my form. Code: [Select] </head> <body> <?php //include "connection_file.php" //include "config01.php" $username = "username"; $height_above = "height_above"; $mb_diff = "mb_diff"; $alternative = "alternative"; ?> <form name = 'form1' method = 'post' action='config01.php'> <table width="700" border="1" cellspacing="5" cellpadding="5"> <caption> Submit Your Airfield Details </caption> <tr> <td width="100"> </td> <td width="200">Your Name</td> <td width="200"><input type='text' name='username' maxlength='30'></td> <td width="100"> </td> </tr> <tr> <td> </td> <td>Height Above MSL</td> <td><input type='text' name='height_above'maxlength= '30'></td> <td> </td> </tr> <tr> <td> </td> <td>Mb Difference</td> <td><input type='text' name='mb_diff'maxlength='40'></td> <td> </td> </tr> <tr> <td> </td> <td>Alternative Airfield</td> <td><input type='text' name='alternative' maxlength='30'></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> <td> </td> </tr> <tr> <td><input type='submit' name='submit' value='post' /></td> <td> </td> <td> </td> <td> </td> </tr> </table> </form> <?php $sql01 = "INSERT INTO users SET user_id = '', username = '$username',height_above = '$height_above', mb_diff = $mb_diff, alternative = $alternative"; $result=mysql_query($sql01); ?> </body> </html> here is the config01.php that the form refers to in the 'action' above. Code: [Select] <?php $host = 'localhost'; $username = 'VinnyG'; $password = 'thepassword'; $db_name = 'sitename'; //connect to database mysql_connect ("$host","$username","password")or die ("cannot connect to server"); mysql_select_db ("db_name") or die ("cannot select DB"); ?> Please could someone look at the above code and tell me where I'm going wrong. I can connect to the DB and update using the top script but I can't submit the form for some reason. I get a "cannot connect to server" message. Please someone help. It's been driving me crazy for the past two days. Regards VinceG http://www.microlightforum.com Hey guys, I really hope someone can help me out here. I have been working on my new website all week and am now almost finished. Just need to complete the contact page and touch up a few things... I really dont know php at all to be honest and just found a code somewhere on the net to help me. Heres my problem I have finally got the form to work but i am not recieving the correct data. I only get the email add, subject and messge. I am not getting the name of the sender.. also i really want to add a website field to the code because i do have that on the contact form... please can someone tell me where i am going wrong? the following is the php code i am using... <?php // Contact subject $subject ="Website enquiry"; // Details $message=$_POST[detail]; // Mail of sender $mail_from=$_POST[customer_mail]; // From $header="from: $name <$mail_from>"; // Enter your email address $to ='robin@rdosolutions.com'; $send_contact=mail($to,$subject,$message,$header); // Check, if message sent to your email // display message "We've recived your information" if($send_contact){ echo "We've recived your contact information"; } else { echo "ERROR"; } ?> please help me.. i am hoping to put the site live tomorrow... many thanks in advance.. rob I have a simply script like this: $fh = fopen("test/test.js", 'w+') or die("can't open file"); fwrite($fh, $output); fclose($fh); It ONLY works if the "test" directory has a 777 permissions. Works like a charm then, but the moment it goes to even 775, I get this: Warning: fopen(test/test.js) [function.fopen]: failed to open stream: Permission denied in /var/www/vhosts/mydomain.com/httpdocs/f.php on line 42 Any thoughts? I don't want this folder to remain 777 Thanks I have been looking at this code most of the morning and do not have a clue what is wrong with the code. I am hoping its not a stupid mistake, can someone please help me out? thank you
<title>Inputing Travel Detials</title> <header> <h1 align="center"> Adding Travel Detials </h1> <body> <p> <center><img src="cyberwarfareimage1.png" alt="Squadron logo" style="width:200px;height:200px" style="middle"></center> <table border="1"> <tr> <td><a href="index.php"> Home Page </a></td> <td><a href="administratorhomepage.html">Administrator Home Page </a></td> <td><a href="viewhomepage.html">View Home Page </a></td> <td><a href="Inputhomepage.html">Input Home Page </a></td> <td><a href="traveldetials.html">Enter More Travel Detials </a></td> </table> </p> <?php include "connection.php"; $Applicant_ID = $_POST["Applicant_ID"]; $Method_Of_Travel = $_POST["Method_Of_Travel"]; $Cost = $_POST["Cost"]; $ETA = $_POST["ETA"]; $Main_Gate_Advised = $_POST["Main_Gate_Advised"]; $query = ("UPDATE `int_board_applicant` SET `Method_Of_Travel`=`$Method_Of_Travel', `Cost`=`$Cost', `ETA`='$ETA', `Main_Gate_Advised`='$Main_Gate_Advised' WHERE `Applicant_ID`='$Applicant_ID'"); $result = mysqli_query($dbhandle, $query) or die(mysqli_error($dbhandle)); if($result){ echo "Success!"; } else{ echo "Error."; } // successfully insert data into database, displays message "Successful". if($query){ echo "Successful"; } else { echo "Data not Submitted"; } //closing the connection mysqli_close($dbhandle) ?> Ok this is puzzleing. I am geting "Could not delete data: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1". but its is deleting the entry that needs to be removed. The "1" is the entry. Just not sure what is causing the error. I do have another delete php but I have put that on the back burning for the time being.
<?php $con = mysqli_connect("localhost","user","password","part_inventory"); // Check connection if (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit(); } else { $result = mysqli_query($con, "SELECT * FROM amp20 "); $amp20ptid = $_POST['amp20ptid']; // escape variables for security $amp20ptid = mysqli_real_escape_string($con, $_POST['amp20ptid']); mysqli_query($con, "DELETE FROM amp20 WHERE amp20ptid = '$amp20ptid'"); if (!mysqli_query($con, $amp20ptid)); { die('Could not delete data: ' . mysqli_error($con)); } echo "Part has been deleted to the database!!!\n"; mysqli_close($con); } ?> Hi guys
I have this code below and all works fine when submitting this online application apart from when someone types either ' # & into one of the comment fields in which it throws up the error. Have tried various fixes from across the internet but no joy. Can anyone offer suggestions?
<?php
$con = mysql_connect("localhost:3306","root","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('sfapp', $con);
$sql="INSERT INTO 'sfapp' ('surname_add','forename_add','dob_add','hometele_add','mobiletele_add','homeadd_add','siblings_add','schoolname_add','headname_add','schooladd_add','schooltele_add','schoolem_add','alevel_add','personstate_add','nameprovided_add','pe_add','se_add','PredGrade_Art','PredGrade_AScience','PredGrade_BusStudies','PredGrade_Electronics','PredGrade_EnglishLang','PredGrade_EnglishLit','PredGrade_French','PredGrade_German','PredGrade_Geog','PredGrade_Graphics','PredGrade_History','PredGrade_Maths','PredGrade_SepScience','PredGrade_ProductDesign','PredGrade_Spanish','PredGrade_Other','Gender_Male','Gender_Female','Sub_EnglishLit','Sub_Maths','Sub_FurtherMaths','Sub_Biology','Sub_Chemistry','Sub_Physics','Sub_French','Sub_German','Sub_Spanish','Sub_Geography','Sub_History','Sub_RE','Sub_FineArt','Sub_Business','Sub_Computing','Sub_GlobPersp','Sub_DramaAndTheatre','Sub_PE','Sub_Dance','Sub_Politics','Sub_Psychology','Sub_Sociology','readprospect_chk','Sib_Yes','Sib_No','Current_Student_Yes','Current_Student_No','I_Understand_chk','Current_Education_chk','Local_Care_chk','Staff_Cwhls_chk','Sub_Film')
VALUES
('$_POST[surname_add]','$_POST[forename_add]','$_POST[dob_add]','$_POST[hometele_add]','$_POST[mobiletele_add]','$_POST[homeadd_add]','$_POST[siblings_add]','$_POST[schoolname_add]','$_POST[headname_add]','$_POST[schooladd_add]','$_POST[schooltele_add]','$_POST[schoolem_add]','$_POST[alevel_add]','$_POST[personstate_add]','$_POST[nameprovided_add]','$_POST[pe_add]','$_POST[se_add]','$_POST[PredGrade_Art]','$_POST[PredGrade_AScience]','$_POST[PredGrade_BusStudies]','$_POST[PredGrade_Electronics]','$_POST[PredGrade_EnglishLang]','$_POST[PredGrade_EnglishLit]','$_POST[PredGrade_French]','$_POST[PredGrade_German]','$_POST[PredGrade_Geog]','$_POST[PredGrade_Graphics]','$_POST[PredGrade_History]','$_POST[PredGrade_Maths]','$_POST[PredGrade_SepScience]','$_POST[PredGrade_ProductDesign]','$_POST[PredGrade_Spanish]','$_POST[PredGrade_Other]','$_POST[Gender_Male]','$_POST[Gender_Female]','$_POST[Sub_EnglishLit]','$_POST[Sub_Maths]','$_POST[Sub_FurtherMaths]','$_POST[Sub_Biology]','$_POST[Sub_Chemistry]','$_POST[Sub_Physics]','$_POST[Sub_French]','$_POST[Sub_German]','$_POST[Sub_Spanish]','$_POST[Sub_Geography]','$_POST[Sub_History]','$_POST[Sub_RE]','$_POST[Sub_FineArt]','$_POST[Sub_Business]','$_POST[Sub_Computing]','$_POST[Sub_GlobPersp]','$_POST[Sub_DramaAndTheatre]','$_POST[Sub_PE]','$_POST[Sub_Dance]','$_POST[Sub_Politics]','$_POST[Sub_Psychology]','$_POST[Sub_Sociology]','$_POST[readprospect_chk]','$_POST[Sib_Yes]','$_POST[Sib_No]','$_POST[Current_Student_Yes]','$_POST[Current_Student_No]','$_POST[I_Understand_chk]','$_POST[Current_Education_chk]','$_POST[Local_Care_chk]','$_POST[Staff_Cwhls_chk]','$_POST[Sub_Film]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
?>
<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['pe_add'])) {
//Email information
$admin_email = $_REQUEST['pe_add'];
$forename = $_REQUEST['forename_add'];
$email = "autoreply@testing.com";
$subject = "Application";
$desc =
"Dear $forename
Thank you for submitting your online application, we will be in touch shortly.
"
;
//send email
mail($admin_email, "$subject", "$desc", "From:" . $email);
//Email response
echo "Thank you for contacting us!";
}
//if "email" variable is not filled out, display the form
else {
?>
If you are seeing this, you need to go back and fill out the Personal Email section!
<?php
}
header("location:complete.php");
mysql_close($con)
?>
Thanks in advance.
Hello all,
Appreciate if you folks could pls. help me understand (and more importantly resolve) this very weird error:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ASC, purchase_later_flag ASC, shopper1_buy_flag AS' at line 3' in /var/www/index.php:67 Stack trace: #0 /var/www/index.php(67): PDO->query('SELECT shoplist...') #1 {main} thrown in /var/www/index.php on line 67
Everything seems to work fine when/if I use the following SQL query (which can also be seen commented out in my code towards the end of this post) :
$sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id";However, the moment I change my query to the following, which essentially just includes/adds the ORDER BY clause, I receive the error quoted above: $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master ORDER BY purchased_flag ASC, purchase_later_flag ASC, shopper1_buy_flag ASC, shopper2_buy_flag ASC, store_name ASC) WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id";In googling for this error I came across posts that suggested using "ORDER BY FIND_IN_SET()" and "ORDER BY FIELD()"...both of which I tried with no success. Here's the portion of my code which seems to have a problem, and line # 67 is the 3rd from bottom (third last) statement in the code below: <?php /* $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id"; */ $sql = "SELECT shoplist.*, store_master.store_name, item_master.item_name FROM shoplist, store_master, item_master ORDER BY FIND_IN_SET(purchased_flag ASC, purchase_later_flag ASC, shopper1_buy_flag ASC, shopper2_buy_flag ASC, store_name ASC) WHERE shoplist.store_id = store_master.store_id AND shoplist.item_id = item_master.item_id"; $result = $pdo->query($sql); // foreach ($pdo->query($sql) as $row) { foreach ($result as $row) { echo '<tr>'; print '<td><span class="filler-checkbox"><input type="checkbox" name="IDnumber[]" value="' . $row["idnumber"] . '" /></span></td>';Thanks Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\mywork\unique.php on line 15 <html> <head> <title> </title> </head> <body bgproperties="fixed"> <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = ''; $con = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'mywork'; mysql_select_db($dbname, $con); $sql=mysql_query(insert into users (regno,name,gender,date,month,year,emailid,cell,paddress,caddress,incometype,incomeamt,dad,fyes,dadocup,mom,myes,momocup,password) VALUES ('$_POST[regno]','$_POST[name]','$_POST[gender]','$_POST[date]','$_POST[month]','$_POST[year]','$_POST[emailid]','$_POST[cell]','$_POST[paddress]','$_POST[caddress]','$_POST[incometype]','$_POST[incomeamt]','$_POST[dad]','$_POST[fyes]','$_POST[dadocup]','$_POST[mom]','$_POST[myes]','$_POST[momocup]','$_POST[password]')"); $sql1=mysql_fetch_array($sql); $result = @mysql_query($SQl1); $result="SELECT * FROM users WHERE regno='$regno'"; while($row = mysql_fetch_array($result)) { //echo $row['regno']."regno<br>"; //echo $row['name']."name<br>"; //echo $row['gender']."gender<br>"; //echo $row['date']."date<br>"; //echo $row['month']."month<br>"; //echo $row['year']."year<br>"; //echo $row['emailid']."emailid<br>"; //echo $row['cell']."cell<br>"; //echo $row['paddress']."paddress<br>"; //echo $row['caddress']."caddress<br>"; //echo $row['incometype']."incometype<br>"; //echo $row['incomeamt']."incomeamt<br>"; //echo $row['dad']."dad<br>"; //echo $row['fyes']."fyes<br>"; //echo $row['dadocup']."dadocup<br>"; //echo $row['mom']."mom<br>"; //echo $row['myes']."myes<br>"; //echo $row['momocup']."momocup<br>"; //echo $row['password']."password<br>"; } echo "Thanks for Register!"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added"; mysql_close($con); ?> <form name="security" action="index.php" method="post"> <input type="submit" value="click here to login"> </form> </body> </html> i have this code <?php require_once('dbconnect.php') $user = "test"; $pass = "test"; $result=mysql_query("SELECT * FROM accounts WHERE user = '$user' AND pass = '$pass' "); if(mysql_num_rows($result) == 0) { $login = "&err=Login Failed."; echo($login); } else { $row = mysql_fetch_array($result); $user = $row['user']; $pass = $row['pass']; $login = "&user=".$user."&pass=".$pass."&err=Login Successful."; echo($login); } ?> and im getting this Parse error: parse error in C:\wamp\www\flashstuff\WTF.php on line 4 line 4 is: $user = "test"; all the dbconnect stuff is fine help! The issue is there seems to be NO syntax error. 1. There is no relevant code before or after this line. 2. Yes, one would think a ! should be there as did I (I didn't write the code), however, even with the ! it still gives the same error. if (function_exists('gzcompress')) die(FUNCTION_NOT_FOUND); is giving me a syntax error, unexpected 'if', expecting 'function' or 'const' I am updating this code from PHP5.3 to PHP7.4 and I can't figure out what the syntax problem is since PHP allows this. I am using Eclipse PHP to do the conversion. Code: [Select] <?php mysql_connect ("-","-","-") or die ('Error'); mysql_select_db ("-"); $out = mysql_query("SELECT * FROM guestbook ORDER BY id DESC"); while($row = mysql_fetch_assoc($out); --and this one if that braces is deleted { ----this is where im getting the error $name = $row['name']; $email = $row['email']; $txt = $row['comment']; $msg = "Are you sure you want to delete"; /* @var $_REQUEST <type> */ if (isset($_REQUEST ["action"]) && $_REQUEST["action"] == "del") { $id = intval($_REQUEST['id']); mysql_query("DELETE FROM guestbook WHERE id=$id;"); echo "<action=index.php>"; } echo "<font face='verdana' size='1'>"; echo "<table border='0'> <tr><td>Name: ".$name."</td></tr>"." <tr><td>Email: ".$email."</td></tr> <tr><td colspan='2'>Comment:</td></tr> <tr><td colspan='2' width='500'><b>".$txt."</b></td></tr> <tr><td><a onclick=\"return confirm('.$msg.');\" href='index.php?action=del&id=".$row['id']."'><span class='red'>["."Delete"."]</span></a> </td></tr> </table><br />"; echo "<hr size='1' width='500' align='left'></font>"; } ?> Kindly help me please. When i delete ({) the error will become the ( i dont know what to do already. Thanks. Hi folks, I am a complete n00b at php and mysql. I am teaching myself from books and the WWW, but alas I am stuck... the error I get is: Parse error: syntax error, unexpected T_STRING in X:\xampp\htdocs\search.php on line 7 here is the code: <?php mysql_connect ("localhost", "user", "password") or die (mysql_error()); mysql_select_db ("it_homehelp_test") or die (mysql_error()); $term = $_POST['term']; $sql = $mysql_query(select * from it_homehelp_test where ClientName1 like '%term%'); <<<------this is line 7 while ($row = mysql_fetch_array($sql)){ echo 'Client Name:' .$row['ClientName1']; echo 'Address:' .$row['Address1']; echo 'Phone:' .$row['Tel1']; } ?> Any help you can offer would be great. I can also post the ".html" file that creates the search bar if it is needed. Thanks |