PHP - Cant Call Function
okay in modlogs.php i have
a function Code: [Select] <?php function modmenu($page) { ?> <dl><dt class="<?php if ($page == 'modlogs') echo '';else echo 'ust'; ?> LEFT" style='margin-left:5px'><a href='mlogs.php'><b>User Logs</b></a> </dt><dt class="<?php if ($page == 'modlogs1') echo '';else echo 'ust'; ?> LEFT"><a href="modlogs1.php">Topic/Forum Actions</a></dt> <dd> <?php } ?> in modlogs1.php i try to echo Code: [Select] modmenu('modlogs1'); to show the menu but i get unidentified function? lol isn't functions global wtf? Similar TutorialsThis topic has been moved to Other Libraries and Frameworks. http://www.phpfreaks.com/forums/index.php?topic=319682.0 I can call the following function successfully as a single php program // Acknowledge and clear the orders function ack($client, $merchant, $id) { $docs = array('string' => $id); $params = array('merchant' => $merchant, 'documentIdentifierArray' => $docs); $result = $client->call('postDocumentDownloadAck', $params); return $result; } with $result = ack($t, $merchant,'2779540483'); successful output [documentDownloadAckProcessingStatus] => _SUCCESSFUL_ [documentID] => 2779540483 I'm trying to figure out how to call this function as an object from another program. Trying the following gives error ***Call to a member function call() on a non-object*** function postDocumentDownloadAck($t, $merchant, $id) { $this->error = null; $docs = array('string' => $this->id); $params = array('merchant' => $this->merchant, 'documentIdentifierArray' => $docs); ** I've tried the following which does nothing $result = $this->soap->call('postDocumentDownloadAck', $params); ** I've tried the following - which gives error "Call to a member function call() on a non-object" $result = $this->t->soap->call('postDocumentDownloadAck', $params); if($this->soap->fault) { $this->error = $result; return false; } return $result; } *** calling program snippet for above function $merchant= array( "merchant"=> $merchantid, "merchantName" => $merchantname, "email"=> $login, "password"=> $password); $t = new AmazonMerchantAPI($merchantid, $merchantname, $login, $password); $documentlist= $t->GetAllPendingDocumentInfo('_GET_ORDERS_DATA_'); $docid = $documentlist['MerchantDocumentInfo'][$i]['documentID']; $docs = array('string' => $docid); $ackorders = $t->postDocumentDownloadAck($t, $merchant,$docs); Any ideas of what I'm doing wrong are greatly appreciated. Hi all, I want to call a javascript function from a php function like this: public function Buscar() { $HoraInicio = $_POST['edtHoraInicio']; $HoraFin = $_POST['edtHoraFin']; $FechaInicio = $_POST['edtFec1']; $FechaFin = $_POST['edtFec2']; $FechaMax = $FechaFin." ".$HoraFin.":00"; $FechaMin = $FechaInicio." ".$HoraInicio.":00"; $_GET["FechaMax"] = $FechaMax; $_GET["FechaMin"] = $FechaMin; echo $FechaMin; echo "<script language=javascript>alert('Hi.')</script>"; } but the function Buscar never show the alert but shows the $FechaMin I hopu u guys can help me out with this probem Thanks, Siddhartha Hi I have a table class and functions I want to call in another function but can't get it working. Some help will be very welcome. It seesm that the new table class is not working in this function if I pass the values to it, I have tested the class, it does get the post values I post to it so $_POST['id'] are being received as well as all the other $_POST's but the table class and find function is not working, it works fine if I don't put it in a function.. function edit() { if (isset($error)){ $error.="Please fix the error(s) above";} else { if ($_POST['id'] <> "") { $update =& new table($db, 'publisher'); $update->find($_POST['id']); $update->name = $_POST['name']; $update->url = $_POST['url']; $update->contact = $_POST['contact']; $update->address = $_POST['address']; $update->phone = $_POST['phone']; $update->email = $_POST['email']; $update->save(); $error = "The Publisher has been edited"; } } } Hi
I'm trying to get the layout like i want but it's not easy
I have this file
<?PHP require_once("./include/membersite_config.php"); if(!$fgmembersite->CheckLogin()) { $fgmembersite->RedirectToURL("login.php"); exit; } if(isset($_POST['submitted'])) { $fgmembersite->PesquisarPorDatas(); } ?> <div id='fg_membersite_content'> <div class="CSSTableGenerator" > //I want the result here </div> <br>I want the result of this $fgmembersite->PesquisarPorDatas(); in "//I want the result here" the r of my code, when the user use the "Pesquisar" button this fucntion is called but the result comes out of my css any help please?? Edited by alphasil, 04 December 2014 - 10:32 AM. Hi im new to php Im excellent in C# more but lets not go into that I was wondering how to call this function. What am i doing wrong.. <?php if(isset($_POST['submit'])) { $startDate = strtotime($_POST['startdate']); $endDate = strtotime($_POST['enddate']); if($startDate != false && $endDate != false) { $startDate = date("y-m-d",$startDate); $endDate = date('y-m-d',$endDate); SearchForBookedRooms($startDate,$endDate); } else { echo "Please select both dates!"; } function SearchForBookedRooms($startDate,$endDate)//Calling this Function Here?? { } } ?> Is this even possible? I'm trying to call function nameGen from in the function nameGen but I just get an error saying cannot redeclare. I only want it to return $newName when it is not in the array $takenVals. can this only be done with another loop and a constant somewhere? Code: [Select] $newVarVals = array(); $takenVals = array(); $varCount = count($varArray); // contents are set else where and is fine for($i = 0 ; $i < $varCount; ++ $i) { function nameGen(&$varCount,&$takenVals){ $newName = rand(0,$varCount); if(in_array($newName,$takenVals)) { nameGen(&$varCount,&$takenVals); } else{ return $newName; } } $newName = nameGen(&$varCount,&$takenVals); $takenVals[] = $newName; $newNameToKeep = '$_'.$newName; $newVarVals[] = array('oldName' => $varArray[$i], 'newName' => $newNameToKeep); } error: Cannot redeclare nameGen() I'm writing a program that allows users to input a stock and view a historical price chart. Code is straight out of libchart charting library. Problem is, user is supposed to enter the stock symbol from a form handler (index.php) which then passes the symbol as a variable to the charting function, which doesn't get called at all:
<? php
function index() { chart($_POST['userinput']};
} ?> .
<?php
function chart($stock)
{
$prices=getdata($stock); //returns array of prices from yahoo finance
$data=analyzer($prices); //produces metrics to be charted
graph($data); } ?> //plots the metrics, outputs .html
chart.php works on its own, as I've verified by hardcoding $argv='ibm'; in its code body. But index.php can't seem to call chart.php, as I've verified by including an echo/var_dump line in chart.php (doesn't get executed at all). It doesn't have anything to do with form handling either, as chart('ibm'); doesn't call chart.php either. I don't understand how a 6-line piece of code can be so problematic. All files are in the same folder, btw.
Thanks.
I am getting this error: Parse error: syntax error, unexpected '[', expecting ')' in C:\xampp\htdocs\Work\Store\store.php on line 154 when I run the following code: Code: [Select] function categorySearch($sql) { $res = mysqli_query($this->conn,$sql); $this->results='<table>'; while($cRow = mysqli_fetch_array($res)) { function getCategoryName($cRow[0]) $this->results .= '<tr><td style="border: thin solid #000000;">' . $this->cat_str . '</td></tr>'; } $this->results.='</table>'; return $this->results; } Line 154 refers to this line: function getCategoryName($cRow[0]) Can anyone see what the problem is? I've made this code for a very simple registration form practice:
//assign form variables $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $username = $_POST['username']; function clean_names($dirty_name) { strip_tags($dirty_name); str_replace(' ', '', $dirty_name); ucfirst(strtolower($dirty_name)); //return $dirty_name; } $names = array($firstname, $lastname, $username); if(isset($_POST['register_button'])) { // WHY IS THIS FUNC CALL NOT WORKING?? foreach($names as $name) { clean_names($name); } echo "First Name: " . $firstname . "<br>"; echo "Last Name: " . $lastname . "<br>"; echo "Username: " . $username . "<br>"; }
The values are returned but they haven't been put through the clean_names function. This is the error that I am getting... Quote <br /> <b>Fatal error</b>: Call to undefined function readChatOnload() in <b>C:\server\xampp\htdocs\php\chat\readChat.php</b> on line <b>18</b><br /> And this is my php file... if(isset($_POST['function'])) { $function = $_POST['function']; switch($function) { case 'readNamesOnload': readNamesOnload(); break; case 'readNamesLoop': readNamesLoop(); break; case 'readChatOnload': readChatOnload(); break; case 'readChatLoop': readChatLoop(); break; } //READ NAMES ONLOAD function readNamesOnload() { die('readNamesOnload'); } //READ NAMES LOOP function readNamesLoop() { die('readNamesLoop'); } //READ CHAT ONLOAD function readChatOnload() { die('readChatOnload'); } //READ CHAT LOOP function readChatLoop() { die('readChatLoop'); } } I don't understand why this is happening. Thanks I'd like to set my own error handler function to clear some session variables, but I do not want to completely replace php's internal error handler message reporting. Is there any way to mimic the internal error message reporting so I can define my own error handler function. function myErrorHandler(){ unset($_SESSION['var']); // HERE EXECUTE Normal PHP error message reporting } Thanks Code: [Select] <html> <center> <form method="post" action=""> <b>Email</b><br><input type="text" name="email"/><br> <b>Password</b><br><input type="password" name="password"/><br> <input type="submit" name="submit" value="Login"/><br> </form> <?php if(isset($_POST['submit'])){ echo echo_post($_POST['email']); function echo_post($postvar){ return $postvar; } } ?> </center> </html> the filename is index.php How come I get the undefined function echo_post on line 14? I know it is probably something simple but I am kind of new to this, if you could help me out that would be great Hi all. I try to adding checkbox when I call my function, my Class code is Code: [Select] class SQLconn{ function fetchData($table_name, $argument, $linebreak, $end_linebreak){ $result = mysql_query("select * from $table_name where status='$argument'"); while($row=mysql_fetch_row($result)){ echo $linebreak.$row[1]."<input type='checkbox' name='option' id='checkbox' value=$row[0] />".$end_linebreak; //$row[0] is 'job_id' from database } } } and my view code is like this Code: [Select] <?php $connect = new SQLconn(config()); $connect->connectDB(); $connect->fetchData("todo", "Undone", "<li>", "</li>"); //this is where the problem is $connect->closeConn(); ?> With that code I succesfully achieve my goal to add checkbox with right 'job_id' value but this is a workaround and not good because if I code it this way my function will be broken if use it somewhere else. My question is, how can I fix my code so I can add checkbox to view page but I can keep my function clean? Really need opinion about this?? I am getting this error while building OOP portal.
Fatal error: Call to a member function count() on a non-object in C:\Users\Rishi\Documents\xampp\htdocs\PDO\Pitch_It\index.php on line 6
My index.php file:
<?php Firstly i am new to php.Iv currently got this while loop iterating through a database drawing polygons from the info in the datatable.each polygon has its own id stored in the datatable and with the on click event i am trying to just output to the screen the specific id of the polygon clicked on.It looks ok to me but it doesnt work for some reason. Below is the loop and the function it is trying to call. /////////////////////////////////////////////////////////////////////// <?php while($info = mysql_fetch_array( $data )){ echo "<polygon fill=".$info['fill_colour']." stroke=\"black\" id=".$info['id']." onclick=\"buildingClick(id)\" points=".$info['coordinates']." />"; } ?> ///////////THIS IS THE FUNCTION/////////////////////////// <?php function buildingClick($id) { echo "building id : {$id}"; } ?> /////////////////////////////////////////////////////////////////// If anyone could help it would be hugely appreciated. Eoin Hi I'm setting up my own framework for a project. I was coming to the point of completion and thought up of a new idea. Is it possible to call a function like this from a class: class myClass { function func($param) { echo "Hello world". $param; } } $class = 'myClass'; $func = "func(' It\'s time to partey!')"; $$class = new $class; $$class->$func; Thanks for any help! What's undefined about deposit()? Code: [Select] class BankAccount { private $name; var $balance = 0; private $dep = 0; function __construct() { if (array_key_exists ("deposit" , $_POST)) { $dep = $_POST['deposit']; echo $dep; deposit($dep); } } function deposit($dep) { $balance += $dep; echo $balance; } } |