PHP - Soapclient W/php Namespacing Issues
Hey, I've got a REALLY complicated issue. I'll do my best to explain it.
I have a 3rd party API (soap) that I'm trying to integrate, I'd like to use namespaces to keep their objects/classes separate from ours. In a nut shell what is happening is that I have a soap struct which maps down to a php object (Transaction) inside that object are more objects. as i build out the parameter array to pass to soapCall everything looks good. however the xml that gets generated by soapCall is missing the transaction value, the tag is their <transaction/> but no value. Now, I assumed this is due to namespacing ruining the automated object detection in the soap client. SO i did: $auth->transaction = new \soapVar($bank_trans, XSD_ANYTYPE, "Transaction" , "http://masked/Transactions"); this gets the value into the xml however now i get a really weird error soapFault: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://masked/Transactions:transaction. The InnerException message was 'Error in line 2 position 4965. Element 'http://masked/Transactions:transaction' contains data of the 'http://masked/Transactions:Transaction' data contract. The deserializer has no knowledge of any type that maps to this contract. Add the type corresponding to 'Transaction' to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding it to the list of known types passed to DataContractSerializer.'. Please see InnerException for more details. in /home/jvieira/dev/www/trunk/include/CWS/CWSBankcard.php on line 1001 Call Stack #TimeMemoryFunctionLocation 10.0061930576{main}( )../TransactionManagement.php:0 20.00822682296CWS\CWSClient->authorize( )../TransactionManagement.php:156 30.00832695680CWS\CWSBankcard->Authorize( )../CWSClient.php:418 40.00832696736SoapClient->__soapCall( )../CWSBankcard.php:1001 ) ) any ideas? Thanks, Joe Similar TutorialsAny charitable soul who can help me? I've been having this problem for days and I can't solve it. I would be forever grateful if anyone could help I already checked in phpinfo ()and the class soap client is enabled
the request that I 'm making is on another domain with port 81 (this domain has my ip on the withlisted) and on my domain I use security certificate. Is it around? anyway wsdl is he
$client = new SoapClient('https://dekrainspecoes.pt/acp/PROD_CustomUI_ACP_Member_Validation_WS.WSDL'); if (!empty($result->QueryByNumCartao_Output->Cartao_Ativo)) { echo 'The userId : '.$result->QueryByNumCartao_Output ->Pessoa_ID; } $JSON = json_encode($result); Hey, 'all. I think I'm just tired because I can't see the issue here, but I'm trying to run a SOAP 1.2 call to a legit endpoint using a legit function call and getting nothing but a 'Could not connect to host' message with a fault code of 'HTTP'. Here's some code: class Testing{ private $_user = "username"; private $_pass = "password"; private $_system = 1; private $_uri = "http://legit.com/endpoint/"; private $_location = "givenlocation.asmx"; private $_soapClient; public function __construct(){ $this->_soapClient = new SoapClient(null, [ 'location' => "{$this->_uri}{$this->_location}", 'uri' => $this->_uri, 'soap_version' => SOAP_1_2, 'exceptions' => true, 'trace' => true, ]); } public function makeCall(){ try{ $data = $this->_soapClient->__soapCall('functionCall', [ 'username' => $this->_user, 'password' => $this->_pass, ]); }catch(SoapFault $e){ die("<pre>".var_export($e, true)."</pre>"); } } } $testSoap = new Testing(); $testSoap->makeCall(); I'll happily take a "Let me Google that for you" result link if it's that simple, but I'm just not seeing the problem. Anybody? As always, help is greatly appreciated.
Forgot to mention - I don't get an error on instantiation of the SoapClient() object, just the __soapCall() call. Edited June 18, 2019 by maxxdHi,
Well, I'm having this
The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'GetSomething'. End element 'Body' from namespace 'http://schemas.xmlso.../soap/envelope/' expected. Found element 'param1' from namespace ''.
The soapclient request itself is something with multiple namespaces, like :
<aaa xmlns="namespace1"> <bbb xmlns="namespace2" xmlns:i="http://www.w3.org/20...hema-instance"> <requestparams>xxxxx</requestparams> </bbb> </aaa> So far I think this may got to do with multiple namespaces, so I've been trying to figure out how to deal with this for hours to no avail. Anyone can shed a light into this problem ? Thanks in advance, Hi y'all. I've been looking at this for two days now and my head is starting to hurt from it.
I'm trying to integrate with an existing web service for client log-in and having trouble getting it done and Google is being very little help at this point. Here's the code, annotated where necessary:
namespace myNamespace; MyClass{ private $_apiLoginAddr = 'http://xxx.xxx.xxx.xxx:xxxx/ServiceAddress/Login.asmx?wsdl'; public function logIn($email,$id){ /* // these work... $testClient = new \SoapClient('http://www.webservicex.com/CurrencyConvertor.asmx?wsdl',array('trace'=>1,'exceptions'=>1)); $resp = $testClient->ConversionRate(array('FromCurrency'=>'USD','ToCurrency'=>'CAD')); print($resp->ConversionRateResult); $testClientAWS = new \SoapClient('http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl',array('trace'=>1,'exceptions'=>1)); $resp = $testClientAWS->ItemLookup(array('ItemID'=>'1430260319')); var_dump($resp); $testClientP = new \SoapClient('https://pilot.prove-uru.co.uk/URUws/uru10a.asmx?wsdl',array('trace'=>1,'execptions'=>1)); print_r($testClientP->__getFunctions()); die(); */ // turning off caching because apparently it's sometimes an issue... ini_set('soap.wsdl_cache_enbled','0'); ini_set('soap.wsdl_cache_ttl','0'); // this doesn't work even a little bit... try{ $creds = array( 'trace' => 1, 'exceptions' => 1, 'cache_wsdl' => 'WSDL_CACHE_NONE', 'soap_version' => SOAP_1_1, ); $client = new \SoapClient($this->_apiLoginAddr,$creds); $results = $client->WebsiteLogin(array('_Password'=>$id,'_UserName'=>$email)); var_dump($client->__getLastRequest()); print('break'); var_dump($client->__getLastResponse()); }catch(\SoapFault $e){ print('Exception thrown!'); var_dump($e); die(); } print('Succesfully completed call!'); var_dump($results); die(); } }Using this code, the browser churns for about a minute before I get the error "SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://xxx.xxx.xxx.x...ceAddress/Login.asmx' : failed to load external entity "http://xxx.xxx.xxx.x...ess/Login.asmx", with or without the call to WebsiteLogin(). Now, I've also tried a non-wsdl version where I replaced the credentials array and SoapClient instantiation with the following: try{ $creds = array( 'trace' => 1, 'exceptions' => 1, 'cache_wsdl' => 'WSDL_CACHE_NONE', 'location' => $this->_apiLoginAddr, 'uri' => 'http://tempuri.org', 'soap_version' => SOAP_1_1, ); $client = new \SoapClient(null,$creds); $results = $client->WebsiteLogin(array('_Password'=>$id,'_UserName'=>$email)); /* see previous code block */Using this approach, my browser again churns for about a minute before I get the error "Could not connect to host". If I don't actually try to log in using the service's WebsiteLogin() function, SoapClient doesn't throw an error on this one and reports a successfully completed call. Which does me no good at all, because my users can't log in if I don't call the WebsiteLogin() function. I can visit the end-point directly in my browser and it's definitely there and active, and SoapUI has no problem at all with the request or the response. I've tried uncommenting the open_ssl.dll in my php.ini, turning the wsdl caching options off in the php.ini directly, and pretty much everything short of ritual sacrifice to no avail. My log in form is sending the credentials via AJAX to the logIn() method above, and all this is happening in a WordPress site. However, as the webservicex, webservices.amazon.com, and pilot.prove-uru.co.uk soap calls all complete successfully, I don't think that's an issue. I've spoken with the maintainer of the service gateway and he swears we're not blacklisted through the firewall, but nothing is working. Anybody come across anything similar? Or have better Google skills that can actually find an applicable answer? Or have any ideas at all? 'Cause I'm at a loss... Hello, I'm having troubles parsing text properly. Whenever I submit data into a mysql db, and then call that specific data, in the text, I get this symbol, �. Does anybody know what it is or how to remove it? I believe it's with utf-8 and me using a function that corrupts the string but I'm not sure. Anybody have any clues? Thanks in advance. Issue # 1 How can i send the values come from $_POST['name'],$_POST['number'] to an email address xyz@radiations3.com??? Issue # 2 I am trying to display data from four different tables with the following sql query: (The problem is that the data is getting displayed fine but i don't know why some of the (same )data gets repeated two or three times where as i checked in all four tables and all the data exists one time not twice) If anything wrong with my query kindly help SELECT distinct * FROM applicant,applicant_info_nic,room,student WHERE applicant_info_nic.status='Available' and applicant.appNIC=applicant_info_nic.appNIC and applicant.roomID=room.roomID and applicant.appNIC=student.appNIC ORDER BY applicant.roomID Hey all, I can not get utf-8 working properly. I'm having issues with special characters, such as bullets, e with an accent over it, etc. The data is being stored in my mssql database properly, and I can see everything there fine. It's when I grab it from the database and display it on my php page. The page it set up to utf-8, if I go to Tools>Page Info, it says encoding is utf-8. I have it in my headers, I just can not figure out why it will not display on the page. Any thoughts? i am trying to sort out a session now, i normally use the folllowing code to check if someone is logged in and if they are not to forward them to the login page, but i am getting this message: Notice: Undefined index: username in code: Code: [Select] if ($_SESSION['username']) { }else{ include 'login.php'; die(""); } can someone help please. Hello, I have the following code Code: [Select] class Uploads extends Controller { public function __construct() { parent::__construct(); if (empty($_FILES)) { log_message('error', 'Uploads - files empty'); exit('No files uploaded'); } ini_set('memory_limit', '128M'); $this->load->helper('file'); $this->load->helper('helpers'); $this->load->model('uploads_model'); } public function font_handler() { $this->uploads_model->font_handler(); } } class Uploads_model extends Model { public function font_handler() { $config = array( 'max_size' => '8388', 'allowed_types' => 'ttf', 'upload_path' => 'assets/fonts/' ); $this->load->library('upload', $config); if ($this->upload->do_upload('Filedata')) { $file = $this->upload->data(); $jsFile = $file['raw_name'].'.js'; $query = $this->db->where('location', 'menuFont')->get('fonts')->row(); if ($query->customFile != '' && file_exists('assets/fonts/'.$query->customFile)) { unlink('assets/fonts/'.$query->customFile); } $path = getcwd() . '/assets/fonts/cufon/convert.php'; $command = 'php ' . $path . ' -u "U+??" ' . $file['full_path'] . ' 1> ' . getcwd() . '/assets/fonts/' . $jsFile; system($command); } } } Ok so, the ttf file is uploaded correctly and I can run $command from the command promt in putty and it works perfect, but when I try to run the same command from system() the js file just contains (from the controller) "No files uploaded" I have no idea why this is happening? Anyone have any ideas? Also one thing i'm not sure about is if it should be 1> or > when creating the js file?!? Thanks guys! Hi, I am having some major issues. My site provides sheet music available for downloading for free. When a user clicks on a sheet to download, a new window opens up. This user views our sponsor's website for 30 seconds. Once the time is up, they can download the free sheet. Now for the issues: I found a download script that I'm putting to the test. When clicking download, it asks where you want to save the file and downloads the file just fine. After some testing, i found that if the user tries to download the sheet again, my entire php/html code displays on the page, as well as a bunch of nonreadable characters (I'm guessing this is from the .pdf file that is supposed to be downloaded). I need to modify my code to stop this from happening. I've tried to exit() the code or die() after the sheet downloads, but I must be doing it wrong because nothing seems to work. I also tried a redirect to send them to a different page once they download the file. That doesn't work either. The next issue is the bottom page is supposed to display our sponsor's website, which it does. However, the frame that contains the website is not 100% in height as it is specified to be. Something in my code is causing it to stop extending all the way. If you would like to see exactly what is happening for yourself, you can go he http://www.sheetmusichaven.com/download.php?sheet=98%20Degrees-I%20Do%20Cherish%20You-SheetMusicHaven.pdf&artist=98%20Degrees&title=I%20Do%20Cherish%20You I'm using the latest version of Firefox, PHP 5. And for the code. I warn you it is ugly >< <?php session_start(); include_once('inc/connect.php'); $sheet = $_GET['sheet']; $artist = stripslashes($_GET['artist']); $title = stripslashes($_GET['title']); $hyphen = " - "; $url = "http://www.youtube.com"; $timetodownload = $_POST['timetodownload']; $todayquery = mysql_query("SELECT `todayviews` FROM `websites` WHERE `active`='yes'"); $todayresult = mysql_fetch_assoc($todayquery); $todayviews = $todayresult['todayviews']; $result = mysql_query("SELECT `url` FROM `websites` WHERE `active`='yes' && `dailyviews`>'$todayviews' && `credits`>0"); $i = 0; while($row = mysql_fetch_array($result)) { while($i<1){ $url = $row['url']; $i++; } } if(strlen($artist)+strlen($title)>80){ $artist = ""; $hyphen = ""; } $ip = $_SERVER['REMOTE_ADDR']; // Time Goes Here // $ipcheck = mysql_query("SELECT ip FROM downloading WHERE ip='$ip'"); // $ipcount = mysql_num_rows($ipcheck); // if ($ipcount!=0) // { // $error1 = "<div id='regerror'>Username already taken!</div>"; // } // $ipquery = "INSERT INTO downloading VALUES ('','$ip','$time')"; // mysql_query($ipquery); $timesdownloaded = 0; if(isset($timetodownload)&&$timesdownloaded<1){ ############################################################### # File Download 1.31 ############################################################### # Visit http://www.zubrag.com/scripts/ for updates ############################################################### # Sample call: # download.php?f=phptutorial.zip # # Sample call (browser will try to save with new file name): # download.php?f=phptutorial.zip&fc=php123tutorial.zip ############################################################### // Allow direct file download (hotlinking)? // Empty - allow hotlinking // If set to nonempty value (Example: example.com) will only allow downloads when referrer contains this text define('ALLOWED_REFERRER', ''); // Download folder, i.e. folder where you keep all files for download. // MUST end with slash (i.e. "/" ) define('BASE_DIR','admin/uploads/'); // log downloads? true/false define('LOG_DOWNLOADS',true); // log file name define('LOG_FILE','downloads.log'); // Allowed extensions list in format 'extension' => 'mime type' // If myme type is set to empty string then script will try to detect mime type // itself, which would only work if you have Mimetype or Fileinfo extensions // installed on server. $allowed_ext = array ( // archives 'zip' => 'application/zip', // documents 'pdf' => 'application/pdf', 'doc' => 'application/msword', // images 'gif' => 'image/gif', 'png' => 'image/png', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', ); #################################################################### ### DO NOT CHANGE BELOW #################################################################### // If hotlinking not allowed then make hackers think there are some server problems if (ALLOWED_REFERRER !== '' && (!isset($_SERVER['HTTP_REFERER']) || strpos(strtoupper($_SERVER['HTTP_REFERER']),strtoupper(ALLOWED_REFERRER)) === false) ) { die("Internal server error. Please contact system administrator."); } // Make sure program execution doesn't time out // Set maximum script execution time in seconds (0 means no limit) set_time_limit(0); if (!isset($sheet) || empty($sheet)) { die("Please specify file name for download."); } // Nullbyte hack fix if (strpos($sheet, "\0") !== FALSE) die(''); // Get real file name. // Remove any path info to avoid hacking by adding relative path, etc. $fname = basename($sheet); // Check if the file exists // Check in subfolders too function find_file ($dirname, $fname, &$file_path) { $dir = opendir($dirname); while ($file = readdir($dir)) { if (empty($file_path) && $file != '.' && $file != '..') { if (is_dir($dirname.'/'.$file)) { find_file($dirname.'/'.$file, $fname, $file_path); } else { if (file_exists($dirname.'/'.$fname)) { $file_path = $dirname.'/'.$fname; return; } } } } } // find_file // get full file path (including subfolders) $file_path = ''; find_file(BASE_DIR, $fname, $file_path); if (!is_file($file_path)) { die("File does not exist. Make sure you specified correct file name."); } // file size in bytes $fsize = filesize($file_path); // file extension $fext = strtolower(substr(strrchr($fname,"."),1)); // check if allowed extension if (!array_key_exists($fext, $allowed_ext)) { die("Not allowed file type."); } // get mime type if ($allowed_ext[$fext] == '') { $mtype = ''; // mime type is not set, get from server settings if (function_exists('mime_content_type')) { $mtype = mime_content_type($file_path); } else if (function_exists('finfo_file')) { $finfo = finfo_open(FILEINFO_MIME); // return mime type $mtype = finfo_file($finfo, $file_path); finfo_close($finfo); } if ($mtype == '') { $mtype = "application/force-download"; } } else { // get mime type defined by admin $mtype = $allowed_ext[$fext]; } // Browser will try to save file with this filename, regardless original filename. // You can override it if needed. if (!isset($_GET['fc']) || empty($_GET['fc'])) { $asfname = $fname; } else { // remove some bad chars $asfname = str_replace(array('"',"'",'\\','/'), '', $_GET['fc']); if ($asfname === '') $asfname = 'NoName'; } // set headers header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Type: $mtype"); header("Content-Disposition: attachment; filename=\"$asfname\""); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . $fsize); // download // @readfile($file_path); $file = @fopen($file_path,"rb"); if ($file) { while(!feof($file)) { print(fread($file, 1024*8)); flush(); if (connection_status()!=0) { @fclose($file); die(); } } @fclose($file); } // log downloads if (!LOG_DOWNLOADS) die(); $f = @fopen(LOG_FILE, 'a+'); if ($f) { @fputs($f, date("m.d.Y g:ia")." ".$_SERVER['REMOTE_ADDR']." ".$fname."\n"); @fclose($f); } $timesdownloaded++; if(isset($timetodownload)==($_POST['timetodownload'])){ $timetodownload = ""; echo "<meta http-equiv=\"refresh\" content=\"0;url=index.php?letter=0\">"; } if($timesdownloaded>0){ header("Location: index.php"); } } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="description" content="Free Piano Sheet Music - Sheet Music Haven" /> <meta name="keywords" content="free,piano,sheet,music,download,keyboard,haven,lyrics,notes,chords,score,top,modern,popular,jazz,classical,sheetmusichaven" /> <meta name="author" content="Sheet Music Haven - Free Piano Sheet Music. Download all types of piano sheet music for free. Popular sheets are added often" /> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" /> <title>Downloading <?php echo $sheet; ?> - Sheet Music Haven</title> <link rel="stylesheet" type="text/css" href="styles/style.css" /> <style> iframe { padding: 0px; spacing: 0px; } body{ margin: 0px; color: #000000; } #bggreen{ width: 99%; height: 88%; background-color: #6aa504; margin-left: auto; margin-right: auto; text-align: center; } #countdown{ color: #4296ce; font-size: 18px; } .sheetbar a{color: #000000; font-family: "Arial", Helvetica, sans-serif; } #logo{ position: relative; width: 320px; height: 65px; text-align: center; float: left; top: 19px; } #timer{ position: relative; width: 65%; height: 59px; float: left; text-align: center; top: 3px; background-color: #ececec; border-style: solid; border-color: #93DB70; } </style> <script type="text/javascript"> var time = 2; function startCountdown(){ var t = setTimeout("countdown()", 1000); } function countdown(){ var sHeet = "<?php echo $sheet;?>"; var artist = "<?php echo $artist;?>"; var tItle = "<?php echo $title;?>"; --time; if(time == 0){ document.getElementById("countdown").innerHTML = "<form action='download.php?sheet=<?php echo $sheet; ?>' method='POST'><input type='image' src='img/download.png' alt='Download' name='timetodownload' value='Download'><\/form>"; }else{ document.getElementById("countdown").innerHTML = time; var t = setTimeout('countdown()', 1000); } } </script> </head> <body onload="startCountdown();" bgcolor="#343331"> <table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0"> <?php echo "<tr><td style='background:#343331;height:80px;border-bottom:#aaaaaa solid 2px;'>"; echo "<div id='bggreen' class='sheetbar'> <div id='logo'><a href='index.php'><img src='img/logosmall.png'></a><br /> <a href='suggestions.php' style='color: #ececec; font-size: 14px;'>Report Errors</a></div> <div id='timer'> It is our sponsor's that keep this website running. Please view their website while you wait for:<br /> <span style='color: #6aa504;'>".ucwords($artist).$hyphen.ucwords($title)."</span> <br /> <div id='countdown'>2</div> </div> </div>".$error; echo "</td></tr>"; ?> <tr><td> <iframe src="<?php echo $url;?>" width="100%" height="100%" frameborder="0" marginwidth="0" marginheight="0"> <p>Your browser does not support iframes.</p> </iframe> </td></tr> </table> </body> </html> Hello, Well let me explain my problem to you guys. I am using a printf function with an array, a custom function which i got off php.net Anyways, Everytime I use it, It seems to leave random numbers at the end of the string for no reason at all. Here is the result in source: Code: [Select] <td><a href="?page=download&name=DarkRP">DarkRP</a></td> <td>08:10:17 AM 07/08/2010</td> <td>Updated DarkRP from revision: 670 to revision: 67150</td> Array ( [Name] => DarkRP [TimeStamp] => 1281186617 [Revision1] => 670 [Revision2] => 671 ) </tr>It is mean't to show Code: [Select] Updated DarkRP from revision: 670 to revision 671but instead it has the random number 50 at the end for no reason... Anyways heres the echoing code: <?php foreach($Logs as $Log){ $Time = TimeToDate($Log['TimeStamp']); if($Log['Revision1']&$Log['Revision2']){ $Message = 'Updated %1$s from revision: %3$s to revision: %4$d'; }else{ $Message = 'Freshly downloaded: %1$s revision: %3$d'; } ?> <tr> <td><?php echo '<a href="?page=download&name='. $Log['Name'] .'">'. $Log['Name'] .'</a>'; ?></td> <td><?php echo $Time['Time'] .' '. $Time['Date']; ?></td> <td><?php echo printf_array($Message, $Log); ?></td> <?php print_r($Log); ?> </tr> <?php } ?> </table> <br /> Functions: function MySQLGetLogs(){ global $Connection; if($Connection){ $Query = sprintf('SELECT name, timestamp, revision1, revision2 FROM update_logs ORDER BY timestamp DESC;'); if($Result = mysql_query($Query)){ $Array = array(); while($Row = mysql_fetch_array($Result)){ $Array2 = array(array( 'Name' => $Row['name'], 'TimeStamp' => $Row['timestamp'], 'Revision1' => $Row['revision1'], 'Revision2' => $Row['revision2'] ) ); $Array = array_merge($Array, $Array2); } mysql_free_result($Result); return $Array; } } } function printf_array($Format, $Array) { return call_user_func_array('printf', array_merge((array)$Format, $Array)); } Also, I got the same issue with printf alone instead of the custom array function above. Hey guys, I wrote a function called isServer() so I can quickly move files from my local machine to my server without modifying too much. The function is as follows: function isServer() { if ($_SERVER['SERVER_NAME'] == 'myservername') { return(true); } else { return(false); } } // isServer() I have placed this function in a system.php file I created that is used to simply to keep things in order. That files contents a <?php session_start(); function isServer() { if ($_SERVER['SERVER_NAME'] == 'myservername') { return(true); } else { return(false); } } // isServer() include "configuration.php"; include "functions.php"; include "functions_sql.php"; include "functions_soap.php"; include "functions_mail.php"; if (isProductionServer()) { $dbhost = 'db'; $dbuser = 'db_user'; $dbpass = 'pass123'; } else { $dbhost = 'localhost'; $dbuser = 'user'; $dbpass = 'pass'; } $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'my_database'; mysql_select_db($dbname) or die ('Selected database does not exist'); ?> The problem I am having is for some reason none of the include files are recognizing the function. For example, the functions_mail.php file references the function to determine which emails to send (because the different environments have different modules and such installed). I know this is something easy, but I can't seem to figure it out. Thanks for any help! Hey guys im having a real problem trying to make this string happend the problem is passing parameters on the javascript function "onmouseover" $map_array .= "<a href='map.php?planet=$address' onmouseover='ajax_popup ($picture,$detail_name,$stargate_address,$detail_owner,$time_conquered,$time_offset,$detail_siege, $alliance)'> <img src='images/star.jpg' style='position:absolute; left:".$b_x."px; top:".$b_y."px; border-style:solid; border-color: yellow;'></a>"; if I try this it works onmouseover='ajax_popup(1,2,3,4,5,6,7,8)'> So the problem is when the variables equal words. Cause of the quote issue. Is there like a way i should be using JSON to do what im trying to do? I have to keep this as a php string too. Or end as a php string Hi all, I am desperately in need of some help here. I have been troubleshooting these codes for days, and I have posted this similar question quite a couple of times, and there is no answer from anyone... I am really in a bad shape now. Could someone please enlighten me to my problem? I have created 2 while loops...apparently the 2nd while loop overwrites the 1st while loop record. Meaning to say...1st while loop generates values of 'Math' 'Eng' 'Chi' 'Sci' AND store it in $subject_data, createLevelCheckboxes($subject_data, $level_data, 5); Apparently, the 2nd while loop takes only the last record 'Sci' from $subject_data and continues the looping. Which gives me results like Level 1 Sci Level2 Sci Level3 Sci I would like to attain something like.... Level 1 Math Level2 Eng Level3 Chi Level4 Sci Is there any reset which I need to do? while($data = mysqli_fetch_array($sql)) { if($current_level_id != $data['level_id']) { $checkboxes .= createLevelCheckboxes($subject_data, $level_data, 5); $current_level_id = $data['level_id']; $subject_data = array(); } //Add the current record to the $level_data array $subject_data[] = $data; } while($data1 = mysqli_fetch_array($sql1)) //Iterate throug the DB results { $checkboxes .= createLevelCheckboxes($subject_data, $level_data, 5); $level_data = array(); $level_data[] = $data1; } $checkboxes .= createLevelCheckboxes($subject_data, $level_data, 5); As far as it goes for me I have the switch() working, but not to what im trying to do. This is for a "media" page where I have 3 different categories "Music", "Videos" and "Photos". I'm trying to get it so when you goto the "Media" page it will show just the 3 categories, that section works but it is also showing the sub categories for all them categories. So for what im trying to do is when viewing the "media" page, it will display the 3 categories, then when selecting the category it will display the "sub categories". and then when you select the "sub category" it will display the contents of that "sub category" should i be trying to do this a different way? or do i have something wrong here? lol here is my switch() code Code: [Select] <?php $cat = (isset($_GET["m_cat"])) ? (intval($_GET["m_cat"])) : 0; switch($_GET["b"]=="true") { default : if("/ffy/media.php"==$_SERVER['PHP_SELF']) { echo "Select a Category"; } case "false": if($_GET["m_cat"]==$cat) { echo "<font size='3'>"; $dcat = mysql_query("SELECT * FROM media_sub_cat WHERE m_cat=$cat") or die("mySQL Query Failed: " .mysql_error()); while($catrow = mysql_fetch_array($dcat)) { list($id, $m_sub_cat, $m_cat) = $catrow; echo ": <font class='myFont'><a href='media.php?b=true&cat=".$m_cat."&subcat=".$m_sub_cat."'>".$m_sub_cat."</a></font> "; } echo ":</font>"; echo "Work Damb You"; } break; case "true": if($_GET["cat"]==$cat && $_GET["subcat"]==$m_sub_cat) { echo "Weird..."; } break; } ?> Hi, I'm trying to convert a charting app to OOP. So here I've simplified it down to just the bare bones issue of drawing a line to a png image and displaying it. Code: [Select] <?php class chart { var $im; var $backgroundColor; var $textColor; function chart() { $this->im= @ImageCreate (100, 200) or die ("Cannot Initialize new GD image stream"); $this->backgroundColor = ImageColorAllocate ($this->im, 224, 234, 234); $this->textColor = ImageColorAllocate($this->im, 233, 14, 91); } function display() { imageline ($this->im,0,0,100,200,$this->backgroundColor); imageline ($this->im,100,0,0,200,$this->textColor); ImagePng ($this->im); } } ?> Here is the code which instantiates the class. Code: [Select] <?php include "simple_draw.php"; $mychart = new chart(); $mychart->chart(); $mychart->display(); ?> Basically depending on how I rework it, one of two things happens: a)it generates a bunch of little boxes which say fffd, or b) I get a message saying the resource is invalid or nonexistent (this error isn't coming up right now so I can't be precise.) If this is run outside the OOP environment it works fine. No sure. I'm really trying to work with classes but this kind of problem is frustrating and admittedly makes it tempting to just go back to regular functions. Any ideas?? Thanks, Jeff Hey I'm having issues with using strtotime(), date(), and time(). I have a couple problems. The first is: I used strtotime to get the unix of a specific date and time (worked great, even outputted the correct time using date() to return it). However when I went to post information on it (I set it up so that you can't post after the event started), it told me it already started like an hour before it was supposed to. I used Code: [Select] if (time() > $event['when']) { echo "too late."; } else { do it } to determine. That had me very confused. Then I decided instead of manually inputting the event times I would pull them from an xml file, which I had no trouble reading. I used: Code: [Select] strtotime("Next $day, $time PM") with $day = Sun, $time = 1:00- This outputted a unix timestamp but then date() returned it as being 7 pm on sunday instead. Any ideas what would be causing these strange things? Hi folks, me again. I am trying to create the login for the admin section of my project, but facing issues again. I can't seem to get the code to check to see if the username and password submitted through the login form is correct as per what is in the database. Here is the form: Code: [Select] <form action="authenticate.php" method="post" name="frmLogin" id="frmLogin"> <table width="400" border="1" align="center" cellpadding="2" cellspacing="2"> <tr> <td width="150">User Id</td> <td><input name="txtUserId" type="text" id="txtUserId"></td> </tr> <tr> <td width="150">Password</td> <td><input name="txtPassword" type="password" id="txtPassword"></td> </tr> <tr> <td width="150"> </td> <td><input name="btnLogin" type="submit" id="btnLogin" value="Login"></td> </tr> </table> </form> The authenticate.php: <?php session_start(); // Start a new session require('../config/config.php'); // Holds all of our database connection information // Get the data passed from the form $username = $_POST['user']; $password = $_POST['password']; // Do some basic sanitizing $username = stripslashes($username); $password = stripslashes($password); $sql = "select * from users where username = '$username' and password = '$password'"; $result = mysql_query($sql) or die ( mysql_error() ); $count = 0; while ($line = mysql_fetch_assoc($result)) { $count++; } ?> The errors I get: Code: [Select] Warning: mysql_query() [function.mysql-query]: Access denied for user 'danoid'@'localhost' (using password: NO) in /home/danoid/public_html/admin/authenticate.php on line 14 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/danoid/public_html/admin/authenticate.php on line 14 Access denied for user 'danoid'@'localhost' (using password: NO) Any one got any ideas? I'm trying to run this: Code: [Select] <?php ini_set('max_execution_time','3600'); ini_set('memory_limit','512M'); ini_set('upload_max_filesize','100M'); ini_set('post_max_size','100M'); phpinfo(); ?> Max execution time and memory_limit works but upload_max_filesize and post_max_size don't work. Are you allowed to set those at run time? I have an XML document that id decrypted and shown onto a table. At the bottom of the page, I'm trying to have it count up one Code: [Select] foreach($Data as $Types) // loop through book foreach($Types as $Colors) // loop through book { print_r(count($Colors->Color)); } There are 4 colors, blue, green, red, yellow. Blue is listed 7 times, green is 3, red is 8, and yellow is 4 times. What I expect it to print is: 7 3 8 4 Instead, it's printing this: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 If I was to just do the print function without count, it lists like this: blue red blue red green yellow blue red yellow red red green yellow yellow blue blue green blue yellow blue red red blue red My end-goal of this code is to get it to print this: Blue: 7 Green: 3 Red: 8 Yellow: 4 |