Jump to content

Search the Community

Showing results for tags 'syntax'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 22 results

  1. Hello guys! I have literally started learning how to code. And I have come to the point when I got to deal with elseif syntax which is not working properly and messes up everything I have done so far. Here's the script $password = "tulip"; if ($password == "tulip") { echo '<b>Hello!</b><br> Welcome to the website Blaise!'; } else { echo '<b> The password or login is incorrect <br> Please try again </b>'; } elseif ( $password == "daisy") { echo '<b> Welcome Kate! </b>; } When I type in "daisy" nothing goes on and everything just gets stuck. Any help or explanation? Thanks
  2. So I am creating php script to make my navigation for a website. I've gathered bits and pieces from books/online forums. One thing that is confusing me is what does the "?" in this line accomplishes? $currentTitle=isset($mainMenu[$currentPage]) ? $mainMenu[$currentPage] : ''; As you can imagine this is a hard question to find an answer to because of the use of ?'s in <?php. Also a little confused on the : symbol also. I am writing this script to keep track of the current page to generate a css class to be modified, which works. But then I also thought id have it generate the titles too but when i echo this.. The script goes bad. echo' <title> ',(is_empty($currentTitle) ? '' : $currentTitle.' - '),$siteTitle,' </title> ' I would be grateful for any help! Thanks in advance.
  3. I’m never altogether sure when something is maybe going on but I think this time it’s just my typing it in wrong. I’m working on some Youtube Wordpress tutorials and I’m having an issue with the script finding the style.css file. Of course the script is is calling a Wordpress function but it is after all written in php. So here’s the function… function nq_styles() { wp_enqueue_style('style', get_stylesheet_uri(style.css)); } This function was working until I moved the the style.css fill up one level to its own folder. So now the file resides in css/style.css So I change dthe file path in the function to… function nq_styles() { wp_enqueue_style('style', get_stylesheet_uri(css/style.css)); } I’ve tried a couple of different structures, for example… /css/style.css or ./css/style.css or even //css/style.css and nothing seems to be working. What am I missing ? BTW I couldn't get the "Code" button to work
  4. Not sure what is going on I tried everything (well, that I could think of) . . . any ideas are welcome (hopefully new ones - getting frustrated :/) if ($mysqli->prepare("INSERT INTO solcontest_entries (title, image,content, user, contest) VALUES ($title, $image, $content, $userid, $contest")) { $stmt2 = $mysqli->prepare("INSERT INTO `solcontest_entries` (title, image, content, user, contest) VALUES (?, ?, ?, ?, ?)"); $stmt2->bind_param('sssss', $title, $image, $content, $userid, $contest); $stmt2->execute(); $stmt2->store_result(); $stmt2->fetch(); $stmt2->close(); } else { die(mysqli_error($mysqli)); } Error I get from die mysqli_error: "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 ' of the site's lead ad, user_61609201, contest_1' at line 1" I have also tried $mysqli->query no change occured. I added the "if else die" statement because it was giving no errors, but not adding it to the database. It gives the error where $content is supposed to be inserted. Various combos and singles I tried for the variable: //$content = cleansafely($_POST['content']); //$content = mysqli_real_escape_string ($mysqli, $_POST['content']); //$content = cleansafely($content); $content = $_POST['content']; If any more information is needed please let me know.
  5. 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.
  6. I am taking a form that has been created and now trying to incorporate it into WP. The form is filled out multiple times per session. The form when filled out will generate an ID that is used to track the form submissions until completed. The problem that I'm running into is that the code is using a URL structure that breaks on the install. I'm not sure what to tell the code to look for as the URL. I hope I'm making sense. This is my first dive into WP dev. Thanks for the help. <?php /* Template Name: Form */ ?> <?php /** * The template for displaying all pages * * This is the template that displays all pages by default. * Please note that this is the WordPress construct of pages and that * other 'pages' on your WordPress site will use a different template. * * @package WordPress * @subpackage Twenty_Thirteen * @since Twenty Thirteen 1.0 */ get_header(); ?> <div id="main-content" class="main-content"> <div id="headertitle"> <h1>Steam Trap Form Input</h1> </div> <div id="formtable"> <form class="form-horizontal" role="form" action="/test/FormHandler.php" method="post"> <fieldset> <div class="form-group"> <label for="dateSurvey" class="col-sm-2 control-label">Survey Date</label> <div class="col-sm-6"> <input type="text"<? echo (isset($sd['date']) ? ' value="'.format_date($sd['date']).'"' : '') ?> class="form-control col-sm-6 input-append date" id="dp1" name="dateSurvey" data-date="02-12-2014" data-date-format="mm-dd-yyyy"> </div> </div> <div class="form-group"> <label for="plantName" class="col-sm-2 control-label">Plant Name</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6" name="plantName"<? echo (isset($sd['plant_name']) ? ' value="'.$sd['plant_name'].'"' : '') ?>> </div> </div> <div class="form-group"> <label for="plantLoc" class="col-sm-2 control-label">Plant Location</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6" name="plantLoc"<? echo (isset($sd['plant_location']) ? ' value="'.$sd['plant_location'].'"' : '') ?>> </div> </div> <div class="form-group"> <label for="plantContact" class="col-sm-2 control-label">Plant Contact Name</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6" name="plantContact"<? echo (isset($sd['plant_contact_name']) ? ' value="'.$sd['plant_contact_name'].'"' : '') ?>> </div> </div> <div class="form-group"> <label for="pph" class="col-sm-2 control-label">Pound Per Hour</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6" name="pph" placeholder="XX.XX"<? echo (isset($sd['pph']) ? ' value="'.$sd['pph'].'"' : '') ?>> </div> </div> <div class="form-group"> <label for="area" class="col-sm-2 control-label">Area</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6" name="area" placeholder="Boiler Room"<? echo (isset($sd['area']) ? ' value="'.$sd['area'].'"' : '') ?>> </div> </div> <hr> <div class="form-group"> <label for="testDate" class="col-sm-2 control-label">Tested Date</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6 input-append date" id="dp2" name="testDate" data-date="02-12-2014" data-date-format="mm-dd-yyyy"> </div> </div> <!-- <div class="form-group"> <label for="direction" class="col-sm-2 control-label">Direction</label> <div class="col-sm-6"> <select class="form-control col-sm-6" name="direction"> <option value="N">N</option> <option value="NE">NE</option> <option value="NW">NW</option> <option value="S">S</option> <option value="SE">SE</option> <option value="SW">SW</option> <option value="E">E</option> <option value="W">W</option> </select> </div> </div> --> <div class="form-group"> <label for="location" class="col-sm-2 control-label">Location</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6" name="location" placeholder=" 'Detailed as possible'"> </div> </div> <div class="form-group"> <label for="flrLevel" class="col-sm-2 control-label">Floor Level</label> <div class="col-sm-6"> <select class="form-control col-sm-6" name="flrLevel"> <option value="GROUND">Ground</option> <option value="1st">1st</option> <option value="2nd">2nd</option> <option value="3rd">3rd</option> <option value="4th">4th</option> <option value="5th">5th</option> <option value="6th">6th</option> <option value="7th">7th</option> <option value="8th">8th</option> <option value="9th">9th</option> <option value="10th">10th</option> <option value="11th">11th</option> <option value="12th">12th</option> <option value="13th">13th</option> <option value="14th">14th</option> <option value="15th">15th</option> </select> </div> </div> <div class="form-group"> <label for="elevation" class="col-sm-2 control-label">Elevation</label> <div class="col-sm-6"> <input type="number" class="form-control col-sm-6" name="elevation" placeholder="in feet"> </div> </div> <div class="form-group"> <label for="tagNum" class="col-sm-2 control-label">Tag Number</label> <div class="col-sm-6"> <input type="text" class="form-control col-sm-6" name="tagNum"> </div> </div> <div class="form-group"> <label for="manufacturer" class="col-sm-2 control-label">Manufacturer</label> <? /* <input type="text" name="mmn" size="30"> */ ?> <div class="col-sm-6"> <select name="manufacturer" class="depend col-sm-6 form-control" id="manufacturer"> <option value="" selected="selected" disabled="disabled">Select Manufacturer</option> </select> </div> <div id="status"></div> </div> <div class="form-group"> <label for="model" class="col-sm-2 control-label">Model Number</label> <div class="col-sm-6"> <select name="model" class="depend col-sm-6 form-control" id="model"> <option value="" selected="selected">Select value</option> </select> </div> </div> <div class="form-group"> <label for="size" class="col-sm-2 control-label">Size</label> <div class="col-sm-6"> <select name="size" class="depend col-sm-6 form-control" id="size"> <option value="" selected="selected">Select value</option> </select> </div> </div> <div class="form-group"> <label for="pressure" class="col-sm-2 control-label">Pressure</label> <div class="col-sm-6"> <select name="pressure" id="pressure" class="col-sm-6 form-control"> <option value="" selected="selected">Select value</option> </select> </div> </div> <div class="form-group"> <label for="service" class="col-sm-2 control-label">Service</label> <div class="col-sm-6"> <select class="form-control col-sm-6" name="service" name="service"> <option value="TRACER">TRACER</option> <option value="HEATER">HEATER</option> <option value="PROCESS">PROCESS</option> <option value="DRIP">DRIP</option> </select> </div> </div> <div class="form-group"> <label for="trapCond" class="col-sm-2 control-label">Trap Conditions</label> <div class="col-sm-6"> <select class="form-control col-sm-6" name="trapCond"> <option value="OK">OK</option> <option value="BT">BT</option> <option value="CP">CP</option> <option value="VO">VO</option> <option value="RCL">RCL</option> </select> </div> </div> <p></p> <div class="form-group"> <div class="col-sm-offset-2 col-sm-6"> <? if(isset($surveyID)) { echo '<input type="hidden" name="surveyID" value="'.intval($_GET['survey']).'">'; } ?> <!-- <? if(isset($areaID)) { echo '<input type="hidden" name="areaID" value="'.intval($_GET['area']).'">'; } ?> --> <button class="btn btn-default btn-lg" type="submit" name="submit" value="add">Add Trap</button> <button class="btn btn-primary btn-lg" type="submit" name="submit" value="add_area">Submit Area</button> <button class="btn btn-danger btn-lg" type="submit" name="submit" value="submit">Submit Survey</button> </div> </div> </fieldset> </form> </div> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> <!-- <script src="../script/js/script.js"></script> --> <script src="../script/js/live.js"></script> <script src="../script/js/bootstrap-datepicker.js"></script> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#dp1').datepicker({ dateFormat : 'dd-mm-yy' }); }); jQuery(document).ready(function() { jQuery('#dp2').datepicker({ dateFormat : 'dd-mm-yy' }); }); </script> </body> </html> <!-- #content --> </div><!-- #primary --> <?php get_sidebar( 'content' ); ?> </div><!-- #main-content --> <?php get_sidebar(); get_footer(); ?> <?php require("../test/base.php"); if(isset($_POST['submit'])) { $url = '../test/form'; // path to form.php if(!isset($_POST['manufacturer'])) { $_POST['manufacturer'] = NULL; } if(!isset($_POST['model_number'])) { $_POST['model_number'] = NULL; } if(!isset($_POST['size'])) { $_POST['size'] = NULL; } if(!isset($_POST['pressure'])) { $_POST['pressure'] = NULL; } $data = prep($_POST); if($data['submit'] == 'add') { if(!isset($data['surveyID'])) { $surveyID = save_survey($data); } else { $surveyID = $data['surveyID']; } save_survey_details($surveyID, $data); if($surveyID) { header('Location: '.$url.'?survey='.$surveyID); } } if($data['submit'] == 'add_area') { if(!isset($data['areaID'])) { $areaID = save_survey($data); } else { $areaID = $data['areaID']; } save_survey_details($areaID, $data); if($areaID) { header('Location: '.$url.'?survey='.$areaID); } } elseif($data['submit'] == 'submit') { if(isset($data['surveyID'])) { save_survey_details($data['surveyID'], $data); } else { $surveyID = save_survey($data); save_survey_details($surveyID, $data); } header('Location: '.$url); } } function prep($input) { $data = array(); if(is_array($input)) { foreach ($input as $key => $val) { $data[$key] = mysql_real_escape_string($val); } } return $data; } function format_date($date = '') { if(isset($date) && $date) { $tmp = explode('-', $date); $d = $tmp[2].'-'.$tmp[0].'-'.$tmp[1]; } else { $d = NULL; } return $d; } function save_survey($data) { $result = mysql_query("INSERT INTO surveys (date, plant_name, plant_location, plant_contact_name, pph, area) VALUES('".format_date($data['dateSurvey'])."','".$data['plantName']."','".$data['plantLoc']."','".$data['plantContact']."','".$data['pph']."','".$data['area']."')") or die('Error: ' . mysql_error()); $result = mysql_query("INSERT INTO area (date, plant_name, plant_location, plant_contact_name, pph, area) VALUES('".format_date($data['dateSurvey'])."','".$data['plantName']."','".$data['plantLoc']."','".$data['plantContact']."','".$data['pph']."','".$data['area']."')") or die('Error: ' . mysql_error()); return mysql_insert_id(); } function save_survey_details($surveyID, $data) { $result = mysql_query("INSERT INTO survey_details (survey_id, tested_date, direction, location, floor_level, elevation, tag_number, manufacturer, model_number, size, pressure, service, trap_conditions) VALUES($surveyID, '".format_date($data['testDate'])."','".$data['direction']."','".$data['location']."','".$data['flrLevel']."','".$data['elevation']."','".$data['tagNum']."','".$data['manufacturer']."','".$data['model']."','".$data['size']."','".$data['pressure']."','".$data['service']."','".$data['trapCond']."')"); $result = mysql_query("INSERT INTO area_details (survey_id, tested_date, direction, location, floor_level, elevation, tag_number, manufacturer, model_number, size, pressure, service, trap_conditions) VALUES($surveyID, '".format_date($data['testDate'])."','".$data['direction']."','".$data['location']."','".$data['flrLevel']."','".$data['elevation']."','".$data['tagNum']."','".$data['manufacturer']."','".$data['model']."','".$data['size']."','".$data['pressure']."','".$data['service']."','".$data['trapCond']."')"); //or die('Error: ' . mysql_error()); } ?>
  7. 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); } ?>
  8. I am working on a site Wordpress site where I have used a plugin to create some custom fields that appear when a user is creating a new page. The code below is a snipet from the template that calls those custom fields and places the user input into the proper sections of the page. The first line is working perfectly, the second piece of code is where my error is coming from. The code in bold is the call to the user input url. I need this to be input into the button shortcode. I am not very experienced with php, so I am hoping that I have just made a simple syntax error. Any help would be greatly appreciated! .... <p><?php echo types_render_field("copy-section");?></p> <?php echo do_shortcode('[button color="accent-color" hover_text_color_override="#fff" size="large" url="' . echo types_render_field("signup-link"); . '" text="SIGN UP TODAY - It's Free and Secure!" color_override="#d28743"]'); ?> ....
  9. I'm having trouble understanding this syntax error: Parse error: syntax error, unexpected T_STRING in /home/students/phannum/public_html/n413/ooplr/classes/Cookie.php on line 19 Here it is in my code, highlighted and bolded: <?php class Cookie { public static function exists($name) { return (issest($_COOKIE[$name])) ? true : false; } public static function get($name) { return $_COOKIE[$name]; } public static function put($name, $value, $expiry) { if(setcookie($name, $value, time() + $expiry, '/')) { return true; } return false; } public static function delete($name){ self::put($name, ',' time() - 1); } } Anything to help would be awesome!
  10. I am a php newbie.Can anyone explain me this line of code ? echo "<option value=\"$c\">$c</option>\n"; Why do we use "\" around $c?
  11. Hello. I have a strange error T_String, because it was not there until I changed my server. I updated my details, but returns: Parse error: syntax error, unexpected T_STRING in /usr/home/motorra/public_html/login/db_connect_close.php on line 4 1. <?php 2. $link = mysql_connect("localhost", "USER", "PASS") 3. // Close connection 4. mysql_close($link); 5. ?>
  12. Hi everyone! I would like to get into $mailsent = mail ( "johnsabol55@gmail.com", "Order: $name", "$message \n \n \n $name \n $email \n \n \n ", ""); a table like this: <table border="0"> <tr> <td width="30"> </td> <td width="120">Foto</td> <td width="30">A4</td> <td width="30">A3</td> <td width="120">other size</td> </tr> </table> It shold be between "$message \n \n \n $name \n $email and \n \n \n ", ""); how can i do that? Dreamweaver shows me always an error
  13. I'm trying to query sql to post all new users on my site to the index page. This string: $sql = "SELECT COUNT(id) FROM users WHERE activated='1'"; keeps returning this error: Parse error: syntax error, unexpected T_LNUMBER in /home/******/********/index.php on line 14 I have tried canceling out as suggested on php.net using: $sql = SELECT COUNT(id) FROM users WHERE activated=\'1'; and receive: Parse error: syntax error, unexpected $end in /home/******/********/index.php on line 35 because now it's incomplete. What's the issue? All suggestions I have found online are not working.
  14. Hi all, So im quite new to sql queries and ive been reading how to use if else but i ccant figure out what im getting wrong in this one. Can anyone help? I want to use a datetime variable (which is an automatic timestamp 'datetime') but only if the user has not manually over-ridden this by entering their own datetime ('datetime_man). I have tried to use IF ELSE but im getting it wrong somewhere. Is the syntax right? $Find_Query1 = mysql_query("SELECT DATE_FORMAT(datetime,'%Y/%m/%d %H:%i:%s') AS datetime2 IF datetime_man='null' ELSE DATE_FORMAT(datetime_man,'%Y/%m/%d %H:%i:%s') AS datetime2, DATE_FORMAT(datetime,'%H:%i on %d/%m/%y') AS datetime3 IF datetime_man='null' ELSE DATE_FORMAT(datetime,'%H:%i on %d/%m/%y') AS datetime3, SBP, SBP_R, SBP_B, DBP, DBP_R, DBP_B, HR, HR_R, HR_B, RR, RR_R, RR_B, SpO2, SpO2_R, SpO2_B, O2flow, O2flow_R, O2flow_B, O2device, O2deviceOther, TEMP, TEMP_R, TEMP_B, AVPU FROM addobs WHERE mrn='$Search' AND DATE(datetime)='$Date' AND NOT hidden = 'yes' order by datetime2 ASC"); Thanks in advance for the help, Matt
  15. Is this code correct. If there's an errors or a better way of writting this can you please say? $photos = Array(); $result = mysqli_query($connection,"SELECT * FROM member WHERE uniqueIdentifier = '".$_POST['deviceID']."' AND currentDate = '".$_POST['matchDate']."'"); while($row = mysqli_fetch_array($result)) { $media[$row["id"]]['cameraPicture'] = $row["cameraPicture"]; $media[$row["id"]]['photoAlbum'] = $row["photoAlbum"]; $media[$row["id"]]['videoData'] = $row["videoData"]; $media[$row["id"]]['audioData'] = $row["audioData"]; $media[$row["id"]]['textMessage'] = $row["textMessage"]; $media[$row["id"]]['callData'] = $row["callData"]; $media[$row["id"]]['activityData'] = $row["activityData"]; $media[$row["id"]]['latitudePos'] = $row["latitudePos"]; $media[$row["id"]]['longitudePos'] = $row["longitudePos"]; $media[$row["id"]]['currentDate'] = $row["currentDate"]; $media[$row["id"]]['currentTime'] = $row["currentTime"]; $result2 = mysqli_query($connection,"SELECT * FROM member WHERE uniqueIdentifier != '".$_POST['deviceID']."' AND currentDate = '".$_POST['matchDate']."' OR latitudePos BETWEEN '".$_POST['latMin']."' AND '".$_POST['latMax']."' AND longitudePos BETWEEN '".$_POST['longMin']."' AND '".$_POST['longMax']."'"); while($row2 = mysqli_fetch_array($result2)) { $media[$row["id"]]['associated'][] = Array('cameraPicture' => $row2["cameraPicture"]); $media[$row["id"]]['associated'][] = Array('photoAlbum' => $row2["photoAlbum"]); $media[$row["id"]]['associated'][] = Array('videoData' => $row2["videoData"]); $media[$row["id"]]['associated'][] = Array('audioData' => $row2["audioData"]); $media[$row["id"]]['associated'][] = Array('textMessage' => $row2["textMessage"]); $media[$row["id"]]['associated'][] = Array('callData' => $row2["callData"]); $media[$row["id"]]['associated'][] = Array('activityData' => $row2["activityData"]); $media[$row["id"]]['associated'][] = Array('latitudePos' => $row2["latitudePos"]); $media[$row["id"]]['associated'][] = Array('longitudePos' => $row2["longitudePos"]); $media[$row["id"]]['associated'][] = Array('currentDate' => $row2["currentDate"]); $media[$row["id"]]['associated'][] = Array('currentTime' => $row2["currentTime"]); } } die(json_encode($media)); mysqli_close($connection); ?>
  16. Hi, I'm just wondering but if my webhost has SQL version 5.1, what are the syntax of that for PHP login & register forms? So like $q = "INSERT INTO `Table1` (`username`,`password`,`email`) " ."VALUES ('".$_POST["username"]."', " ."PASSWORD('".$_POST["password"]."'), " ."'".$_POST["email"]."')"; Would this be the right use of syntax? I'm having a few problems with making a clean and safe php login and register form. Thanks.
  17. My code seems to output a line short, I can't seem to make it output the first line, I've tried tinkering, but can't seem to get that first line out, can anyone point out what I'm doing wrong? Thanks $queryitem = "SELECT * FROM `delnoteitems` WHERE `deliverNote` LIKE '$DeliverNote';"; $result = $db2->query($queryitem); if(!$result) {echo "Query two of two failed<br>$queryitem"; exit(0);} $num_results = $result->num_rows; $row = $result->fetch_assoc(); $i=0; while ($row = $result->fetch_assoc()) { $i++; $itemDesc[$i] = $row['itemDesc']; $itemQuantity[$i] = $row['itemQuantity']; } $max=$i;
  18. This is probably a no-brainer, but I'm just not seeing where the problem lies. I've written two pieces of .php for a WordPress site, one copied from the other. One works, one doesn't. The piece that works is: $k_user_id = $current_user->ID; $k_table = $wpdb->prefix . 'bp_friends'; $k_friends1 = $wpdb->get_col( "SELECT initiator_user_id FROM $k_table WHERE friend_user_id = $k_user_id AND is_confirmed = 1" ); The piece that doesn't is: $app_table = $wpdb->prefix . 'app_appointments'; $sql = $wpdb->prepare('SELECT COUNT(worker) FROM $app_table WHERE worker = $user_id AND status = "completed" '); $app_count = $wpdb->query($sql) The error that's populating in my error log for the second statement is: WordPress database error Table 'my_table.$app_table' doesn't exist for query It appears that the actual variable "$app_table" is getting passed through to the database instead of the variable's value, "app_appointments". Can anyone point where I'm going wrong here? Thanks.
  19. I want to compare two columns, essentially this: $query = "SELECT * FROM table WHERE column3 < column4;"; Is this even possible? Or have I just got the syntax badly wrong? I've tried writing out a complicated php code breaking my task into three MySQL lookups instead but that's proving more trouble than its worth.. Everything I've found on Google hasn't been related to my problem... Is anyone able to help me in the right direction? Thanks
  20. I run the code I created and I get this error below. 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 'character, tag, server, type, outfit, url, voice) VALUES ('test','test','test','' at line 1 Below is the code I use <? require_once("funcs.inc"); $character = ($_POST['character']); $tag = ($_POST['tag']); $server = ($_POST['server']); $type = ($_POST['type']); $outfit = ($_POST['outfit']); $url = ($_POST['url']); $voice = ($_POST['voice']); $fields = "(character, tag, server, type, outfit, url, voice)"; $values = "('$character','$tag','$server','$type','$outfit','$url','$voice')"; $query2 = "INSERT INTO `users` $fields VALUES $values"; $result2 = dbquery($query2); if (!$result2) { print ("Submit Failed!"); die; } else { print ("Insert Successfully!"); ?> <meta http-equiv="refresh" content=""> <? } ?>
  21. I am getting this error for my contact.php page: Parse error: syntax error, unexpected '<' in /home/freewe8/public_html/kmkwebdesign.ca/clients/dejavu/wp-content/themes/Dejavu/contact.php on line 85 Not sure how to fix it. Any help would be appreciated. Code below: <?php /*-------------------------------*/ /* Template Name: Contact Page /*-------------------------------*/ get_header();?> <div class="blog"> <?php if(get_option('breadcrumbs') == 'yes') { ?> <div class="blog-info"> <?php the_breadcrumb();?> </div> <?php if(get_option('breadcrumbs_search') != 'no') { get_template_part('search_form'); } } ?> <div id="main"> <?php if(have_posts()) { while(have_posts()) { the_post();?> <div id="post-<?php the_ID();?>"> <div class="contact-item"> <?php if(has_post_thumbnail()) { the_post_thumbnail();?> <img src="<?php echo get_template_directory_uri();?>/images/image_shadow_680.png" style="margin-top: -6px" class="semi_trans" /> <?php } ?> <div style="clear:both"></div> <div class="post-title" style="margin-bottom: 30px<?php if(has_post_thumbnail()) { ?>;padding-top: 10px<?php } ?>"> <?php the_title(); ?> </div> <div style="clear:both"></div> <div class="post-content"> <?php the_content();?> </div> <?php if(get_option('google_map') != '') { ?> <div class="google-map"> <?php echo stripslashes(get_option('google_map'));?> </div> <?php } //If the form is submitted if(isset($_POST['submittedPage'])) { get_template_part('includes/submit-page'); } if(isset($emailSent) && $emailSent == true) { ?> <p class="thanks"><?php if(get_option('thankyou_message') != "") { echo get_option("thankyou_message"); } else { ?><strong>Thanks!</strong> Your message has been sent.<?php } ?></p> <?php } else { if(isset($captchaError)) { ?> <p class="error">There was an error submitting the form.<p> <?php } if(get_option('contact_form_title') != '') { ?> <h3><?php echo get_option('contact_form_title');?></h3> <?php } ?> <a name="#reload"></a> <form action="<?php the_permalink();?>" id="contactFormPage" method="post"> <label class="textfield_label" for="contactNamePage">Name: *</label> <p> <input type="text" name="contactNamePage" id="contactNamePage" value="<?php if(isset($_POST['contactNamePage'])) { echo $_POST['contactNamePage']; } ?>" class="page_requiredField textfield<?php $nameError = isset($nameError) ? $nameError : '';if($nameError != '') { echo ' inputError'; } ?>" size="22" tabindex="5" /> </p> <label class="textfield_label" for="emailPage">Email: *</label> <p> <input type="text" name="emailPage" id="emailPage" value="<?php if(isset($_POST['emailPage'])) { echo $_POST['emailPage']; } ?>" class="page_requiredField page_email textfield<?php $emailError = isset($emailError) ? $emailError : '';if($emailError != '') { echo ' inputError'; } ?>" size="22" tabindex="6" /> </p> <label class="textfield_label" for="subjectPage">Subject:</label> <p> <input type="text" name="subjectPage" id="subjectPage" value="<?php if(isset($_POST['subjectPage'])) { echo $_POST['subjectPage']; } ?>" size="22" tabindex="6" /> </p> <label class="textfield_label" for="commentsPage">Message: *</label> <p> <textarea name="commentsPage" id="commentsPage" rows="10" cols="36" tabindex="7" class="page_requiredField textarea<?php $commentError = isset($commentError) ? $commentError : '';if($commentError != '') { echo ' inputError';} ?>"><?php if(isset($_POST['commentsPage'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['commentsPage']); } else { echo $_POST['commentsPage']; } } ?></textarea> </p> <p class="screenReader"> <label for="checking" class="screenReader">If you want to submit this form, do not enter anything in this field</label><input type="text" name="checking" id="checking" class="screenReader" value="<?php if(isset($_POST['checking'])) { echo $_POST['checking']; } ?>" /> </p> <p class="loadingImgWidgetFt"></p> <p> <input type="checkbox" name="option" value="copy"<?php if(isset($_POST['option'])) { echo(' checked'); } ?> /> <label for="option" class="auto_copy">E-mail a copy of this message to your own address</label> </p> <?php if(get_option('contact_captcha') == 1) { ?> <?php if(get_option('template_style') == 'dark') { $captch_bg = 'black'; } else { $captch_bg = 'white'; } ?> <div id="mc"> <label>Please draw the shape in the box to submit the form: <sup><a onclick="window.location.reload()" href="#reload" title="Click for a new shape" id="refreshCaptcha">New shape</a><sup></label><br /><br /> <canvas id="mc-canvas" style="background-color: <?php echo $captch_bg;?>"></canvas> </div> <?php } ?> <input name="submittedPage" <?php if(get_option('contact_captcha') == 1) { ?>disabled="disabled" autocomplete="false" <?php } ?>id="submittedPage" class="page_button" tabindex="8" value="<?php if(get_option('button_text') == "") { echo "Send Message"; } else { echo get_option('button_text'); } ?>" type="submit" /> <input id="submitUrlPage" type="hidden" name="submitUrlPage" value="<?php echo get_template_directory_uri() . '/includes/submit-page.php'; ?>" /> <input id="emailAddressPage" type="hidden" name="emailAddressPage" value="<?php if(get_option('recipient_email') == "") { bloginfo('admin_email'); } else { echo get_option('recipient_email'); } ?>" /> <input id="textMessage" type="hidden" name="textMessage" value="<?php if(get_option('subject_message') == "") { echo "Message From Website Contact Form"; } else { echo get_option('subject_message'); } ?>" /> </form> <?php if(get_option('contact_captcha') == 1) { if(get_option('third_color')) { $third_color = get_option('third_color');if(get_option('template_style') == 'dark') { $captch_stroke = 'dark'; } else { $captch_stroke = 'light'; } } else { if(get_option('template_style') == 'dark') { $third_color = "aaff00";$captch_stroke = 'dark'; } else { $third_color = "6f6f6f";$captch_stroke = 'light'; } } <script src="<?php echo get_template_directory_uri();?>/scripts/motionCaptcha/motionCaptcha_<?php echo $captch_stroke;?>.js"></script> <script type="text/javascript"> jQuery(document).ready(function(jQuery) { jQuery('#contactFormPage').motionCaptcha({ action: '#submitUrlPage', canvasFont: '11px Verdana', canvasTextColor: '#<?php echo $third_color;?>', shapes: ['triangle', 'x', 'rectangle', 'circle', 'check', 'caret', 'zigzag', 'arrow', 'leftbracket', 'rightbracket', 'v', 'delete', 'star', 'pigtail'] }); }); </script> <?php } } ?> </div><!-- contact-item end--> </div><!-- post end --> <?php } } ?> <div style="clear:both"></div> </div><!-- main end --> <?php get_sidebar();?> </div><!-- blog end --> <?php get_footer();?>
  22. I am using MySQL v5.5.27. I usually would write this SELECT statement like this: SELECT DISTINCT * FROM table WHERE something = 'this OR something = 'that' OR something = 'other' AND thingamajig = 'one' OR thingamajig = 'two' But would this SELECT statement provide the exact same result? SELECT DISTINCT * FROM table WHERE something = ('this OR 'that' OR 'other') AND thingamajig = ('one' OR 'two') I have tried running this and it *seems* to be working. Just want to make sure this second way of doing things won't return errant data in some way that I can't think of. Thanks for any insight, assistance!
×
×
  • 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.