Jump to content

Search the Community

Showing results for tags 'function'.

  • 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

  1. Hey guys, So i have a small yet very simple question more so than an issue. I am trying to call a variable that is a field from a mysql database. i am using an extract() function so any field title just returns as a variable. i have a member page where i then list the member and want to have on the side of their name the year they are born. for ex. <h1> Name ( year ) </h1> So in my data field the year the person is born is given as a full string of text 1984-14-09 Y/dd/m. All i want is the year from this data and to remove the day/month. So i did some research , and i came up with the solution of using an explode(), creating an array, and then simple echoing the index of that data i want. Problem is that the array is then leaving the entire string as one index in the array, basically not doing what i wanted it to do, which was to split the string into parts, allowing me to then echo whatever part i wanted. my code: <h1><a href="#link"><? echo $member_name; ?> (<? $arr = explode(' ',trim($member_birth_date)); print_r($arr); ?>)</a></h1> end result: any suggestions as to how to get the result i am looking for ? would really appreciate any ideas or solutions thanks guys
  2. Good day, I've got a problem getting the value of the parameter on a function I've got this code to append on my div $(' .'+type).append(' <a href="#" id="'+type+'-'+desId+'" class="admin-managers"> <span class="admin-managers" id="'+name+'">'+name+'</span> <span id="'+desId+'" onclick="remove('+type+','+desId+')" class="remove" name="<?php echo $type; ?>"></span></a> '); that is how I append the data and it is working fine, But on the "remove(type,desId)" function on: function remove(type,id){ Alert(type); } the id is working fine, but on the type everytime I alert it it return "javascript:void(0)"> What is that happening,? ?
  3. Hey there guys ! so i have finally finished my register log-in page , and with that i have created a couple functions pages , as i am sure you can assume all the functions for logic will be called from these pages. now i have one called users , i.e for login , registration , check if active, etc.. and i have one for more general functions page called general , i.e for redirects, and input sanitation. anyway my register login page works flawless ( well i guess more 90 % done 90 % left to go ). and now when im on the index page or my main page essentially i now see a fatal error: now i see that it is telling me exactly where the error is , yet i dont understand as to why i am seeing this . im not quite sure as to how the function is being declared already , when the function is only being called once or twice on the register page. just to show you guys what im talking about my code: general.php ( FUNCTIONS ARE STORED) function email($to, $subject, $body){mail($to, $subject, $body, 'From: support@j.m.com'); } function email_to_activate($to, $subject, $body){ mail($to, $subject, $body, 'From: activate@j.m.com'); } function email_user_for_recovery($to, $subject, $body){ mail($to, $subject, $body, 'From: recovery@j.m.com'); } function logged_in_redirect(){ if (logged_in() === true ) header("Location: index.php"); } function protect_page() { // redirects if user is not logged in .. user gets no access page if (logged_in() === false ) { header('Location: no_permission.php'); exit(); } } function admin_access() { global $user_data; if (has_access($user_data['user_id'], 1) === false) { header('Location: index.php'); exit(); } } function page_redirect() { // if user not logged in redirect goes to index page if (logged_in() === false ) { header('Location: index.php'); exit(); } } function redirect(){ // redirects regardless of logged in or not header('Location: index.php'); exit(); } function array_sanitize(&$item){ $items = strip_tags(htmlentities(mysql_real_escape_string($item))); } function sanitize($data) { return strip_tags(htmlentities(mysql_real_escape_string($data))); } function output_errors($errors){ $output = array(); foreach($errors as $error){ $output[] = $error ; } return '<ul>' . implode($output) . '</ul>'; } and index.php // CORE FUNCTIONS - DATABASE CONNECT - SESSIONS & COOKIES include('include/init.php'); // HEADER INFO - META TAGS - LINKS - SCRIPTS include('include/header.php'); // LOG USER IN if (logged_in() === true){ include ('include/widgets/loggedin.php'); } else { include('include/widgets/login.php'); } // WEBSITE LOGO include('include/logo_head.php'); // NAVIGATION BAR include('include/navbar.php'); // MAIN PAGE include('include/topbanner.php'); include('include/topbanner2.php'); <----- Error shows up here and cuts off the rest of the page. include('include/mainbody.php'); // FOOTER include('include/footer.php'); as i mention in the code above, the page spits about half the output then cuts off and displays that error message. This confuses me a bit more actually. any suggestions as to why this is happening ? EDIT : to add init.php ( CORE FILE ) if(!isset($_SESSION)) { session_start(); } error_reporting(E_ALL| E_STRICT); ini_set('display_errors', 1); require ('core/database/dbconnect.php'); require ('core/functions/general.php'); require ('core/functions/users.php'); require 'core/queries/dbqueries.php'; $current_file = explode('/', $_SERVER['SCRIPT_NAME']); $current_file = end($current_file); if (logged_in() === true) { $session_user_id = $_SESSION['user_id']; $user_data = user_data($session_user_id, 'user_id', 'username', 'password', 'email', 'gender', 'country', 'month' ,'date' , 'year', 'pass_recover', 'type'); if (user_active($user_data['username']) === false){ session_destroy(); header('Location: index.php'); exit(); } if($current_file !== 'change_password.php' && $current_file !== 'logout.php' && $user_data['pass_recover'] == 1 ){ header('Location: change_password.php?force'); exit(); } } $errors = array();
  4. Hi all, I am trying to make sure that a user cannot move on unless they select a radiobutton, but unfortunately it's not working. I used same function with checkbox in my other page and it works perfect but i don't know why it is not working here Btw, this is not inside a form (as in other page I have used inside the form) PLEASE HELP echo "<td class='kooltd'><input type = 'radio' name = 'rFlight' value = '".$row['flight_id']."'></td>"; echo "<input type='submit' id='button1' name='booking' value='Make Booking for the Selected Flight' onclick='if(!this.form.rFlight.checked){alert('You must select a flight.');return false}'/></br>";
  5. Hello my beautiful freaks, i have an issue trying to create my forgot username code. i am trying to send my end user an email with their loggin info ( more specifically the username ) <? function recover($mode, $email) { $mode = sanitize($mode); $email = sanitize($email); $user_data = user_data(user_id_from_email($email),'username'); if ( $mode == 'username') { email_user_for_recovery($email, 'Your username info', " Hello, This email has been sent from http://j.justin7410.com/recover.php You have received this email because this email address" .$user_data['email'] . ", was used during the registration process of our website. There has been a request for your forgotten username, If you did not request this information plese disregard this email. You do not need to unsubscribe or take any further action. Your sign-in username is: " .$user_data['username'] . // <--- THIS VARIABLE IS NOT BEING INDEXED CORRECTLY "Thank you for using j.justin7410.com, we hope to make your experience as easy and seamless as can be. Cheers, - team j.motionempire.com "); in general the $user_data variable is not returning the values i need. i was wondering if you guys had any good way of debugging this issue ? the variables are passing fine in other instances, but when passed through it wont echo the things i need the email received is just sending everything but the data needed/ thanks guys
  6. Hey freaks, i have been working on a log in / register system for a couple days now, and i am in the process of finalizing my end users activation of a newly registered account. I was having no real issues until now, to where i am utterly confused as to why i am having such a core problem. So for the first part i had a user register, and wanted to make sure the user is not already entering an email that already exists in my Database. if (email_exists($_POST['register_email']) === true) { $errors[] = 'The email you provided is already in use. If you are having trouble remembering your user info click <a href="#">here</a>'; } the error goes to an errors array i have setup with all the errors that would display to the end user if any occur. the email_exists() is the following : function email_exists($email) { $username = sanitize($email); $query = (" SELECT COUNT(`user_id`) FROM `users` WHERE `email` = '$email' "); $results = mysql_query($query); if(mysql_error()) { echo 'MySQL Error: '. mysql_error() .'<br>'; echo 'Query: '.$query; } else if(!mysql_num_rows($results)) { //### row has not been returned } else { //### row has been returned } return (mysql_result($results, 0) == 1) ? true : false; } Now everything in the function calls correctly, and as you see in the error check, row will be returned. Yet, as you see in my IF statement in the error check above, nothing is being returned with the variable i am inputting ( yet the other IF statement all seem to work with the same variable $_POST) now this i figured was the problem to my MAIN and number one issue. Getting my user activation working. if(isset($_GET['success']) === true && empty($_GET['success']) === true){ ?> <h2> Thank you, your account has been activated</h2> <h3> You can now log in and access the site and join the disscussions in out forum !</h3> <? } else if (isset($_GET['email'], $_GET['email_code']) === true){ $email = trim($_GET['email']); $email_code = trim($_GET['email_code']); if (email_exists($email) === false ){ $errors[] = ' We have a problem, we couldn\'t find that email address !'; // THIS IS THE ERROR GIVEN TO USER } else if (activate($email, $email_code) === false) { $errors[] = ' We had a problem activating your account '; } if(empty($errors) === false){ ?> <h2>Oops...</h2> <? echo output_errors($errors); } else { header('Location: activate.php?success'); exit(); } } else { header('Location: index.php'); exit(); } Now above i have highlighted what conditional is passed, when a end user click on the return link to activate their account. as i mentioned above , i know its the email_exists function, since not only does that conditional fail . in database i can create multiple users with the same email. Please guys any help would be greatly appreciated. I am a PHP / Programming noob , but i am trying my best to debug and catch my issues. i just cant figure this one out on my own .
  7. Hey guys, I am currently trying to finalize my registration page, and i am have some issues with the header() function. i know there are certain rules like no html can be above the header. and what not but i am fairly new to this and can figure out why i am outputting an error. my code is : <?if (isset($_GET['success']) && empty($_GET['success'])) { echo '<h1> Thank you for your registration </h1>'; } else { if (empty($_POST) === false && empty($errors) === true ) { $register_data = array( 'email' => $_POST['register_email'], 'username' => $_POST['register_username'], 'password' => $_POST['password'], 'gender' => $_POST['gender'], 'month' => $_POST['month'], 'date' => $_POST['date'], 'year' => $_POST['year'], 'country' => $_POST['country'], ); user_register($register_data); header('Location: register.php?success'); exit(); } else if ( empty($errors) === false) { echo '<div class="register_errors">'; echo '<span style="color:red"><h3>'; echo output_errors($errors); echo '</h3></span>'; echo '</div>'; } } ?> All of the code works for me until i try to send send the message. The error i get is the following : it directs me to my header.php file <!DOCTYPE html> <div> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="author" content="#"> <meta name="keywords" content="#"> <meta name="description" content="#"> <meta name="robots" content="#"> <meta name="revisit-after" content="7 days"> <link href="css/style.css" rel="stylesheet" type="text/css"> <link href="css/normalize.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="jscript/sidebar.js"></script> <script type="text/javascript" src="jscript/mootools.js"></script> <body> <div class="top"> Any suggestions ? cant seem to figure this one out
  8. I have created a user defined function to return a string value function getModel($part) { $root = substr($part,0,4); $query = "SELECT Root, Model FROM tbl_Root WHERE Root = '$root'"; $result = mysql_query($query) or die ("Query Root failed: " . mysql_error()); while ($rec = mysql_fetch_array($result, MYSQL_ASSOC)) { if (in_array($root, $rec)): $Model = $rec['Model']; else: $Model = 'UNKNOWN'; endif; } return $Model; } When trying to find the attributes of several hundred part numbers, I pass them to a MySQL temp table that would then select the distinct part numbers and loop them through my functions. $query = "SELECT DISTINCT A FROM TempAttributes"; $result = mysql_query($query) or die ("Query failed: " . mysql_error()); while ($rec = mysql_fetch_array($result, MYSQL_ASSOC)) { $part = mysql_escape_string($rec['A']); $Model = getModel($part); $query = "REPLACE INTO tbl_Attributes (Part, Model) VALUES ('$part', '$Model')"; $endresult = mysql_query($query) or die ("Query Load failed: " . mysql_error()); } The line of code that stops the execution of my loop is $Model = getModel($part); I executed the loop with this line of code in and it stops after the first part number. When I comment this line of code out, my loop processes all of my part numbers, but of course not with the return values I am looking for. Why does my user defined function not process through the while loop to assign the $Model variable the return value of the getModel function? Please help!
  9. I am getting this error message, "Warning: implode() [function.implode]: Invalid arguments passed in/home/sam139/public_html/_import/functions.php on line 235" and I have no idea where I'm going wrong. The code where the issue is occurring is <p class="bline"><strong>Cast: </strong> <?= implode("<br/>", $p['cast']); ?></p> Where am I going wrong? Any help is much appreciated!
  10. I need to call a javascript or a php function from a form made in php, so that I could make change in data base on clicks. 1)I included the function on onclick event on submit but nothing happens. 2)The file name in which this code is include is view_users.php could someone hel me solve this <?php mysql_select_db("programmers") or die(mysql_error()); $data = mysql_query("SELECT * FROM user_allotment") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { echo "<tr>"; echo "<td>".$info['id'] . "</td>"; echo "<td>".$info['uname'] . "</td> "; echo "<td>".$info['password'] . "</td>"; $id=$info['id']; echo "<form method="post" action="view_users.php">"; echo "<td><label><input type="button" name=/"$id/" value="edit" align="middle" onclick="edit()"/></label></td>"; echo "<td><label><input type="button" name=/"$id/" value="delete" align="middle" onclick="edit()"/></label></td>"; echo "<td><label><input type="checkbox" name=/"$id/" value="privilege" align="middle" onclick="edit()"/></label></td>"; echo "</form>"; echo "</tr>"; } ?>
  11. I have acquired a time clock script that I wanted to try and use, instead of the employees manually punching in and out, but going through it now, found that this function eregi() is old and I have tried to change it to preg_match. Here is the code: elseif (!eregi ("^([0-9]?[0-9])+[-|/|.]+([0-9]?[0-9])+[-|/|.]+(([0-9]{2})|([0-9]{4}))$", $from_date, $date_regs)) { $evil_post = '1'; if ($use_reports_password == "yes") { include '../admin/topmain.php'; } else { include 'topmain.php'; } echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n"; echo " <tr valign=top>\n"; echo " <td>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n"; echo " <tr>\n"; echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red> A valid From Date is required.</td></tr>\n"; echo " </table>\n"; } else { if ($calendar_style == "amer") { if (isset($date_regs)) {$from_month = $date_regs[1]; $from_day = $date_regs[2]; $from_year = $date_regs[3];} if ($from_month > 12 || $from_day > 31) { $evil_post = '1'; if ($use_reports_password == "yes") { include '../admin/topmain.php'; } else { include 'topmain.php'; } echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n"; echo " <tr valign=top>\n"; echo " <td>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n"; echo " <tr>\n"; echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red> A valid From Date is required.</td></tr>\n"; echo " </table>\n"; }} elseif ($calendar_style == "euro") { if (isset($date_regs)) {$from_month = $date_regs[2]; $from_day = $date_regs[1]; $from_year = $date_regs[3];} if ($from_month > 12 || $from_day > 31) { $evil_post = '1'; if ($use_reports_password == "yes") { include '../admin/topmain.php'; } else { include 'topmain.php'; } echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n"; echo " <tr valign=top>\n"; echo " <td>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n"; echo " <tr>\n"; echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red> A valid From Date is required.</td></tr>\n"; echo " </table>\n"; }}}} if (!isset($evil_post)) { if (empty($to_date)) { $evil_post = '1'; if ($use_reports_password == "yes") { include '../admin/topmain.php'; } else { include 'topmain.php'; } echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n"; echo " <tr valign=top>\n"; echo " <td>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n"; echo " <tr>\n"; echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red> A valid To Date is required.</td></tr>\n"; echo " </table>\n"; } elseif (!eregi ("^([0-9]?[0-9])+[-|/|.]+([0-9]?[0-9])+[-|/|.]+(([0-9]{2})|([0-9]{4}))$", $to_date, $date_regs)) { $evil_post = '1'; if ($use_reports_password == "yes") { include '../admin/topmain.php'; } else { include 'topmain.php'; } echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n"; echo " <tr valign=top>\n"; echo " <td>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n"; echo " <tr>\n"; echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red> A valid To Date is required.</td></tr>\n"; echo " </table>\n"; } else { if ($calendar_style == "amer") { if (isset($date_regs)) {$to_month = $date_regs[1]; $to_day = $date_regs[2]; $to_year = $date_regs[3];} if ($to_month > 12 || $to_day > 31) { $evil_post = '1'; if ($use_reports_password == "yes") { include '../admin/topmain.php'; } else { include 'topmain.php'; } echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n"; echo " <tr valign=top>\n"; echo " <td>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n"; echo " <tr>\n"; echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red> A valid To Date is required.</td></tr>\n"; echo " </table>\n"; }} elseif ($calendar_style == "euro") { if (isset($date_regs)) {$to_month = $date_regs[2]; $to_day = $date_regs[1]; $to_year = $date_regs[3];} if ($to_month > 12 || $to_day > 31) { $evil_post = '1'; if ($use_reports_password == "yes") { include '../admin/topmain.php'; } else { include 'topmain.php'; } echo "<table width=100% height=89% border=0 cellpadding=0 cellspacing=1>\n"; echo " <tr valign=top>\n"; echo " <td>\n"; echo " <table width=100% height=100% border=0 cellpadding=10 cellspacing=1>\n"; echo " <tr class=right_main_text>\n"; echo " <td valign=top>\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=0 cellspacing=3>\n"; echo " <tr>\n"; echo " <td class=table_rows width=20 align=center><img src='../images/icons/cancel.png' /></td><td class=table_rows_red> A valid To Date is required.</td></tr>\n"; echo " </table>\n"; }}}} if (isset($evil_post)) { echo " <br />\n"; echo " <form name='form' action='$self' method='post' onsubmit=\"return isFromOrToDate();\">\n"; echo " <table align=center class=table_border width=60% border=0 cellpadding=3 cellspacing=0>\n"; echo " <tr>\n"; echo " <th class=rightside_heading nowrap halign=left colspan=3><img src='../images/icons/report.png' /> Daily Time Report</th></tr>\n"; echo " <tr><td height=15></td></tr>\n"; echo " <input type='hidden' name='date_format' value='$js_datefmt'>\n"; When I change the two lines: !eregi ("^([0-9]?[0-9])+[-|/|.]+([0-9]?[0-9])+[-|/|.]+(([0-9]{2})|([0-9]{4}))$", $from_date, $date_regs) to this: !preg_match("^([0-9]?[0-9])+[-|/|.]+([0-9]?[0-9])+[-|/|.]+(([0-9]{2})|([0-9]{4}))$", $from_date, $date_regs) I get an error saying this: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: No ending delimiter '^' I also get an error within it saying: A valid From Date is required. The calendar style is "amer", so you can ignore the "euro" part of the code, as I did not want to delete anything. Hopefully this is enough information.
  12. Hope this is the right topic for my problem and maybe someone can help me with this! My blog is in wordpress and when you look at the default category page it looks empty, just plain post list so i figured it would be nice to have last few category posts before the content. With the theme which I'm using silverOrchid i already have front page slider which i like so i would like to copy that slider in the category.php which i created earlier and change it to show and change latest posts per category which users are reading. Here is slider code from index.php //include slider if ( $gazpo_settings['gazpo_show_slider'] == 1 ) { get_template_part('includes/slider'); } So my question is how to change this code (if possible) to show latest posts from category which users are reading? I tried a few different forum threads but non of them seams understandable enough for me so i would appreciate help .... thanx
  13. insertion of data in database using function in php
  14. Hello I tried to move the bold section of the below code into a function getWeights() located in a m_weight.php file (I want to implement MVC pattern) <?php $get_weights_q = mysql_query (" SELECT * FROM users_weight WHERE weight_uid = '$user_id' ORDER BY weight_date DESC ", toctoc() ) or die(mysql_error() ); while ($weight = mysql_fetch_array($get_weights_q)) { ?> <li> <?php echo date( " d M-y H:i (l) " , $weight['weight_date']). ' : ' . $weight['weight'] . ' <a href="'.$_SERVER['SCRIPT_NAME'].'?del=' . $weight['weight_id'] . '">Changer</a> ' ; } ?> </li> </ul> ---------------- Here is the function: function getWeights($user_id) { $get_weights_q = mysql_query (" SELECT * FROM users_weight WHERE weight_uid = '$user_id' ORDER BY weight_date DESC ", toctoc() ) or die(mysql_error()); } The result is : Notice: Undefined variable: get_weights_q in H:\home\user\documents\DEV-H\EasyPHP-5.3.8.1\www\Food-Tribe\v_weight.php on line 44 Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in H:\home\user\documents\DEV-H\EasyPHP-5.3.8.1\www\Food-Tribe\v_weight.php on line 44 If I let the code just above the While, in procedural mode it works fine... Any idea?
  15. Hi, I'm using a preg_replace to change [menu] into Menu::makeMenu(); , but when it executes the replace, for some reason it's sending my code to the first line after the <body> tag rather than where the [menu] was in the first place. Preg Replace: function formatPage($transform){ $a = array( "/\[element=\"(.*?)\"\]/ise", "/\ /ise", "/\[menu]/ise", "/\[login-button]/ise", ); $b = array( "elementCreate(\"$1\");", "pageCreate();", "Menu::makeMenu();", "loginBtn();", ); $transform = preg_replace($a, $b, $transform); return $transform; } I can copy out the whole function and stuff for the Menu:: but I don't think it'll matter. Please help! Cheers.
  16. I have a problem when i Click the Edit button int he form, the database doesn't update, In the beginning i thought i had a problem with the query, but I did a check as a query and everything was fine. Can someone suggest something please. //this is the file - album.func.php function edit_album($album_id, $album_name, $album_description) { $album_id = ((int)$album_id); $album_name = mysql_real_escape_string($album_name); $album_description = mysql_real_escape_string($album_description); mysql_query("UPDATE `albums` SET `name`='$album_name', `description`='$album_description' WHERE `album_id`='$album_id' AND `user_id`=".$_SESSION["user_id"]); } //this is the file - edit_album.php if (!empty($errors)) { foreach ($errors as $error) echo $error; }else { edit_album($album_id, $album_name, $album_description); header('Location: index.php'); exit(); }} ?> <?php $album_id = $_GET["album_id"]; $album_data = album_data($album_id, 'name', 'description'); ?> //this is the form <form action="?album_id=<?php echo $album_id; ?>" method="post"> <p>Name:</br><input type="text" name="album_name" maxlength="55" value="<?php echo $album_data["name"]; ?>"/></p> <p>Description:</br><textarea name="album_description" rows="6" cols="35" maxlength="500"><?php echo $album_data["description"]; ?>
  17. Hi all, I'm experiencing a lot of trouble trying to create a script for my website. I'm making a database dependant menu, and I've spent a couple of days doing trial and error much to no prevail. I'm using Twitter Bootstrap if anyone is familiar with it, and creating a drop down menu. The code for each of these buttons is: <div class="btn-group"> <a class="btn btn-inverse dropdown-toggle" data-toggle="dropdown" href="#"> WOD <span class="caret"></span> </a> <ul class="dropdown-menu"> <!-- dropdown menu links --> <li><a tabindex="-1" href="http://www.google.com.au">View the WOD</a></li> <li><a tabindex="-1" href="#">WOD Archives</a></li> <li class="divider"></li> <li><a tabindex="-1" href="#">Benchmarks</a></li> </ul> </div> So, what I need to be able to do is call each menu that I have in the database, (I have 5), determine if it's a drop down, and if it is, echo the links for it inside of the <ul class="dropdown-menu"> It seems simple to me, but I cannot get it right. Please help! Cheers.
  18. All, I had someone request a function to be written. Here's what they said: can you take a list of ints and get back a list of indices that add up to a variable 'X'?? here's what they asked for (as an example)... Input: ([1,4,7,2], X=3) output: [[0,1]] I'm not quite sure I'm following it. Anyone shed some light on this for me? I'm just not getting what they want, probably because I don't have formal training in coding. Vocabs are always mismatched. thanks.
  19. Hi all, i am fairly new with php and i am running into a problem with a php function. It is very basic but i've got something wrong here. It is a function in wordpress that needs to analyze the post and extract the category. For every category another value needs to be returned. My code is: function postimage($post_id){ $category = get_the_category( $post_id ); $id = $category[0]->cat_ID; if ( $id = 45 ){ $link = 'This is category 45'; } else { $link = 'This is not category 45 '; } return $link; } There are 2 strange things happening: 1. The first statement is always true. Even if the category id is not 45 it still returns the first $link. 2. If i return the variable $id after the if statement it returns als 45. If i do it without the if statement it returns correct. The 2 problems are obviously related but i don't understand what i'm doing wrong. Please help
  20. Hello everyone, i have to say im a severe newbie. I know very little php, but im struggling to learn it. Im trying to complete a tutorial but somewhere somehow it doesnt work as intended. I have problems displaying the entries i have in my db table. They dont show up in Index.php. There are 4 short files, seperated with brackets ## http://pastebin.com/7wXGxyT4. Perhaps its the $fulldisp that doesnt play well. I would appreciate some help alot! Thank you.
  21. I have the following function, which I'm struggling to convert: /******************************************************/ function start() { global $dpath, $rb_head, $rb_foot, $siteurl; /******************************************************/ include("$dpath$rb_head"); $ip = getenv ("REMOTE_ADDR"); $urllink = getenv("HTTP_REFERER"); if (!ereg("$siteurl", "$urllink")) { $urllink2 = "$siteurl"; //echo "<br /><b>Page being Referred</b>: <a href=$urllink2>$urllink2</a>\n"; } else { $urllink2 = "$urllink"; //echo "<br /><b>Page being Referred</b>: <a href=$urllink2>$urllink2</a>\n"; } include("rb_form.php"); crkdo(); include("$dpath$rb_foot"); } Any help would be appreciated. Duncan
  22. Hi Guys, From what I can tell, there is no other similar inquiry around... I'm completing my Higher School Certificate (final year of high school in New South Wales Australia) and I'm creating a web system for a major. Part of it requires me to have fully dynamic pages for my clients purpose, and I'm using database elements - so basically there is a BB Code site editor that translates [element=menu] to <?php elementCreate("menu"); ?> What I'm finding for some reason I can't contemplate, is that it's just blatantly not working! And when I use view source the <?php elementCreate("menu"); ?> is green as if it's a comment? function bbElement($transform){ $a = array( "/\[element=\"(.*?)\"\]/is", ); $b = array( "<?php echo elementCreate($1); ?>", ); $transform = preg_replace($a, $b, $transform); return $transform; } function elementCreate($element){ $element_fetch = mysql_query("SELECT * FROM `elements` WHERE `element_name` = '".$element."'")or die(mysql_error()); while($element_info = mysql_fetch_array($element_fetch, MYSQL_ASSOC)){ $econt = $element_info['content']; } return $econt; } It's quiet likely I've missed something simple - but all help is appreciated! Cheers.
  23. keep getting this in my code Warning: preg_match() [function.preg-match]: Unknown modifier 'd' in /home/content/52/9922952/html/sg_contact_content/contact_i51contact.php on line 38 <?php /* This PHP form mailing script created by SiteGrinder 3.1.2 s_239 http://www.medialab.com/sitegrinder3 */ function stripFormSlashes($arr) { if(!is_array($arr)) { return stripslashes($arr); } else { return array_map('stripFormSlashes', $arr); } } if(get_magic_quotes_gpc()) { $_POST = stripFormSlashes($_POST); } if(($_POST['email']=="")) { echo "<html><body><p>The following fields are <strong>required</strong>.</p><ul>"; if($_POST['email'] == ""){ echo "<li>*Email</li>"; } echo "</ul><p>Please use your browsers <a href=\"javascript:history.back();\">Back</a> button and fill out these fields.</p></body></html>"; } else { $message = ""; $message .= "Name: " . htmlspecialchars($_POST['name'], ENT_QUOTES) . "<br>\n"; $message .= "*Email: " . htmlspecialchars($_POST['email'], ENT_QUOTES) . "<br>\n"; $message .= "Inquiring: " . htmlspecialchars($_POST['inquiring'], ENT_QUOTES) . "<br>\n"; $message .= "Comments: " . htmlspecialchars($_POST['comments'], ENT_QUOTES) . "<br>\n"; $lowmsg = strtolower($message); $injection_strings = array ( "content-type:","charset=","mime-version:","multipart/mixed","bcc:","cc:"); foreach($injection_strings as $suspect) { if((preg_match("/$suspect/",$lowmsg)) || (preg_match("/$suspect/", strtolower($_POST['name']))) || (preg_match("/$suspect/", strtolower($_POST['email'])))) { die ( 'Illegal Input. Go back and try again. Your message has not been sent.' ); } } $headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: \"" . $_POST['name'] . "\" <" . $_POST['email'] . ">\r\n"; $headers .= "Reply-To: " . $_POST['email'] . "\r\n"; $message = utf8_decode($message); mail("andierue@yahoo.com", "Authentic Health Inquiry", $message, $headers); header("Location: http://www.authentichealthbykate/thank-you.html"); } ?>
  24. I am getting some errors on my PHP form --- first one is Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in /home/content/52/9922952/html/sg_contact… on line 38 and the other is Warning: Cannot modify header information - headers already sent by (output started at /home/content/52/9922952/html/sg_contact… in /home/content/52/9922952/html/sg_contact… on line 48 HERE IS MY ORIGINAL CODE FOR THE FILE---PLEASE HELP WITH THE CHANGES I NEED TO MAKE-- ______________________________________… <?php /* This PHP form mailing script created by SiteGrinder 3.1.2 s_239 http://www.medialab.com/sitegrinder3 */ function stripFormSlashes($arr) { if(!is_array($arr)) { return stripslashes($arr); } else { return array_map('stripFormSlashes', $arr); } } if(get_magic_quotes_gpc()) { $_POST = stripFormSlashes($_POST); } if(($_POST['email']=="")) { echo "<html><body><p>The following fields are <strong>required</strong>.</p><ul>"; if($_POST['email'] == ""){ echo "<li>*Email</li>"; } echo "</ul><p>Please use your browsers <a href=\"javascript:history.back();\">Back… button and fill out these fields.</p></body></html>"; } else { $message = ""; $message .= "Name: " . htmlspecialchars($_POST['name'], ENT_QUOTES) . "<br>\n"; $message .= "*Email: " . htmlspecialchars($_POST['email'], ENT_QUOTES) . "<br>\n"; $message .= "Inquiring: " . htmlspecialchars($_POST['inquiring'], ENT_QUOTES) . "<br>\n"; $message .= "Comments: " . htmlspecialchars($_POST['comments'], ENT_QUOTES) . "<br>\n"; $lowmsg = strtolower($message); $injection_strings = array ( "content-type:","charset=","mime-version… foreach($injection_strings as $suspect) { if(( preg_match($suspect, $lowmsg)) || ( preg_match($suspect, strtolower($_POST['name']))) || ( preg_match($suspect, strtolower($_POST['email'])))) { die ( 'Illegal Input. Go back and try again. Your message has not been sent.' ); } } $headers = "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n"; $headers .= "From: \"" . $_POST['name'] . "\" <" . $_POST['email'] . ">\r\n"; $headers .= "Reply-To: " . $_POST['email'] . "\r\n"; $message = utf8_decode($message); mail("andierue@yahoo.com", "Authentic Health Inquiry", $message, $headers); header("Location: http://www.authentichealthbykate/thank-you.html"); } ?> ______________________________________… THANK YOU VERY MUCH FOR YOUR TIME!!!!!!! contact_i51contact.php
  25. Please could you help.. I need to make this code allow me to use the showDiv function multiple times on the page.. <script type="text/javascript"> function showDiv() { document.getElementById('welcomeDiv').style.display = "block"; } function hideDiv() { document.getElementById('welcomeDiv').style.display = "none"; } </script> <a name="answer" value="Show Div" onclick="showDiv()" >Show</a> <div id="welcomeDiv" style="display:none;" class="answer_list" > <h2>Hello</h2> <button onclick="hideDiv()" class="loginBut" style="font-family: 'Handjet', cursive; font-size: 2EM;">Close</button> </div> Thanks. It seems I need to add an index variable to the function. Don't know how though.. I'm new to JS.
×
×
  • 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.