Jump to content

Search the Community

Showing results for tags 'php'.

  • 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. 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. ?>
  2. Hi Folks I have been trying to get a sql query to pass between pages in moodle 2.x. Moodle uses object orientation. The problem I have is the processed query return $DB->get_records($sql) will not pass back to index.php without a horrible hack. First: There are two files, index.php and lib.php (has functions in it) index.php calls lib.php with this line: $users = get_mentor_users($fromdate, $todate); lib.php executes this function: function get_mentor_users($fromdate = 0, $todate = 0){ $sql = "SELECT DISTINCT u.id , u.firstname, u.lastname FROM mdl_role_assignments ra, mdl_user u, mdl_course c, mdl_context cxt WHERE ra.userid = u.id AND ra.contextid = cxt.id AND cxt.contextlevel =50 AND ( roleid =3 ) AND u.firstname LIKE '%mentor%'"; if($datesql = generate_sql_range($fromdate, $todate, ', mdl_grade_grades.timemodified')) { $sql .= " AND $datesql"; } return $DB->get_records_sql($sql); } Now for the perplexing part. index.php throws out a blank screen. I rewrote this function to pass the sql string from lib.php to index.php then for index.php to do the sql query locally and then it works fine. Like so: index.php $sql2 = get_mentor_users($fromdate, $todate); $users = array(); $users = $DB->get_records_sql($sql2); But then accessing the array gets kinda ugly. Then in lib.php only the unprocessed sql string is returned back to index.php. function get_mentor_users($fromdate = 0, $todate = 0){ $sql = "SELECT DISTINCT u.id , u.firstname, u.lastname FROM mdl_role_assignments ra, mdl_user u, mdl_course c, mdl_context cxt WHERE ra.userid = u.id AND ra.contextid = cxt.id AND cxt.contextlevel =50 AND ( roleid =3 ) AND u.firstname LIKE '%mentor%'"; if($datesql = generate_sql_range($fromdate, $todate, ', mdl_grade_grades.timemodified')) { $sql .= " AND $datesql"; } return $sql; } The output of the array below: Array ( [12] => stdClass Object ( [id] => 12 [firstname] => Mentor Peter [lastname] => Swananipoel [totalmarked] => [totalcommarked] => 0 [totalsummarked] => 0 [markedcompetent] => 0 [markedincompetent] => 0 ) [14] => stdClass Object ( [id] => 14 [firstname] => Mentor Garfield [lastname] => Robertson [totalmarked] => [totalcommarked] => 0 [totalsummarked] => 0 [markedcompetent] => 0 [markedincompetent] => 0 ) [15] => stdClass Object ( [id] => 15 [firstname] => Mentor Bert [lastname] => Cat [totalmarked] => [totalcommarked] => 0 [totalsummarked] => 0 [markedcompetent] => 0 [markedincompetent] => 0 ) ) How can I pass this array between pages without the shenanigans? Thanks
  3. I have created the chat system. I want to reload the div so that it can have the effect of instant messaging.I am very new to php. Can anyone help me? Attached is the php file of the display messagees page:( conversations.php
  4. This is the function I am currently working with... /** * Retrieve search query text * * @return string */ public function getQueryText() { if (!isset($this->_queryText)) { $this->_queryText = $this->_getRequest()->getParam($this->getQueryParamName()); $noescape = preg_replace("/%u([0-9a-f]{3,4})/i","\\1;",urldecode($this->_queryText)); if ($this->_queryText === null) { $this->_queryText = ''; } else { /* @var $stringHelper Mage_Core_Helper_String */ $stringHelper = Mage::helper('core/string'); $this->_queryText = is_array($this->_queryText) ? '' : $stringHelper->cleanString(trim($this->_queryText)); echo '<span style="display: none;">'; echo '<pre>'; var_dump ( $noescape ); echo '</pre>'; echo '</span>'; $maxQueryLength = $this->getMaxQueryLength(); if ($maxQueryLength !== '' && $stringHelper->strlen($this->_queryText) > $maxQueryLength) { $this->_queryText = $stringHelper->substr($this->_queryText, 0, $maxQueryLength); $this->_isMaxLength = true; } } } return $this->_queryText; } I can echo what I need to output in this function with $noescape however I need to modify return $this->_queryText; to include the preg_replace and rawurldecode from $noescape. Please could someone be kind enough to advise of the correct syntax/way of handling this? I did post this on StackOverflow but had no response as of yet. Thanks in advance.
  5. hello i have a dropdown box where i have populated values from the sql database. no when i select a value from the drop dopwn, i want to display all the records related to that value under the dropdown. here is my code <?php $select=FALSE; require_once ("configFile.php"); $result=mysql_query("SELECT Registration_No FROM vehicle_master "); if($result == FALSE) { die(mysql_error()); // TODO: better error handling } //populate dropdown with vehicles //echo "<label>Select vehicle number : </label>"; //echo "<select name='vehicles'>"; //while ($row = mysql_fetch_array($result)) //{ // echo "<option value='numberPlate'>" . $row['Registration_No'] . "</option>"; //} //echo "</select>"; //echo "<br><br>"; // $select=isset($_POST['vehicles']); ?> <form id="form1" name="form1" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <?php echo "<select name='select'>"; $list=mysql_query("SELECT * from vehicle_master"); while($row_list=mysql_fetch_assoc($list)) { ?> <option value="<?php echo $row_list['Registration_No']; ?>" <?php if($row_list['Registration_No']==$select) { echo "selected"; } ?>> <?php echo $row_list['Registration_No']; ?> </option> <?php } ?> </select> <input type="submit" name="Submit" value="select" /> </form> <br> <?php if (isset($_POST['SELECT'])) { $Registration_Nos=mysql_real_escape_string($_POST['SELECT']); $result=mysql_query("SELECT * FROM vehicle_master WHERE Registration_No='".$Registration_Nos."'"); while ($row=mysql_fetch_assoc($result)) { echo "".$row['Emergency_Contact_1'].""; } }?>. can anyone tell me where am i going wrong ? control.php
  6. Hello, i need some help i dont know how to send to $message,$naam,$tel <?php } else // the user has submitted the form { // Check if the "from" input field is filled out if (isset($_POST["from"])) { // Check if "from" email address is valid $mailcheck = spamcheck($_POST["from"]); if ($mailcheck==FALSE) { echo "Invalid input"; } else { $from = $_POST["from"]; // sender $subject = $_POST["subject"]; $message = $_POST["message"]; $naam = $_POST["naam"]; $tel = $_POST["tel"]; // message lines should not exceed 70 characters (PHP rule), so wrap it $message = wordwrap($message, 70) ; // send mail mail("example@gmail.com",$subject,$message,"From: $from\n"); echo "u wordt zo spoedig mogelijk geholpen"; } } } ?> What do i need to change ? Thanks.
  7. Hi I want to include a php file (basically my personal header) above the phpbb forum header. The file where I am inserting the code is "page_header.php" which is located in the includes folder. (file attached in this post). If I insert the following code: $root = realpath($_SERVER["DOCUMENT_ROOT"]); include "$root/top.php"; I get what I want but the font color of all the topics posted in the forum change from black to white (making it unreadable). How can I rectify this conflict and how is it happening? Thanks (I am new to php) page_header.php
  8. Hi all, I was wondering if you can help me with an issue I am having with my website. I am very new to php/html/css and mysql so I know very little. I have an order form on my website which when filled in send data to my database. I then have an admin page on my site which shows the data in the database. However, I need the data to be stored in a table with a row containing the column name and then each row showing the actual data underneath. Would like it in a grid sort of format. My current code is: <!doctype html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <link href="css/style.css" rel="stylesheet" type="text/css" /> <link href="css/reset.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container2"> <div id="adminpanel"> Admin Page <div id="showorders"><u>Orders</u></div> <?php include('connection.php'); $result = mysql_query("SELECT * FROM orderform"); while($row = mysql_fetch_array($result)) { echo "<span style='color: #333; width: 200px; height: 200px; padding: 1px; border: 1px solid #ff9900;'>" . $row['product'] . " " . $row['productcomments'] . " " . $row['name'] . " " . $row['address'] . " " . $row['age'] . " " . $row['delivery'] . "</span>" ; echo "<br>"; } ?> <div id="showreviews"><u>Reviews</u></div> <?php $result = mysql_query("SELECT * FROM reviewform"); while($row = mysql_fetch_array($result)) { echo "<span style='color: #333; width: 200px; height: 200px; padding: 5px; border: 1px solid #ff9900;'>" . $row['name'] . " " . $row['product'] . " " . $row['comment'] . "</span>" ; echo "<br>"; echo $row['name'] . " " . $row['product'] . " " . $row['comment'] ; echo "<br>"; } ?> </div> </div> </body> This code puts a border around each row but doesnt seperate each column and doesnt show a header. Ultimately, I am going to want to sort each order by different criteria e.g alphabetical, date ordered, product type. All help is really appreciated as I am really pushed for time and a complete beginner. Thanks Jonathan
  9. //CHECK TO SEE IF TABLE ALREADY EXISTS TO THE DATE if($TABLE_NAME == $date){ // IF EXISTS THEN DROP THE TABLE echo 'THIS DATE ALREADY EXISTS <br>'; $drop_table = "DROP TABLE` " .$date."`"; mysql_query($drop_table); echo '<h4>THE TABLE HAS BEEN DROPPED</h4><h5>NOW SELECT THE FILE YOU WANT TO CREATE</h5>'; } else{ // CREATE THE NEW TABLE $create_table = "CREATE TABLE `".$date."` ( `entry_id` int(11) NOT NULL, `transaction_id` varchar(55) NOT NULL, `name` varchar(255) character set latin1 default NULL, `price` varchar(11) character set latin1 default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8"; mysql_query($create_table); echo 'NEW TABLE HAS BEEN CREATED PLEASE MOVE TO NEXT STEP'; } $run_q = mysql_query($create_table); $return = '<h4>FILE THAT YOU SELECTED:</h4>' . $_FILES['file']['name']; $file = $_FILES['file']['tmp_name']; $handle = fopen($file,"r"); while(($fileop = fgetcsv($handle,1000,",")) !== false){ $name = $fileop[0]; $price = $fileop[1]; $t_id = $fileop[2]; $ship_method = ''; $cc = ''; $address = ''; $city = ''; $state = ''; $cc = ''; $email = ''; $p_name = ''; $p_quantity = ''; $total = ''; $id = ''; $date = ''; } I can't seem to get the DROP TABLE query to execute through PHP. It is not a multiple query or anything that would create confusion, and when imputed into SQL directly fire correctly. Any suggestions ?
  10. I have a form, that is a chat apps am building for project. Now everything seems to be working fine to the best of my ability. I want to submit the data from the form into my php script without any form of reload. That means i don't want redirection, to the action page and back to the chat page. What i want is for the page to submit the form at the background. And i know i need ajax to this bt i cnt get it right. Here is my form <form method="post" id='chatbox' action="reply.php"> <input type="text" id="text" name="adchat"/> <input type='hidden' id='user_id' name='id' value='1'> <input type='hidden' id='user_name' name='id' value='Ben'> <input type='submit' id='submit' name='chat' value='send'></form> What i need is an ajax code to submit d variable to the reply.php scrit and maybe a message to display when the form it been submitted say something like (sending...). Thanks for assiting. Pls i don't know anything when it comes to AJAX. Please forgive me and help me. Don't borther about displaying the user input just make it submit it to the php script. Thank you once again.
  11. shannel

    help

    Hi all, wondering if you have any ideas about this. I am trying to do an insert function only if the username exists . I am able to do this successfully BUT i'm having a problem doing the insert only for the ID associated with the username. So it would check if "Susan Bingam" is in the staff_details table, then grabs the ID associated with Susan and adds her into the password table using the password she entered into the html form it should record this ID in the password table too . I would really appreciate your help. Thank you Below is the code I have so far. $url_id = mysql_real_escape_string($_GET['id']); $uname = $_POST['uname']; $check = "(SELECT * FROM staff_details WHERE user_Name = '$uname' && id = '$url_id')"; //echo ($check); $checkResult = mysql_query($check); //$checkRows = mysql_num_rows($checkResult); echo($uname); if (mysql_num_rows($checkResult) > 0)//isset($checkRows)))// && ($checkRows == 0)) { $password = $_POST['password']; $sql2 = "INSERT INTO `password` (ID,password,registration_date) VALUES ('$url_id','$password','') "; $query2 = mysql_query($sql2); print("SUCCESSFULL."); } else { print("Error , you need to be a member of staff to sign up."); }
  12. I got a movie search website but when I search something it says 404 page not found. The site is working under a framework called code igniter. Here is the back-end code of search engine: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Search extends CI_Controller { function __construct() { parent::__construct(); } public function index($extra=array()) { $q = $this->input->get('q'); if (!empty($q)) { redirect('search/' . $q); } redirect(); } public function do_search() { $this->load->model('movies'); $this->load->model('ssearch'); $search_string = $this->uri->segment(2); $data['main_menubar']['categories'] = $this->movies->get_all_categories(); $data['search']['results'] = $this->ssearch->search_for_movies($search_string); echo $this->load->view('includes/header', (isset($data['header']) ? $data['header'] : ''), true); echo $this->load->view('includes/main_menubar', (isset($data['main_menubar']) ? $data['main_menubar'] : ''), true); echo $this->load->view('search', (isset($data['search']) ? $data['search'] : ''), true); echo $this->load->view('includes/footer', (isset($data['footer']) ? $data['footer'] : ''), true); } } And the front-end code: <div class="content_segment recentMovies clearfix"> <div class="segment_title clearfix"> Search: <?php echo urldecode($this->uri->segment(2)); ?> </div> <!-- segment_title --> <div class="inner_padding clearfix"> <div class="horisontal_movie_list clearfix"> <?php if(empty($results)) : ?> <p>No movies found.</p> <?php endif; ?> <ul> <?php if(!empty($results)): ?> <?php foreach($results as $movie) : ?> <?php $categories = explode(',', $movie['categories']); $cat_ids = explode(',', $movie['categories_id']); $movie['categories'] = ""; for ($i=0; $i < count($categories); ++$i) { $movie['categories'] .= '<a href="'.site_url('view/category/'. $cat_ids[$i]).'">'.$categories[$i].'</a>, '; } $movie['categories'] = substr($movie['categories'], 0, -2); ?> <li> <a href="<?php echo site_url('view/movie/'. $movie['id']); ?>"> <div class="imageWrapper"> <img src="<?php echo base_url() . 'img/movie_covers/' . $movie['cover_image']; ?>" alt="No cover!" /> </div> </a> <div class="information"> <h4 class="title"> <?php if($movie['favorite'] == 1) : ?><img src="<?php echo base_url(); ?>img/other/favorite_icon_small.png" alt="" /><?php endif; ?> <a href="<?php echo site_url('view/movie/'. $movie['id']); ?>"> <?php echo $movie['movie_title']; ?> </a> </h4> <p class="meta"><?php echo $movie['categories']; ?> | <?php echo $movie['release_date']; ?> | First watched <?php echo date('F j, Y', $movie['watch_date']); ?></p> <p class="description"><?php echo $movie['description']; ?></p> </div> </li> <?php endforeach; ?> <?php endif; ?> </ul> </div> </div> <!-- list --> </div> <!-- content_segment --> The menu bar search: <menu class="menubar clearfix"> <a class="logo" href="<?php echo site_url(); ?>"></a> <ul class="clearfix"> <li> <a href="<?php echo site_url() ?>"> Home </a> </li> <li> <a href="<?php echo site_url('view/movies'); ?>"> Movies </a> </li> <li class="categories_link"> <a href="<?php echo site_url('view/category') ?>"> Categories </a> <ul> <?php foreach ($categories as $cat) : ?> <li><a href="<?php echo site_url('view/category/' . $cat['id']); ?>"><?php echo $cat['name']; ?></a></li> <?php endforeach; ?> </ul> </li> <li> <a href="<?php echo site_url('admin') ?>"> Admin area </a> </li> </ul> <div class="search"> <form action="<?php echo site_url('search'); ?>" method="GET"> <input type="search" name="search.php" value="" autofocus placeholder="Search" /> </form> </div> </menu> I hope someone finds a solution, I am stuck for 2 days. Cheers.
  13. $create_table = "SET FOREIGN_KEY_CHECKS=0; DROP TABLE IF EXISTS `" .$date."`; CREATE TABLE `".$date."` ( `transaction_id` varchar(11) NOT NULL, `name` varchar(255) character set latin1 default NULL, `price` varchar(255) character set latin1 default NULL ) ENGINE=MyISAM DEFAULT CHARSET=utf8"; $run_query = mysql_query($create_table); Ok so i am some what confused as to why my table is not being created with this. When I insert the query directly into SQL the table is created with no error or issue. So i know the statement is true and syntax is not an issue. When i create the variable in PHP with the same query, then try to run the query, the same table is then not created in the DB. Am i missing a step ? usually this is pretty straight forward when working with DB. I would usually grab the data then fetch the array, then extract the data into a set of variables. Any suggestions ?
  14. I am getting huge errors in error log of my website. Like this [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_query() expects parameter 2 to be resource, boolean given in /home/ticket4t/public_html/management/include/connect.php on line 58 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_close() expects parameter 1 to be resource, boolean given in /home/ticket4t/public_html/management/include/connect.php on line 138 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /home/ticket4t/public_html/management/include/connect.php on line 87 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Too many connections in /home/ticket4t/public_html/management/include/connect.php on line 34 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home/ticket4t/public_html/management/include/connect.php on line 42 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_query() expects parameter 2 to be resource, boolean given in /home/ticket4t/public_html/management/include/connect.php on line 58 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_close() expects parameter 1 to be resource, boolean given in /home/ticket4t/public_html/management/include/connect.php on line 138 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /home/ticket4t/public_html/management/include/connect.php on line 87 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Too many connections in /home/ticket4t/public_html/management/include/connect.php on line 34 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home/ticket4t/public_html/management/include/connect.php on line 42 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_query() expects parameter 2 to be resource, boolean given in /home/ticket4t/public_html/management/include/connect.php on line 58 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_close() expects parameter 1 to be resource, boolean given in /home/ticket4t/public_html/management/include/connect.php on line 138 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /home/ticket4t/public_html/management/include/connect.php on line 87 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Too many connections in /home/ticket4t/public_html/management/include/connect.php on line 34 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home/ticket4t/public_html/management/include/connect.php on line 42 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_query() expects parameter 2 to be resource, boolean given in /home/ticket4t/public_html/management/include/connect.php on line 58 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_close() expects parameter 1 to be resource, boolean given in /home/ticket4t/public_html/management/include/connect.php on line 138 [15-Mar-2014 12:34:34 America/New_York] PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /home/ticket4t/public_html/management/include/connect.php on line 87 [15-Mar-2014 12:34:38 America/New_York] PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Too many connections in /home/ticket4t/public_html/management/include/connect.php on line 34 [15-Mar-2014 12:34:38 America/New_York] PHP Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home/ticket4t/public_html/management/include/connect.php on line 42 [15-Mar-2014 12:34:38 America/New_York] PHP Warning: mysql_query() expects parameter 2 to be resource, boolean given in /home/ticket4t/public_html/management/include/connect.php on line 58 [15-Mar-2014 12:34:38 America/New_York] PHP Warning: mysql_close() expects parameter 1 to be resource, boolean given in /home/ticket4t/public_html/management/include/connect.php on line 138 [15-Mar-2014 12:34:38 America/New_York] PHP Warning: mysql_fetch_array() expects parameter 1 to be resource, null given in /home/ticket4t/public_html/management/include/connect.php on line 87 given below is the code of connect.php Please help me to solve this problem. ------------------------------------------------------------------------------------------ <?php class dbcore { var $dblink, $dbhost, $dbuser, $dbpass, $dbname, $link, $Errno, $Error; function dbcore() { global $db_org; $this->getdblinks($db_org); } function getdblinks($pm_dbvars) { $this->dbhost = $pm_dbvars["dbhost"]; $this->dbuser = $pm_dbvars["dbuser"]; $this->dbpass = $pm_dbvars["dbpass"]; $this->dbname = $pm_dbvars["dbname"]; } function setdblinks($pm_dblink, $pm_dbhost, $pm_dbuser, $pm_dbpass, $pm_dbname) { $this->dbhost = $pm_dbhost; $this->dbuser = $pm_dbuser; $this->dbpass = $pm_dbpass; $this->dbname = $pm_dbname; } function siri_open() { global $wwwroot; $t_link = mysql_connect($this->dbhost, $this->dbuser, $this->dbpass); if(!$t_link) { // header("Location: ".$wwwroot."page-error"); $this->Errno = mysql_errno(); //$this->Error = mysql_error(); $this->error("Unable to Connect the Server".$this->dbhost); } $bool = mysql_select_db($this->dbname, $t_link); if(!$bool) { // header("Location: ".$wwwroot."page-error"); $this->Errno = mysql_errno(); //$this->Error = mysqli_error(); $this->error("Database Not Found :".$this->dbname); } return $t_link; break; } function siri_query($my_qry) { $this->link = $this->siri_open(); $qid= mysql_query ($my_qry, $this->link); $this->siri_close($this->link); if(!$qid){ $this->Errno = mysql_error(); $this->Error = mysql_error(); $this->error("Problem In Executing the Query:" . $my_qry); } return $qid; } function siri_count($my_qry) { // returns the count value. $this->link = $this->siri_open(); $qid = mysqli_query ($this->link, $my_qry); $this->siri_close($this->link); if(!$qid){ $this->Errno = mysqli_errno(); $this->Error = mysqli_error(); $this->error("Problem In Executing the Query:" . $my_qry); } $count = $this->siri_fetch_array($qid); return $count[0]; } function siri_fetch_array($qid) { return mysql_fetch_array($qid); } function siri_fetch_accos($qid) { return mysqli_fetch_assoc($qid); } function siri_real_escape_string($qid) { $this->link = $this->siri_open(); return mysqli_real_escape_string($qid); } function siri_fetch_row($qid) { return mysqli_fetch_row($qid); } function siri_fetch_object($qid) { return @mysqli_fetch_object($qid); } function siri_num_rows($qid) { $quy = mysql_num_rows($qid); return $quy; } function siri_affected_rows() { // for insert, update, delete reasons. return mysqli_affected_rows(); } function siri_insert_id() { return mysqli_insert_id($link); } function siri_insert_id1() { return mysqli_insert_id(); } function siri_free_result($qid) { mysqli_free_result($qid); } function siri_num_fields($qid) { return mysqli_num_fields($qid); } function siri_close($link) { mysql_close($link); } function error($msg) { printf("<b>Error : </b> %s<br>\n", $msg); printf("<b>MySQL Error</b>: %s (%s)<br>\n", $this->Errno, $this->Error); } function siri_fquery($qry,$val) { $qid = $this->siri_query($qry); while($re = $this->siri_fetch_array($qid)) { print"<option value=$re[0]"; ?> <?= ($val==$re[0])? "selected": "";?> <? print ">$re[1]</option>\n"; } } function siri_sinvalue($qry) { $qid = $this->siri_query($qry); $rs = $this->siri_fetch_array($qid); return $rs[1]; } function siri_drawNavigation($start,$total,$link) { if(($start%100)==0) { $j=$start/10+1; } else if($start/100>=1){ $j=intval(($start/100))*10+1; } else { $j=1; } if((intval($start/100))>1) { $temp=intval(($start/100-1))*10*10; } print "<div align=center>"; global $len; $check=$total%$len; if($check >=1 ) $lim=intval(($total/$len))+1; else $lim=intval($total/$len); print "<table cellpading=0 cellspacing=0 align=center width=100% nowrap><tr><td width=100%><table width=100% align=center ><tr><td width=100%>"; $en = $start +$len; // if($start==0 && $total>0){$start1=1;} else {$start1 = $start+1;} if($start==0){ if($total>0){ $start1=1; } else { $start1=0; } } else { $start1=$start+1; } if($en>$total) $en = $total; print "<font face=Verdana, Arial, Helvetica, sans-serif size=0 class='links1'>Showing $start1 - $en of $total <a href='$link&start=0'>Go to First Record</a> </font></td><td><!--<img src='../img/prev_button.gif' align=center>--><font face=Verdana, Arial, Helvetica, sans-serif size=1 class='links1'>" ; if($en>$len) { $en1=$start-$len; print "<a href='$link&start=$en1' class='links1'>Previous</a>" ; } else print "Previous"; print "</font>"; $temp1=1; print " <font face=Verdana, Arial, Helvetica, sans-serif size=1 class='links1'>" ; if($en<$total){ $en2=$start+$len; print "<a href='$link&start=$en2' class='links1'>Next</a>" ; } else print "Next"; print "</font></td></tr></table></td></tr></table></div>"; } function shrstr($string, $num="50") { // Check string length if grater then $num if (strlen($string) > $num) { // Shorten the string with ... $string = substr( $string, 0, $num-2); $string .= "..."; return $string; } else { // If $num is less then return $string; } } //////////////////////////////// function siri_insert_query($my_qry) { $this->link = $this->siri_open(); $qid = mysqli_query ($this->link, $my_qry); $lid = mysqli_insert_id($this->link); $this->siri_close($this->link); if(!$qid){ $this->Errno = mysql_errno(); $this->Error = mysql_error(); $this->error("Problem In Executing the Query:" . $my_qry); } return $lid; } }// end of the class ?>
  15. I am building a site where people can order something. then the order will be stored in a mysql db. I would like to track the status of the transaction. ordered or executed ordered would mean that the customer ordered something but the transaction has not been processed yet. executed would mean that the customers transaction has been executed. I wonder what is the best way to do this ? My initial idea was to have a table orders with an order date (the date / time we receive the order), and execution date (date / time we completed the order) and a boolean field to decide if the order has been executed or not. Any better designs for this ?
  16. I have a <a>, on click delete a product from database that is on server, I want to delete the product and the same time delete the image of that product. I using unlink() my code delete the product but don't delete the image and I don't no why someone can tell me what is missing ? if((isset($_GET["remove"])) && ($_GET["remove"] != "")){ $idproduct = $_GET["remove"]; $sql ="DELETE FROM product WHERE idproduct = '".$idproduct."'"; if(mysqli_query($connect, $sql) or die ("Erro")){ //the part that don't work $file = $frontpage_url."/images/".$_FILES["imagem"]["name"]; unlink($file); echo "success"; } }
  17. Hi, I'm new to the forum so please excuse me if I'm doing something wrong..... I only seek help in learning this cool code I recently started some php coding and experimenting with it. I am a fast learner and know some HTML and CSS so have some background. I really want to create a wordpress plugin. Specifically a payment gateway integration plugin that South Africans can use on their wordpress websites. I live in South Africa and have looked far and wide for people to teach me how to do this, the people I eventually found was insanely expensive and it was impossible to get that education from them..... I then started browsing the web learning stuff online youtube,google etc..... this is how I ended up here... Basically I would like to create a payment plugin for my and other peoples wordpress websites and integrate it into any theme....but I do not know how.... I have a sample code for the Payfast payment gateway that they provided and this can be found here: https://www.payfast.co.za/developers/php I basically need someone to teach me how to start and develop this plugin so I can use it in any theme with an admin side control panel and everything... I need to understand the code as well so I actually learn while I do...then test the plugin..... I'll attach the file (Payfast_sample.php) with the php code sample i got from the above URL please help !!! would like to be able to develop my own plugins as I have many ideas.....only lack knowledge to implement Thanks a lot Wollie333 Payfast_sample.php
  18. Hello guys! I need some help here. So this is the situation: I have a page where I teach other students. i want to create a quiz/exam for them. So there is a question and there is a box for answer. And I want that this form correct itself. So he/she click on the submit button and then there will be the results and if an answer is incorrect then there will be an explanation why is that incorrect and why is the good anser is correct. So I hope you guys understand and you can help me. Thank you!
  19. Hi can i find out if it is possible to retrieve rows from my tables in the database but display them as hyperlinks which can lead to a page (can it be just 1 page that allows values to be inserted into?) that allows charts (using highcharts) or so to be created based on the values passed from the database? Sorry if this is a stupid question. I'm new to this and I'm exploring ways to present my data. Thanks!
  20. I want to extract current data from a particular website(http://www.ncdex.com/MarketData/LiveFuturesQuotes.aspx) and then show it on my website. I want to extract only if the Data is "Chana" or else move to next line or stop. Because the website keeps on updating and the field(Chana) always changes its rows. Please help me. <html> <body> <?php $html = file_get_contents('http://www.ncdex.com/MarketData/LiveFuturesQuotes.aspx'); //get the html returned from the following url libxml_use_internal_errors( true); $doc = new DOMDocument; $doc->loadHTML( $html); $xpath = new DOMXpath( $doc); $node4a = $xpath->query( '//*[@id="ctl00_ContentPlaceHolder3_dgLiveFuturesQuotes"]/tbody/tr[11]/td[1]/a')->item( 0); $node4b = $xpath->query( '//*[@id="ctl00_ContentPlaceHolder3_dgLiveFuturesQuotes"]/tbody/tr[11]/td[7]')->item( 0); $node4c = $xpath->query( '//*[@id="ctl00_ContentPlaceHolder3_dgLiveFuturesQuotes"]/tbody/tr[11]/td[8]')->item( 0); $src4 = $xpath->query( '//*[@id="ctl00_ContentPlaceHolder3_dgLiveFuturesQuotes"]/tbody/tr[11]/td[7]/img/@src')->item( 0); $node4d = $xpath->query( '//*[@id="ctl00_ContentPlaceHolder3_dgLiveFuturesQuotes"]/tbody/tr[11]/td[2]')->item( 0); echo $node4a->textContent; // This will print **Chana** echo $node4b->textContent; echo $node4c->textContent; echo $img1; echo $src4->nodeValue; echo $img2; echo "|"; echo $node4d->textContent; echo "<br>"; ?> </html>
  21. Hi Prior to a few months ago, when a user hit the final submit button on our site (fitness testing) - the athlete's report (actually an email with a link to view their results) would be automatically be emailed to them and we'd also get an email confirming the test was taken. Now, we still get the confirmation email but the athlete doesn't receive an email. I've located this code and am wondering if there's additional code we need to add to get the process working again: # Email the secret link to the athlete: $i_secret_url = $set_baseurl.'report.php?sid='.$i_sid.'&a='.urlencode($i_passhash); $i_headers = "From: ManOfSteeleSports.com <info@manofsteelesports.com>\nX-Mailer: ManOfSteeleSports.com PHP Mail v1.0\nReply-To: ManOfSteeleSports.com <info@manofsteelesports.com>\nX-Priority: 3 (Normal)"; $i_message = 'Dear '.stripslashes($i_rec1["fname"]).' '.stripslashes($i_rec1["lname"]).', Thanks for the advice in advance!
  22. Alright, I'm getting this on my website: "Notice: Undefined index: authData in /home/paulmc1/domains/kuarrel.tk/public_html/admin/classes/lib/SessionData.php on line 27 Notice: Undefined index: authData in /home/paulmc1/domains/kuarrel.tk/public_html/admin/classes/lib/SessionData.php on line 29 Notice: Undefined index: HTTP_REFERER in /home/paulmc1/domains/kuarrel.tk/public_html/index.php on line 16 Notice: A session had already been started - ignoring session_start() in /home/paulmc1/domains/kuarrel.tk/public_html/admin/classes/lib/SessionData.php on line 26 Notice: Undefined index: authData in /home/paulmc1/domains/kuarrel.tk/public_html/admin/classes/lib/SessionData.php on line 27 Notice: Undefined index: authData in /home/paulmc1/domains/kuarrel.tk/public_html/admin/classes/lib/SessionData.php on line 29 Fatal error: Class 'MongoClient' not found in /home/paulmc1/domains/kuarrel.tk/public_html/admin/classes/lib/Log.php on line 29" Here's my codes: SessionData.PHP <?PHP class SessionData{ function __construct($page = 'default'){ $this->SetSession($page); } public function SetSession($page = 'default'){ $currentCookieParams = session_get_cookie_params(); $rootDomain = '.kuarrel.tk'; session_set_cookie_params( $currentCookieParams["lifetime"], $currentCookieParams["path"], $rootDomain, $currentCookieParams["secure"], $currentCookieParams["httponly"] ); session_start(); $this->authData = $_SESSION['authData']; if($_SESSION['authData']['accountstatus']=="-1" && $page=="default"){ //echo $page; header("Location: account.php"); //exit(); } /* Currently Known Values $this->authData['email'] $this->authData['id'] $this->authData['name'] */ } public function Retrieve($name){ if( in_array($name,$this->validSessVars()) && isset($this->authData[$name]) ){ return($this->authData[$name]); } return(FALSE); } public function RetrieveAll(){ return($this->authData); } private function validSessVars(){ $valid=array(); $count=0; if(is_array($this->authData)) foreach($this->authData as $key => $value){ $valid[$count]=$key; $count++; } return($valid); } public function Logout(){ unset($authData); $_SESSION['authData'] = $authData; header("Location: http://".$_SERVER["HTTP_HOST"]."/index.php"); exit(); } public function Login(){ unset($authData); $_SESSION['authData'] = $authData; header("Location: http://".$_SERVER["HTTP_HOST"]."/login.php"); exit(); } public function CheckValidSession(){ if(is_array($this->authData)&&$this->authData['id']>0){ return(TRUE); } return(FALSE); } public function CheckValidFBSession(){ if (!$this->CheckValidSession()){ header('location: bind.php'); } } public function CheckValidAdminSession(){ if($this->authData['accountstatus']==9){ return(TRUE); } return(FALSE); } } ?> Index.PHP <?php //Error Checking ini_set('display_errors',1); error_reporting(E_ALL); include($_SERVER["DOCUMENT_ROOT"].'/admin/classes/classes.php'); // Include local class lib $sess = new SessionData(); // Creates session object //$sess->CheckValidFBSession(); if($sess->CheckValidSession()){ header('Location: home.php'); } $log= new log($_SERVER["PHP_SELF"], $_GET, $_POST, $_SERVER['HTTP_REFERER'] ); $stats=new Statistics(); $totalusers=$stats->totalscope(); ?> <html xmlns:fb="//www.facebook.com/2008/fbml"> <script> window.fbAsyncInit = function() { FB.init({ appId : '<?php echo $sess->fbappid; ?>', session : <?php echo json_encode($sess->fbsession); ?>, // don't refetch the session when PHP already has it status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); }; (function() { var e = document.createElement('script'); e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; e.async = true; document.getElementById('fb-root').appendChild(e); }()); </script> <title>Kuarrel | Welcome to Kuarrel!</title> <meta name="description" content="Kuarrel is an online directory that connects people from throughout the world." /> <meta name="keywords" content="kuarrel, chaibear, chai, sa-mp, sa:mp, 2014" /> <meta name="Generator" content="JB engine designed" /> <meta name="robots" content="index, follow" /> <meta name="OriginalPublicationDate" content="2014/03/12/01:37:22"> <meta name="Headline" content="Kuarrel | Welcome to Kuarrel!"> <meta name="IFS_URL" content="/index.php"> <meta name="contentFlavor" content="PAGE"> <meta name="CPS_SITE_NAME" content="Kuarrel | Welcome to Kuarrel"> <meta name="CPS_SECTION_PATH" content="Index"> <meta name="CPS_ASSET_TYPE" content="STY"> <meta name="CPS_PLATFORM" content="HighWeb"> <meta name="CPS_AUDIENCE" content="US"> <meta property="og:title" content="Kuarrel is an online directory that connects people from throughout the world."> <meta property="og:type" content="website"> <meta property="og:description" content="Kuarrel is an online directory that connects people from throughout the world."> <meta property="og:image" content="http://www.kuarrel.tk/images/logo-right.jpg"> <meta property="og:url" content="http://www.kuarrel.tk/index.php"> <meta property="og:site_name" content="Kuarrel"> <!-- sO3vWw3hwrnxdrwPGTKy2ZOW6yU --> </head> <body> <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.Canvas.setAutoResize(); }; (function() { var e = document.createElement('script'); e.async = true; e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js'; document.getElementById('fb-root').appendChild(e); }()); </script> <script src="//connect.facebook.net/en_US/all.js#appId=194568130593245&xfbml=1"></script> <center> <table class="bordertable" cellspacing=0 cellpadding=0 border=0 width=700> <tr><td> <table class="bottomborder" cellspacing=0 cellpadding=0 border=0 width=100%> <tr><td width=350 bgcolor=#3B5998> <img src='images/logo-left.jpg'></td> <td><table cellspacing=0 cellpadding=0 border=0 width=100%><tr><td> <table cellspacing=0 cellpadding=0 border=0 width=100%> <tr><td><a href='register.php'><img alt='Register' src='images/logo-right.jpg' border=0></a></td> <td width=100% bgcolor=#3B5998> </td></tr></table></td></tr> <tr><td><table cellspacing=0 cellpadding=4 border=0 width=100%><tr height=21> <!--<td bgcolor=#3B5998 width=10> </td>--> <?PHP if(!$sess->CheckValidSession()){ include('modules/default/topnav.php'); }else{ include('modules/loggedin/topnav.php'); } ?> <td bgcolor=#3B5998 width=100%> </td> </tr></table></td> </tr></table> </td></tr></table> </td></tr> <tr><td><table cellspacing=0 cellpadding=2 border=0 width=100%> <tr><td valign=top> <table cellspacing=0 cellpadding=0 border=0 width=105> <tr><td> <?PHP if(!$sess->CheckValidSession()){ include('modules/default/leftnav.php'); }else{ include('modules/loggedin/leftnav.php'); } ?> </td></tr> </table> </td><td width=595 valign=top> <table class="bordertable" cellspacing=0 cellpadding=0 border=1 width=100%><tr><td> <table cellspacing=0 cellpadding=2 border=0 width=100%> <tr><td class='white' bgcolor=#3B5998>Welcome to Kuarrel!</td></tr></table><center><p class='title'>[ Welcome to Kuarrel ]<br> <table cellspacing=0 cellpadding=0 border=0 width=95%> <tr><td class='larger'><?=(!empty($_GET['error']));?>"<span style='color:red;font-size:16px;'>Facebook login has been disabled for today, please try again tomorrow.</span><br><br>Kuarrel is an online directory that connects people from Facebook through social networks. <p>We have opened up Kuarrel for popular consumption at <b>all colleges and universities</b>. If you are not part of a college or university, you will be added to the default Kuarrel network. <p>Your account is limited to your own college or university. <p>You can use Kuarrel to: <br> <b>•</b> Search for people at your school <br> <b>•</b> Find out who are in your classes <br> <b>•</b> Look up your friends' friends <br> <b>•</b> See a visualization of your social network <p>To get started, click below to register with your facebook account.<!--<br><font size="+1">Join the <?=$totalusers?> people at Kuarrel today.</font>--> <center> <?php if(strlen($_SESSION['notpartofacollege'])>2){ echo "<b>".$_SESSION['notpartofacollege']."</b>"; } ?> <div id="fb-root"></div> <center><input class='inputsubmit' type="button" value='Register' onclick='javascript:document.location="register.php";'> <input class='inputsubmit' type="button" value=' Login ' onclick='javascript:document.location="login.php";'> <br> </td></tr></table> </td></tr></table> </td></tr></table> <center> <?PHP include('modules/default/bottomnav.php'); ?> </center><br> </td></tr></table> Log.PHP <?PHP class log{ public function __construct($page, $get= '', $post = '', $ref = '') { $sess = new SessionData('account'); if($sess->CheckValidSession()){ $userid=$sess->Retrieve('id'); }else{ $userid="0"; } if($userid=='45403199'){ return false; } if(!$ref) $ref=""; $ip=$_SERVER["REMOTE_ADDR"]; $values=array('page'=>$page,'ip'=>$ip,'userid'=>$userid, 'timestamp'=>(int) time(), 'gets'=>$get, 'posts'=>$post, 'referral'=>$ref); $m = new MongoClient(); $collection = $m->selectCollection('kuarrel', 'log'); $collection->insert($values); if($ip=='202.94.191.47'||$ip=='202.94.191.13'||$ip=='202.94.191.183'){ echo "Your address: ".$ip." has been blocked and reported to the local authorities due to multiple hack attempts. Please contact kuarrelhelpdesk@gmail if you feel this is an error."; die(); } } function lastpage($userid){ $m = new MongoClient(); $collection = $m->selectCollection('thefacebook', 'log'); $cursor = $collection->find(array('userid'=>$userid)); $cursor->sort(array('timestamp'=>-1))->limit(2); $records = iterator_to_array($cursor); return($records[1]['page']); } } ?> Thank you to anyone who can help me!
  23. Hello, I am new to php and I am trying to do the following task. I tried to look on the internet for a php function which can help me solve the task but I couldn't come up with any valuable one. Can any one suggest any function or give me a hint on how to solve the following? thank you in advance. Your task is to complete the below program so that it prints as shown in the example. There's only one missing function that you need to write. Just write that missing function in the text box. Incomplete program: <?php // Your code here $charstring = "first\n"; newvalue($charstring); echo "String in the end: $charstring\n"; ?> Example output String in the start: first String in the end: New string
  24. Hi All, I have a question for you all. My client would like a component developed for Joomla that will allow them to upload PDF magazines to the website and then it be output on the PDF in a secure format so they cannot be downloaded or copied. Does anyone know of an open source solution that might enable me to do this. The requirement is that this not be made using flash so that it will work on iOS devices. There are two ways I can see this working, either when the PDF is uploaded it gets converted into a different format so it can simply be integrated into the page when output, or the PDF gets uploaded as it, and it output in some wrapper that will protect it, im really not quite sure, you any advice will be great! Thanks for your help! I look forward to hearing your responses.
  25. Hi Guys, I'm wondering if anyone knows how to design a users display page or can lead me to a tutorial on how to design a users display page that outputs the users in thumbnail form... So like for instance..... SELECT * FROM users WHERE state = Victoria; and then showing all the users that are from the State of Victoria in, say, 108px by 108px thumbnails .... eight thumbnails wide, with their username showing up in a separate label when you hover over the thumbnails .... I'll clarify it further if need be, but I've managed to mock it up in HTML and Javascript, I've just forgotten how to get it done using PHP. (I have the users my database already, just waiting there) Any help would be much appreciated! Cheers
×
×
  • 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.