PHP - Oop Extend Problem.
I am new to OOP php programming and I am trying to figure out what I did wrong on this. I am trying to call my protection() function in my users class, so I extended my question class and call the protection function but it isn't working.
Here is my code for my class_lib: Code: [Select] <?php require('dbc.php'); class users { public $email; public $password; public $first_name; public $last_name; public $id; function __construct($e,$p) { $this->email = $e; $this->password = $p; } function protection() { if(!$_COOKIE['user']) { header("location:../login.php"); } } } //new class class questions extends users { public $title; public $question; public $response; public $sub_category; public $date; public $pid; function __construct(){} function newest() { $sql = "SELECT * FROM math ORDER by pid DESC LIMIT 0,5"; $execute = mysql_query($sql) or die(mysql_error()); while($data = mysql_fetch_array($execute) ) { $this->title = $data['title']; $this->question = $data['question']; $this->pid = $data['pid']; echo '<p class="title">' . $this->title . '<br /></p>'; echo ' <br /><br /><br /><br /><a href="questions.php?id=' . $this->pid . '" class="button">Awnser it</a><br /><br /><br />'; } } } ?> Here is the page to call the function: Code: [Select] <?php require('../class_lib.php'); $question = new questions(); $question -> protection(); ?> Similar Tutorialshey guys i have a script ive made which loads classes automatically when called...the script works fine but when i extend the class Autoloader_Exception and it comes back with the error Code: [Select] Fatal error: Class 'Autoloader_Exception' not found in C:\www\library\autoloader.class.php on line 3 i might be missing something here but i dont know why the autoloader doesnt load the extended class if someone can please help me how i can extend the class please thanks Code: [Select] <?php class Autoloader extends Autoloader_Exception { protected static $_declared_classes = array(); public static function load_class($class_name) { $class_name = ucwords($class_name); $file = self::get_class_path($class_name); try { if (!class_exists($class_name, FALSE)) { if (file_exists($file)) { require_once $file; self::$_declared_classes[] = $class_name; } else { throw new Exception(sprintf("Class '%s' not found.<br />\n", $class_name)); } } } catch (Exception $e) { echo $e->getMessage(); } } protected static function get_class_path($class_name) { global $classes; if (array_key_exists($class_name, $classes)) { return ROOT . DS . $classes[$class_name]; } } public static function declared_classes() { echo "<pre>"; print_r(self::$_declared_classes); echo "</pre>"; } } spl_autoload_register(array('Autoloader', 'load_class')); ?> Hi all, I'm trying to increase the server default php session timeout from 1hour to 3hours. I don't have access to my php.ini but can use .htaccess. Is the following the correct way to do this? in the .htaccess add the line: php_value session.gc_maxlifetime 10800 Or would I be better off including the following after every session start() on everypage: Code: [Select] ini_set("session.gc_maxlifetime","10800"); thanks! Hi, I'm having an image upload function I did create for few weeks ago - it has an variable called $newname, which contains the path and file. I'm then using the imageupload() function in another function called EditFrontPage(), which is used to 'update' some content. If I update the image, it runs the imageupload function, which is great, it resize and optimize the image, and it moves it to the folder I specified. What I then want, is within' my EditFrontPage() function, is to echo out the $newname variable from the imageUpload function. is there a way to do this? in a smart way? If my code is needed, you can take a look at it he http://codepad.org/poKNSU5H Thank you a lot guys! Guys thanks for helping me solve the problem i had but now i have another problem and i am lost. i have included the code below for you to have overview.
This is the code:
<table style="width:100%; margin-left:auto; margin-right:auto"> Hi, I am trying to write in an existing excel file. But for some reason, I can't open the workbook (but I know I have made similar code work before). Here I am just pasting the code upto the error line $filename="C:\\apache\\htdocs\\GAC2\\dload\\template.xls"; $excel = new COM("excel.application") or die("Unable to instanciate excel"); $excel->Visible = 1; $excel->DisplayAlerts = 1; try{ $wkb = $excel->Workbooks->Open($filename); }catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } //........ Later part of the code This returns the following error Code: [Select] Caught exception: Source: Microsoft Office Excel Description: Unable to get the Open property of the Workbooks class For record, the I have already validated the file location. And I have tried the following line instead without any positive result. Code: [Select] $filename="C:\apache\htdocs\GAC2\dload\template.xls"; Looking for any help please. -Abd im making a website it works fine on firefox but on ie doesnt work correctly. page looks weird i see the error is <? include("index/index_files/front/php/include.php"); ?> anyone can help me its in a <html> tab. I am trying to save this an an xml document but am getting this error when I try to open the xml file "feed.xml" - "XML Parsing Error: no element found" $xml = '<rss version="2.0"> <channel> <title> RSS Feed</title> <link></link> <description>the best industry-lead opinions</description> <language>en-us</language> </channel> </rss>"; $xml2 = new DOMDocument('1.0'); $xml2->Load($xml); $xml2->save("feed.xml"); hello! I have a problem with utf-8 ...
In horizontalmenu.php I have:
print '<a href="/calcioitalia/coaches/'.$name.'.html').'">'.$name.'</a>';where $name=José Márioand in .htaccess I have AddDefaultCharset UTF-8 AddCharset UTF-8 .htmland doesn't work... How could I solve this problem? Thank u! i have the following sql running on local but i get an error. the sql: $sql = "SELECT * FROM '".TBL_PARENTS."'" or die(mysql_error()); the config file: define('DB_PREFIX', 'forum_'); define('TBL_PARENTS', DB_PREFIX.'parents'); the 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 ''forum_parents'' at line 1 the echoed sql: SELECT * FROM 'forum_parents' as you can see when it is echoed it looks fine. Any ideas? The server im using is wamp server. Code: [Select] <?php require('config.php'); $sql = "SELECT m.Title as title , f.Reg_URL as reg FROM website_main as m JOIN website_front as f LIMIT 0,01 "; $result = @mysql_query($sql) or die(mysql_error()); echo "<table border='3'>"; echo "<font size='9'><tr> <th><FONT COLOR=red><center>Title</center></font></th> <th><FONT COLOR=red>reg</th> </tr></font>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table $reg = $row['reg']; echo "<tr><td bgcolor=''><center>"; echo $row['title']; echo "</td><td bgcolor=''><center>"; echo '.$reg.'; echo "</td></tr>"; } ?> I got a problem i try to use an attribute for $reg but only appears as .$reg. on website anyone know why? Parts i have problems with are $reg = $row['reg']; and echo '.$reg.';. thank you I Have An error on line 42 not sure what it is can any one tell? $foundnum = mysql_num_rows($run); Hey guys i just installed a new Theme on my IPB 3.3.4 its called Dashboard now, the start page looks fine but if i try to click on "My Profile" an error pops up.
Error message:
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\xampp\htdocs\board\cache\skin_cache\cacheid_4\skin_profile.php on line 1035
skin_profile.php on line 1035:
<span class='ipsType_smaller desc lighter blend_links'><a href='" . $this->registry->getClass('output')->formatUrl( $this->registry->getClass('output')->buildUrl( "app=members&module=profile&section=status&type=single&status_id={$status['status_id']}", "public",'' ), "array($status['member_id'], $status['members_seo_name'])", "members_status_single" ) . "'>{$this->lang->words['ps_updated']} " . $this->registry->getClass('class_localization')->getDate($status['status_date'],"manual{%d %b}", 0) . " · " . intval($status['status_replies']) . " {$this->lang->words['ps_comments']}</a></span>
i'm getting this erro "Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 3 in /***/***/*****.php on line 278 not an active session, starts new" this is the code: if ($phase = mysql_result(mysql_query("SELECT `phase` FROM `as_support` WHERE `mission` = '$var2'"),0,0)) { if ($phase=='5') { // mysql_query("DELETE FROM `as_support` WHERE `mission` = '$var2'"); // header("Location: https://www.**********/*******/*******.php"); } else { echo date('h:i:s') . ": PHASE is $phase<br />"; echo "\$var1=$var1,\$var2=$var2<br />"; } } else { echo "not an active session, starts new<br />"; echo "\$var1=$var1,\$var2=$var2<br />"; mysql_query("INSERT INTO `as_support` (`mission`, `phase`) VALUES ('$var2', '0')") OR DIE(mysql_error()); the first line is line no. 278 can someone please tell me what to do? tnx shirley Hi I make 3 querys first Order by DESC, second RAND() and third ASC. Now I want that in the second query can't be the same ids (produgg_users.id) that already taken in the first. And in the third not the ids from first and second. Like I have it now the same users can show up in the RAND() and the ASC like in DESC. Here my Script so far: $rs = mysql_query("select produgg_users.id, twitterUser, credits from produgg_users where twitterUser != '' and produgg_users.id IN (select concat_ws(',', id) from produgg_users where credits > 0 and id != ".$usersClass->userID().") and produgg_users.id NOT IN (select concat_ws(',', followedID) from produgg_activity where followerID = '".$usersClass->userID()."') and produgg_users.id NOT IN (select concat_ws(',', userid) from produgg_featured) ORDER BY credits DESC LIMIT 10") or die(mysql_error()); $nr = @mysql_num_rows($rs); if($nr != 0) { print "<p>Simply click <strong>get 1 point</strong> and you will automatically FOLLOW the USER and earn the credit!</p>"; print "<p><font color=\"#0066FF\">Top Members</font></p>"; while($row=@mysql_fetch_object($rs)) { $divLeft = '<div id="thediv_'.$row->id.'"><div style="float:left;width:400px;">'; $divRight = '<div style="float:left;width:150px;">'; $clearDiv = '<div style="clear:both;"></div>'; print "$divLeft<img src=\"http://api.twitter.com/1/users/profile_image/".strip_tags($row->twitterUser)."?size=mini\" alt=\"\" /> ".strip_tags($row->twitterUser)." <font color=\"#999999\" size=\"1\">$row->credits Points</font></div>$divRight <a href='javascript:void(0);' id='vote_$row->id' class='getPoint'>Get 1 Point</a></div>$clearDiv<hr /></div>"; $z = 1; } } //Lucky Riders $rs = mysql_query("select produgg_users.id, twitterUser, credits from produgg_users where twitterUser != '' and produgg_users.id IN (select concat_ws(',', id) from produgg_users where credits > 0 and id != ".$usersClass->userID().") and produgg_users.id NOT IN (select concat_ws(',', followedID) from produgg_activity where followerID = '".$usersClass->userID()."') and produgg_users.id NOT IN (select concat_ws(',', userid) from produgg_featured) ORDER BY RAND() LIMIT 5") or die(mysql_error()); $nr = @mysql_num_rows($rs); if($nr != 0) { print "<p><font color=\"#0066FF\">Lucky Riders</font></p>"; while($row=@mysql_fetch_object($rs)) { $divLeft = '<div id="thediv_'.$row->id.'"><div style="float:left;width:400px;">'; $divRight = '<div style="float:left;width:150px;">'; $clearDiv = '<div style="clear:both;"></div>'; print "$divLeft<img src=\"http://api.twitter.com/1/users/profile_image/".strip_tags($row->twitterUser)."?size=mini\" alt=\"\" /> ".strip_tags($row->twitterUser)." <font color=\"#999999\" size=\"1\">$row->credits Points</font></div>$divRight <a href='javascript:void(0);' id='vote_$row->id' class='getPoint'>Get 1 Point</a></div>$clearDiv<hr /></div>"; $z = 1; } } //Lucky Riders $rs = mysql_query("select produgg_users.id, twitterUser, credits from produgg_users where twitterUser != '' and produgg_users.id IN (select concat_ws(',', id) from produgg_users where credits > 0 and id != ".$usersClass->userID().") and produgg_users.id NOT IN (select concat_ws(',', followedID) from produgg_activity where followerID = '".$usersClass->userID()."') and produgg_users.id NOT IN (select concat_ws(',', userid) from produgg_featured) ORDER BY credits ASC LIMIT 5") or die(mysql_error()); $nr = @mysql_num_rows($rs); if($nr != 0) { print "<p><font color=\"#0066FF\">Last Rides</font></p>"; while($row=@mysql_fetch_object($rs)) { $divLeft = '<div id="thediv_'.$row->id.'"><div style="float:left;width:400px;">'; $divRight = '<div style="float:left;width:150px;">'; $clearDiv = '<div style="clear:both;"></div>'; print "$divLeft<img src=\"http://api.twitter.com/1/users/profile_image/".strip_tags($row->twitterUser)."?size=mini\" alt=\"\" /> ".strip_tags($row->twitterUser)." <font color=\"#999999\" size=\"1\">$row->credits Points</font></div>$divRight <a href='javascript:void(0);' id='vote_$row->id' class='getPoint'>Get 1 Point</a></div>$clearDiv<hr /></div>"; $z = 1; } } Hi there, I have a map of America made in flash, where you click on a state and the page should display the SQL database information for that state in the HTML table - but instead all it shows is the first entry of the database regardless of which state you click and it doesn't display the 2 radio buttons. My code is as follows Flash Actionscript 3 (just showing one state) Code: [Select] function waClick(event:MouseEvent):void { var waURL:URLRequest = new URLRequest("restaurants.php?state=Washington"); navigateToURL(waURL, "_self"); } wa_btn.addEventListener(MouseEvent.CLICK, waClick); PHP code Code: [Select] <?php include("mvfconnect.php"); $theChoice = $_GET['state']; $query = "SELECT * FROM restaurants WHERE" .$theChoice; $result = @ mysql_query($query); if (!$result) { $message="Unfortunately we are having problems with this page, we promise to have it fixed as soon as possible"; die($message); } $num = mysql_num_fields($result); $i=0; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)){ $show1=substr($row['state'],0,50)."..."; $show2=substr($row['city'],0,50)."..."; $show3=substr($row['rname'],0,50)."..."; $show4=substr($row['address'],0,50)."..."; $show5=substr($row['pnum'],0,50)."..."; $show6=substr($row['web'],0,50)."..."; $show7=substr($row['dishes'],0,50)."..."; $show8=substr($row['dish_details'],0,50)."..."; $show9=substr($row['challenges'],0,50)."..."; $show10=substr($row['challenge_details'],0,50)."..."; $show11=substr($row['youtube'],0,50)."..."; $show12=substr($row['images'],0,50)."..."; echo "<tr>". "<td>".$row['city']."</td>". "<td>".$row['rname']."</td>". "<td>".$row['address']."</td>". "<td>".$row['pnum']."</td>". "<td>".$row['web']."</td>". "<td>".$row['dishes']."</td>". "<td>".$row['challenges']."</td>". "<td id='state".$i."' style='display:none'>".$row['state']."</td>". "<td id='city".$i."' style='display:none'>".$row['city']."</td>". "<td id='rname".$i."' style='display:none'>".$row['rname']."</td>". "<td id='address".$i."' style='display:none'>".$row['address']."</td>". "<td id='pnum".$i."' style='display:none'>".$row['pnum']."</td>". "<td id='web".$i."' style='display:none'>".$row['web']."</td>". "<td id='dishes".$i."' style='display:none'>".$row['dishes']."</td>". "<td id='dish_details".$i."' style='display:none'>".$row['dish_details']."</td>". "<td id='challenges".$i."' style='display:none'>".$row['challenges']."</td>". "<td id='challenge_details".$i."' style='display:none'>".$row['challenge_details']."</td>". "<td id='youtube".$i."' style='display:none'>".$row['youtube']."</td>". "<td id='images".$i."' style='display:none'>".$row['images']."</td>". "<td><input type='radio' name='vid' id='vid".$i."' onclick='openVideo(".$i.")' /></td>". "<td><input type='radio' name='pic' id='pic".$i."' onclick='openImage(".$i.")' /></td>". "<td class='last'style='display:none'>".$show1." ".$show2." ".$show3." ".$show4." ".$show5." ".$show6." ".$show7." ".$show8." ".$show9." ".$show10."</td>". "</tr>"; $i++; } ?> I have used this code before and it has worked fine, can someone please help me out! Hi. I am from poland. I am 17 old age and like webmastering. I write my social network. I have new server 10 GB VPS and my script no runing In my server. in my server do can not login. No runing function Code: [Select] mb_strtolower();as delete function mb_strtolower() ; this login runing. In my server haven`t installing liberary GD and no runing upload avatars. my code upload is: elseif ($_GET['act'] == "upload") { echo <<< KONIEC <hr> <center> <p> <h2>Dodaj zdjęcie</h2> <ul class="gallery clearfix"> <li class="extra"> KONIEC; error_reporting(E_ALL); // we first include the upload class, as we will need it here to deal with the uploaded file include('include/class.upload.php'); // retrieve eventual CLI parameters $cli = (isset($argc) && $argc > 1); if ($cli) { if (isset($argv[1])) $_GET['file'] = $argv[1]; if (isset($argv[2])) $_GET['dir'] = $argv[2]; if (isset($argv[3])) $_GET['pics'] = $argv[3]; } // set variables $dir_dest = (isset($_GET['dir']) ? $_GET['dir'] : 'test'); $dir_pics = (isset($_GET['pics']) ? $_GET['pics'] : $dir_dest); if (!$cli) { } // we have three forms on the test page, so we redirect accordingly if ((isset($_POST['action']) ? $_POST['action'] : (isset($_GET['action']) ? $_GET['action'] : '')) == 'simple') { // ---------- SIMPLE UPLOAD ---------- // we create an instance of the class, giving as argument the PHP object // corresponding to the file field from the form // All the uploads are accessible from the PHP object $_FILES $handle = new Upload($_FILES['my_field']); // then we check if the file has been uploaded properly // in its *temporary* location in the server (often, it is /tmp) if ($handle->uploaded) { // yes, the file is on the server // now, we start the upload 'process'. That is, to copy the uploaded file // from its temporary location to the wanted location // It could be something like $handle->Process('/home/www/my_uploads/'); $handle->Process($dir_dest); function TestProcess(&$handle, $title = 'test', $details='') { global $dir_pics, $dir_dest; $unlink = 'test/'. $handle->file_dst_name; $myid = $_SESSION['id']; $opis = htmlspecialchars(stripslashes(strip_tags(trim($_POST["opis"]))), ENT_QUOTES); $handle->Process($dir_dest); if ($handle->processed) { unlink("$unlink"); $link = ''.$dir_pics.'/' . $handle->file_dst_name .''; $addphoto = mysql_query("INSERT INTO photo VALUES('', '$myid', '$link', '$opis')"); echo <<< KONIEC <br> <center> <img src="$link" > <br> <br /> </center> KONIEC; } else { echo '<fieldset class="classuploadphp">'; echo ' <legend>' . $title . '</legend>'; echo ' Error: ' . $handle->error . ''; if ($details) echo ' <pre class="code php">' . htmlentities($details) . '</pre>'; echo '</fieldset>'; } } if (!file_exists($dir_dest)) mkdir($dir_dest); // ----------- $handle->image_convert = 'jpg'; $handle->image_resize = true; $handle->image_ratio_y = true; $handle->image_x = 500; $handle->image_precrop = 15; $handle->image_watermark = "watermark_large.png"; $handle->image_watermark_x = 20; $handle->image_watermark_y = -20; TestProcess($handle, '15px pre-cropping (before resizing 800 wide), large watermark automatically reduced, position 20 -20', "\$foo->image_convert = 'jpg';\n\$foo->image_resize = true;\n\$foo->image_ratio_y = true;\n\$foo->image_x = 800;\n\$foo->image_precrop = 15;\n\$foo->image_watermark = 'watermark_large.png';\n\$foo->image_watermark_x = 20;\n\$foo->image_watermark_y = -20;"); } else { // one error occured echo '<fieldset>'; echo ' <legend>file not uploaded to the wanted location</legend>'; echo ' Error: ' . $handle->error . ''; echo '</fieldset>'; } // we copy the file a second time // we delete the temporary files $handle-> Clean(); } else { // if we are here, the local file failed for some reasons echo '<fieldset>'; echo ' <legend>local file error</legend>'; echo ' Error: ' . $handle->error . ''; echo '</fieldset>'; } echo <<< KONIEC <li> </ul> </p> </center> KONIEC; is it the only problem that isn`t installing GD as i have something off in php.ini ? Plise Help me I have a simple text file called bio.txt: Code: [Select] wohlersr; Richie Wohlers; Intermediate; Four Aces meyersg; Greg Meyers; Novice; Four Aces I wrote a little script, to return the info for Greg Meyers if the user id is correct, or say "Member not found" if incorrect. For some reason, my output is giving me both. I assume it's a context error, but can't figure it out. Here's my script: Code: [Select] <?php $file=file("bio.txt"); $count=count($file); $i=0; while($i<=$count) { $row = explode(";", $file[$i]); $id = $row[0]; $name = $row[1]; $class = $row[2]; $club = $row[3]; if($id=="meyersg"){ echo $name."</br>"; echo $class."</br>"; echo $club."</br>"; }else{ echo "Member not found."; } $i++; } ?> And here's the output I'm getting: Code: [Select] Member not found. Greg Meyers Novice Four Aces Member not found. Im trying to parse this string and put it in the array.. However i dont know how.. Code: [Select] 11111<>your mobile<>the receiver<>keyword<>2012-01-15<>12:09:08<>wow "this", is great! I want to remove this sign <> and put the elements on the array.. Also i would not want to loose the quotes and commas Can someone help me? thanks |