PHP - Does Anybody Know How To Connect To Cpanel With Curl?
I found this class online that looks like it should work. I have googled quite a bit on how to get this to work, but I can't find anything. All the discussions on google are a couple years old.
Code: [Select] <?php class cPanel { var $cPanelUser = ""; var $cPanelPass = ""; var $cPanelDomain = ""; var $cPanelPort = 0; var $cPanelRel = ""; var $cPanelRoot = ""; function cPanel($cPanelDomain, $cPanelPort, $authUser, $authPass) { $this->cPanelDomain = $cPanelDomain; $this->cPanelPort = $cPanelPort; $this->cPanelUser = $authUser; $this->cPanelPass = $authPass; //Root path of cPanel to load pages begining with / $this->cPanelRoot = "http".($this->cPanelPort==2083 ? "s" : "")."://".$this->cPanelDomain.":".$this->cPanelPort."/"; //Relative path of cPanel to load pages not begining with / $this->cPanelRel = $this->cPanelRoot.""; } function fetchPage($cPanelPage, $sPostVars = "") { $ch = curl_init(); $loginf = sprintf("%s:%s", $this->cPanelUser, $this->cPanelPass); //Build the path. If it begins with / we go and paste at root if ($cPanelPage[0] == '/') { $url = $this->cPanelRoot.substr($cPanelPage, 1); } else { //Build the path - if begins with / we go and paste relative $url = $this->cPanelRel.$cPanelPage; } curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_POST, true); curl_setopt ($ch, CURLOPT_POSTFIELDS, $sPostVars); // curl_setopt ($curl, CURLOPT_TIMEOUT, 30); // curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("Mozilla/%d.0",rand(4,5))); // curl_setopt ($curl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0); // curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 0); // curl_setopt ($curl, CURLOPT_FAILONERROR, 0); echo $loginf; echo $url."?".$sPostVars; curl_setopt ($ch, CURLOPT_USERPWD, $loginf); curl_setopt ($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); $result = curl_exec ($ch); echo 'Errors: ' . curl_errno($ch) . ' ' . curl_error($ch) . '<br><br>'; curl_close ($ch); return $result; } } Similar TutorialsHi, I'm trying to connect to CreditSafe's API with supplied username and password using PHP's CURL, unfortunately am having to do everything from scratch as they won't provide any details as to how we are supposed to set the connection up. The idea is that a username and pw are supplied and you then get a "token" which can be used to make further requests for data. The username and pw are given by them in JSON format so I am trying to use these and authenticate against their API. At the moment though I get the following for each of the test variables (see end of this script) I'm outputting to the screen: Data is HTTP/1.1 100 Continue HTTP/1.1 404 Not Found Date: Mon, 18 Jan 2021 15:18:30 GMT Content-Type: application/json; charset=UTF-8; skipnullon="everywhere" Content-Length: 61 Connection: keep-alive Strict-Transport-Security: max-age=31536000; includeSubdomains; { "correlationId": "6c2dc370-59a0-11eb-893a-0223445bacd9" } Response is NULL Array is just blank (because Response is NULL) This is what I have so far, am struggling with it, any idea what's going wrong?
<?php
$data_array = array(
$headers = array(
curl_setopt_array($curl, [ //Testing output below echo 'Data is '.$return; echo 'Response is '.$response; echo 'Array is '.var_dump($response); curl_close($curl); ?> [/CODE]
Anyone have any ideas? Thanks!
Hello. I am trying to connect to a AXIS 210A Network Camera with PHP and CURL. The reason why, is to log in to only one webpage, and then show all the webcams. Here is my code: $url = "http://xx.xx.xx.xx:1500/"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_USERPWD, "user:pass"); $result = curl_exec($ch); curl_close($ch); ?> I only get a white screen? Any ideas anyone? Hi, There is a feature in cpanel called optimize website and when you go in it there is a field to fill Compress the specified MIME types. My question is this the correct way to optimize PHP CSS JS did i enter the mime types correctly? text/html text/plain text/xml/css/application/x-httpd-php/application/x-javascript Hello, I created a PHP script that creates a database, user, and then adds the user to the database. it had been working perfectly for the past year, and then out of no where last night, it stopped working simultaneously on 20 different servers.. cPanel has not changed or anything, unless it was auto-updated without my knowledge... the first 2 lines work, however the last line does not $b = file_get_contents("https://".$username.":".$password."@localhost:2083/frontend/x3/sql/addb.html?db=database"); $b = file_get_contents("https://".$username.":".$password."@localhost:2083/frontend/x3/sql/adduser.html?user=username&pass=password"); $b = file_get_contents("https://".$username.":".$password."@localhost:2083/frontend/x3/sql/addusertodb.html?user=username&db=database&ALL=ALL"); any thoughts? hi, I wrote code that allow me to create email account outside of cpanel and works greats with one domain name. However I'm trying to change code for two domains to select domain name using menu. The forms that i wrote is come with one text fields for input user name and one drop menu for select domain which is: Code: [Select] <input name="username" size="20" /> <select name="domain_select" id="domain_select"> <option value="realdeafworld.com">domain1.com</option> <option value="realdeafway.com">domain2.com</option> </select>and then is sending data to other page which is config.php and Code: [Select] $username = 'username'; // This variable is the cPanel username $password = 'password'; // Please enter your cPanel password $domain_name = 'domain1.com, domain2.com'; // Please enter the domain name associated with the account $domain_select = $domain_name; $skin = 'x3'; and then it will process to other page which is "http://$username:$password@$domain_name:2082/frontend/$skin/mail/doaddpop.html?email=$_POST[username]&domain=$domain_name&password=$_POST[password]"a=25"); For some reason is not working right, event i put Code: [Select] $domain_name = 'realdeafworld.com, realdeafway.com'; between two domain im getting result of domain1.com. i also changed the variable name to Code: [Select] $domain_name = '$domain_select '; and still not working. Can anyone help me how can i solve this by select one domain name from menu before create email account! please help thanks. AM I'm working on a website (for free) and the website owner has shared hosting w/ cPanel. When logged in to cPanel, the PHP version can be set to PHP5.5. So I did that. When logged in via SSH, scripts are still running on PHP5.3.
I found that /opt/alt/php55/usr/bin/php is a location of php5.5, but when I run my script, it gives an error that mysqli is not found.
As far as I know, this is probably just a typical cPanel install. If anyone can point me to the right way to run PHP5.5 from the command line, I'd appreciate it.
good day dear community, i am workin on a Curl loop to fetch multiple pages: i have some examples - and a question: Example: If we want to get information from 3 sites with CURL we can do it like so: $list[1] = "http://www.example1.com"; $list[2] = "ftp://example.com"; $list[3] = "http://www.example2.com"; After creating the list of links we should initialize the cURL multi handle and adding the cURL handles. $curlHandle = curl_multi_init(); for ($i = 1;$i <= 3; $i++) $curl[$i] = addHandle($curlHandle,$list[$i]); Now we should execute the cURL multi handle retrive the content from the sub handles that we added to the cURL multi handle. ExecHandle($curlHandle); for ($i = 1;$i <= 3; $i++) { $text[$i] = curl_multi_getcontent ($curl[$i]); echo $text[$i]; } In the end we should release the handles from the cURL multi handle by calling curl_multi_remove_handle and close the cURL multi handle! If we want to another Fetch of sites with cURL-Multi - since this is the most pretty way to do it! Well I am not sure bout the string concatenation. How to do it - Note I want to fetch several hundred pages: see the some details for this target-server sites - /(I have to create a loop over several hundred sites). * siteone.example/?show_subsite=9009 * siteone.example/?show_subsite=9742 * siteone.example/?show_subsite=9871 .... and so on and so forth Question: How to appy this loop into the array of the curl-multi? <?php /************************************\ * Multi interface in PHP with curl * * Requires PHP 5.0, Apache 2.0 and * * Curl * ************************************* * Writen By Cyborg 19671897 * * Bugfixed by Jeremy Ellman * \***********************************/ $urls = array( "siteone", "sitetwo", "sitethree" ); $mh = curl_multi_init(); foreach ($urls as $i => $url) { $conn[$i]=curl_init($url); curl_setopt($conn[$i],CURLOPT_RETURNTRANSFER,1);//return data as string curl_setopt($conn[$i],CURLOPT_FOLLOWLOCATION,1);//follow redirects curl_setopt($conn[$i],CURLOPT_MAXREDIRS,2);//maximum redirects curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,10);//timeout curl_multi_add_handle ($mh,$conn[$i]); } do { $n=curl_multi_exec($mh,$active); } while ($active); foreach ($urls as $i => $url) { $res[$i]=curl_multi_getcontent($conn[$i]); curl_multi_remove_handle($mh,$conn[$i]); curl_close($conn[$i]); } curl_multi_close($mh); print_r($res); ?> I look forward to your ideas. define("DB_HOST", "localhost"); Ok this code doesn't look wrong but i cant figure out whats going on? Code: (connect.php) [Select] <?php //connect.php $server = 'localhost'; $username = 'admin'; $password = 'pass'; $database = 'gms'; if(!mysql_connect($server, $username, $password)) { exit('Error: could not establish database connection'); } if(!mysql_select_db($database) { exit('Error: could not select the database'); } ?> ERROR Code: [Select] Parse error: syntax error, unexpected '{' in /home/adee67/public_html/forum/connect.php on line 13 for some reason my database will not connect, here's the code: Code: [Select] <?php require("mstr_ref2.php"); function parseToXML($htmlStr) { $xmlStr=str_replace('<','<',$htmlStr); $xmlStr=str_replace('>','>',$xmlStr); $xmlStr=str_replace('"','"',$xmlStr); $xmlStr=str_replace("'",'&#39;',$xmlStr); $xmlStr=str_replace("&",'&',$xmlStr); return $xmlStr; } // Opens a connection to a MySQL server $connection=mysql_connect (localhost, $username, $password); if (!$connection) { die('Not connected : ' . mysql_error()); } // Set the active MySQL database $db_selected = mysql_select_db($database, $connection); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); } // Select all the rows in the markers table $query = "SELECT * FROM markers WHERE 1"; $result = mysql_query($query); if (!$result) { die('Invalid query: ' . mysql_error()); } header("Content-type: text/xml"); // Start XML file, echo parent node echo '<markers>'; // Iterate through the rows, printing XML nodes for each while ($row = @mysql_fetch_assoc($result)){ // ADD TO XML DOCUMENT NODE echo '<marker '; echo 'name="' . parseToXML($row['name']) . '" '; echo 'address="' . parseToXML($row['address']) . '" '; echo 'lat="' . $row['lat'] . '" '; echo 'lng="' . $row['lng'] . '" '; echo 'type="' . $row['type'] . '" '; echo '/>'; } // End XML file echo '</markers>'; ?> I think there is something wrong with this line of code. Where it says 'locat host' im not too sure about that because im not connecting to a local host, so what can i put in there instead?i think that is the problem. Code: [Select] $connection=mysql_connect (localhost, $username, $password); This is the error I get: Code: [Select] Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'a2221438'@'localhost' (using password: NO) in /home/a2221438/public_html/map.php on line 44 Hey, I've had this problem for a couple days now, and haven't been able to work it out. I'm trying to connect to the Gamesurge IRC using PHP - though the code I am using times out and can't connect. I thought it was my code, however I have searched the web for working codes and they all *seem* to do the same basic thing as mine. So if anyone has any ideas as to why I am getting a timeout, I would appreciate it. The code I'm using. <?php error_reporting(E_ERROR); $cfg = array( "server" => "irc.gamesurge.net", "channel" => "#wiremod", "port" => 6667, "name" => "thetree PHP" ); echo "Connecting to " . $cfg["server"] . " on port " . $cfg["port"] . "<br/>"; $socket = fsockopen($cfg["server"], $cfg["port"], $errno, $errstr, 5); if (!$socket) { echo("Error[$errno]: $errstr...<br/>"); } else { echo "Socket connection successful..<br/>"; } fclose($socket); ?> Hosted file: http://joethetree.lil.org.uk/socket.php Thanks thetree I'm trying to add Facebook connect to my new app, but I'm not sure where to really start. I looked through a lot of the facebook documentation, but I haven't been able to find any really good implementation suggestions. I just want basic functionality. Hello all, This is my first post in here, so go easy. I recently transferred my account from my local ISP to GoDaddy. And now my search criteria is not working. I am getting the follow error message on the page of my search box, instead of the graphics itself: Could not connect to MySQL:Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) I thought maybe this would be a simple error when I found out that GoDaddy does not use the "localhost" connect string. So I switched it to the local IP for GoDaddy still to no avail. I am lost after that. My PHP skills are limited. I was taught by a very advanced user who uses shortcuts and different strings self made for his ease. So looking online for solutions for the script was very hard(to me at least), because the lines of code do not match common scripts online. Is this a simple solution? Does the: global $dbc; @dbConnect(); function work with GoDaddy? Because I have seen maybe different ways to connect to a DB with PHP. Here's the script I am using to connect and extract results from the DB. Any and all help will be greatly appreciated. Thanks in advance. Using MySQL Version 4: <? @require("searchheader.php"); ?> <table cellpadding=10 cellspacing=0 border=0> <tr> <td align=left valign=top> <? displayMenu(); ?> </td> <td align=right valign=bottom> <? if($_GET["f_catid"]){ $num_cats = 5; for($i=1;$i<=$num_cats;$i++){ $where .= " or c".$i." = ".$_GET["f_catid"]; } $where = substr($where,4,strlen($where)); $sql = "select * from product where ".$where." order by product_name ASC LIMIT 0,20"; dbConnect(); $result = mysql_query($sql,$dbc); ?> <div class="search_results_menu"> <form action="[url=http://www.nexpart.com/extpart.php?part=]http://www.nexpart.com/extpart.php?part=[/url]<?=$r["part_number"]?>&linecode=<?=$row[" manufacturer"] ?>" method="GET"><input type="text" name="quantity" size="2" value="0" style="text-align: center;"><input type="button" name="submit_top" value="Check Out"> </form> <table class="search_results_found" bgcolor="#efefef" cellpadding=3 cellspacing=0 border=1 bordercolor="#000000" style="border:1px solid #000000;"> <tr bgcolor="#efefef"> <td class="search_results_title"><b>Manufacturer</b></td> <td class="search_results_title"><b>Part Number</b></td> <td class="search_results_title"><b>Part Name</b></td> <td class="search_results_title"><b>Price</b></td> <td class="search_results_title"><b>Image</b></td> <td class="search_results_title"><b>Add to Cart</b></td> </tr> <? if(mysql_num_rows($result) > 0){ while($row = mysql_fetch_assoc($result)){ ?> <tr bgcolor="#efefef"> <td><?=$row["manufacturer"]?></td> <td><a href="[url=http://www.nexpart.com/extpart.php?part=]http://www.nexpart.com/extpart.php?part=[/url]<?=$row["part_number"]?>&linecode=<?=$row["manufacturer"]?>"><?=$row["part_number"]?></a></td> <td><?=$row["product_name"]?></td> <td>$<?=$row["price"]?></td> <td><a href="[url=http://www.wlpsr.com/images/]http://www.wlpsr.com/images/[/url]"<?=$row["part_number"]?>".jpg " onClick="window.open('/images/<?=$row["part_number"]?>.jpg', '<?=$row["part_number"]?>', 'toolbar=yes, directories=no, location=no, status=yes, menubar=no, resizable=yes, scrollbars=yes, height=300, width=400'); return false">View</a></td> <td><form action="[url=http://www.nexpart.com/extpart.php?part=]http://www.nexpart.com/extpart.php?part=[/url]<?=$r["part_number"]?>&linecode=<?=$row["manufacturer"] ?>" method="GET"><input type="text" name="quantity" size="2" value="0" style="text-align:center;"> </form> </td> </tr> <? } } else{ ?> <tr> <td colspan=100 align="center"><b>No products in this category.</b></td> </tr> </table> <form action="[url=http://www.nexpart.com/extpart.php?part=]http://www.nexpart.com/extpart.php?part=[/url]<?=$r["part_number"]?>&linecode=<?=$row[" manufacturer"] ?>" method="GET"><input type="text" name="quantity" size="2" value="0" style="text-align: center;"><input type="button" name="submit_top" value="Check Out"> </form> </td> </tr> <? } ?> </td> </tr> </table> </div> <? } ?> <div class="form"> <form name="search" action="<? echo $_SERVER['PHP_SELF']; ?>" method="GET"> <input type="text" name="f_keywords" size="17" value="" maxlength="100"> <input type="image" src="gobutton.gif"> </form> </select> <br><br><br> <? $trimmed = trim(strip_tags($_GET["f_keywords"])); //Set the database access information as constants. if(strlen($trimmed) > 0){ define ('DB_USER', 'USERNAME'); define ('DB_PASSWORD', 'THEPASSWORD'); define ('DB_HOST', 'LOCALIP'); define ('DB_NAME', 'DBNAME'); define ('DB_TABLE', 'TABLE'); //Make the connection to the DB global $dbc; @dbConnect(); $query = "SELECT * FROM product WHERE manufacturer LIKE '%$trimmed%' OR part_number LIKE '%$trimmed%' OR price LIKE '%$trimmed%' OR product_name LIKE '%$trimmed%' order by manufacturer"; $result = mysql_query($query); $count = mysql_numrows($result); if ($trimmed == "") { echo "Please enter a search criteria..."; exit; } // check for a search parameter if (!isset($result)) { echo "<p>Please enter a search parameter!</p>"; exit; } $numresults=mysql_query($query); $numrows=mysql_num_rows($numresults); if ($numrows == 0) { echo "<h4>Results</h4>"; echo "<p>We are sorry <b>$trimmed</b> has returned zero results.</p></font>"; } // next determine if s has been passed to script, if not use 0 if (empty($s)) { $s=0; } // get results $result = mysql_query($query,$dbc); if($numrows < 1){ $return= "results";} else{ $return = "result"; } if($numrows > 1){ $return = "results";} else{ $return = "result"; } // display what the person searched for echo "Your search for ", " <b>$trimmed</b> ", " found <br><b>$numrows $return.</b>"; // begin to show results set $count = 1 + $s ; } if(strlen($trimmed) > 0){ ?> </div> <div class="search_results"> <table cellpadding=0 cellspacing=0 border=0> <tr> <td align="right"> <form action="[url=http://www.nexpart.com/extpart.php?part=]http://www.nexpart.com/extpart.php?part=[/url]<?=$r["part_number"]?>&linecode=<?=$row[" manufacturer"] ?>" method="GET"><input type="text" name="quantity" size="2" value="0" style="text-align: center;"><input type="button" name="submit_top" value="Check Out"> </td> </tr> <tr> <td> <table class="search_results_found" bgcolor="#efefef" cellpadding=3 cellspacing=0 border=1 bordercolor="#000000" style="border:1px solid #000000;"> <tr> <td width="100" class="search_results_title" align="center"> Manufacturer </td><td width="70" class="search_results_title" align="center"> Part Num. </td><td width="115" class=" search_results_title" align="center"> Description </td><td width="60" class="search_results_title" align="center">Price</td><td width="45" class=" search_results_title" align="center"> Image </td><td width="105" align="center"><b>Add to Cart</b> </td> </tr> </td> </tr> <? while ($r= mysql_fetch_array($result)) { $manufacturer = $r["manufacturer"]; $part_number = $r["part_number"]; $product_name = $r["product_name"]; $price = $r["price"]; $count++; echo "<tr><td>$manufacturer</td><td>"; echo "<a href=\"[url=http://www.nexpart.com/extpart.php?part=]http://www.nexpart.com/extpart.php?part=[/url]".$r["part_number"]."&linecode=".$r["manufacturer"]."\">".$r["part_number"]."</a></td><td>"; echo "$product_name</td><td>"; echo "$ $price</td><td>"; echo "<a href=\"[url=http://www.wlpsr.com/images/]http://www.wlpsr.com/images/[/url]".$r["part_number"].".jpg \" onClick=\"window.open('/images/".$r["part_number"].".jpg', '".$r["part_number"]."', 'toolbar=yes, directories=no, location=no, status=yes, menubar=no, resizable=yes, scrollbars=yes, height=300, width=400'); return false \">View</a></td><td>"; echo "<form action=\"[url=http://www.nexpart.com/extpart.php?part=]http://www.nexpart.com/extpart.php?part=[/url]".$r["part_number"]."&linecode=".$r["manufacturer"]."\" method=\"GET\"><input type=\"text\" name=\"quantity\" size=\"2\" value=\"0\" style=\"text-align:center;\"></td></tr>"; } ?> </table> <tr> <td align="right"> <form action="[url=http://www.nexpart.com/extpart.php?part=]http://www.nexpart.com/extpart.php?part=[/url]<?=$r["part_number"]?>&linecode=<?=$row[" manufacturer"] ?>" method="GET"><input type="text" name="quantity" size="2" value="0" style="text-align: center;"><input type="button" name="submit_bottom" value="Check Out"> </td> </tr> <? } ?> </table> <br><br> </div> <? @require("footer3.php"); ?> Mod edit: [code] . . . [/code] tags added. hello, if i have an entry in a table called company on database cc, would the following be the propper code? im getting a blank page. Code: [Select] <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'mike'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'cc'; mysql_select_db($dbname); $query = "SELECT * FROM company"; $result = mysql_query($query); while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "Name :{$row['compant']} <br>" . "Subject : {$row['address']} <br>" . } ?> hi all First of all My client have dot net server on windows OS. They want to display some pages which are created by php. Is there any possibility to display like this. And How can i connect sql server using php on remote to retrieve data. Can any one tell me how can i do this. Thanks in advance Hi, I have a script which uses a connect file but I am struggling to get files in other folders to read and for the "$loggedIn = checkLogin();" code to work. If I connect to the database within the same script it works straight away. If I change my password then I have to change every file but otherwise I cannot include the connect file as I have to link to it locally. So if the connect file is in: www.domain.co.uk/php/login/connect.php then www.domain.co.uk/php/login/index.php -- this works www.domain.co.uk/php/logout.php -- this doesn't regardless of how I link to the connect file. I'm trying to connect to two databases and I'm having problems with the following code. I googled to come up with this but can't figure out the errors I'm getting. Code: [Select] $connection="localhost"; $username="user"; $password="password"; $database1="dbone"; $database2="dbtwo"; $db1 = mysql_connect($connection,$username,$password) or die(mysql_error()); $sel1 = mysql_select_db($database1, $db1); $query1 = "SELECT * FROM TBLUSERS"; $result1 = mysql_query($query1, $db1); while($nt1 = mysql_fetch_array($result1, $db1)) { } $db2 = mysql_connect($connection,$username,$password) or die(mysql_error()); $sel2 = mysql_select_db($database2, $db2); $query2 = "SELECT * FROM TBLPD20101101"; $result2 = mysql_query($query2, $db2) or die(mysql_error()); while($nt2 = mysql_fetch_array($result2, $db2)) { } The error I get is Quote Warning: mysql_fetch_array() expects parameter 2 to be long, resource given in C:\xampp\htdocs\HighVisibility\DashBoard2.php on line 13 Warning: mysql_fetch_array() expects parameter 2 to be long, resource given in C:\xampp\htdocs\HighVisibility\DashBoard2.php on line 22 Hello there, I'm using a Mac (10.5. and installed MAMP for PHP and MYSQL I trying to build a blog. I just setup a database in phpmyadmin. I created a php and start coding, everything works just fine, but when I tried to connect to the mysql it gives me a blank page I inserted this code Code: [Select] <?php session_start(); $connect = mysql_connect('localhost','root', 'root'); or die(mysql_error()); $db = mysql_select_db('blog',$connect); $session_name = $_SESSION['uid']; ?> but then the whole page turns to be blank page , but when I excluded this, it works just fine. I don't get it cause my database/phpmyadmin connected just fine. Any help is much appreciated. Been trying to figure this out for hours. hey I need this to connect to my database on my sybase sql server, but no matter what i try, it won't populate the plunum field. Any help would be appreciated. Here is my HTML code: Code: [Select] <html> <head> <title>helloscan</title> <meta http-equiv="refresh" content="18"> <meta http-equiv="scanner" content="javascript:doScan('%s');"/> <meta http-equiv="scanner" content="start"/> <META HTTP-Equiv="scanner" Content="enabled" /> <META HTTP-Equiv="scanner" Content="AutoEnter:Enabled"/> <meta http-equiv="keycapture" content="accelerate:all" /> <meta http-equiv="keycapture" content="keyvalue:0x0D; dispatch=true; keyevent:url('javascript:mykeypressed();')" /> <meta http-equiv="quitbutton" content="visibility: visible;"/> <script language="javascript" type="text/javascript"> function doScan(data){ var divEl = ("%s"); } function enablescanner(enable){ Generic.InvokeMetaFunction('scanner', 'start'); Generic.InvokeMetaFunction('scanner', 'enabled'); Generic.InvokeMetaFunction('scanner', 'autoenter:enabled'); } </script> <script> function get_plunum(){ xmlhttp=ajaxfunction(); if (xmlhttp==null) { alert ("no ajax support"); return; } var ae_xrefnum = document.getelementbyid('ae_xrefnum').value; var ae_plunum = document.getelementbyid('ae_plunum').value; var querystring = "?ae_xrefnum=" + xrefnum + "&ae_plunum="+ plunum"; xmlhttp.onreadystatechange = function (){ if (xmlhttp.readystate == 4 || xmlhttp.readystate=="comlete"){ document.myform.ae_plunum.value = xmlHttp.responseText; } } xmlhttp.open("GET", "helloscan2.php"+querystring, true); xmlhttp.send(null); } function ajaxfunction(){ var xmlhttp=null; try {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } catch (err) {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } return xmlhttp; } </script> </head> <body onload="enablescanner(true)"> <h3 align="center"><center><img src="ac moore" /></center>Please scan a barcode...</h3> <form name="myform"> ItemBarcode: <input type="text" id="ae_xrefnum" name="ae_xrefnum" itembarcode="divE1" oninput="get_plunum()" /> plunum: <input type="text" id="ae_plunum" name"ae_plunum" oninput="get_price()"/> </form> <script language=javascript> { document.myform.ae_xrefnum.focus(); } </script> </body> </html> And Here is my PHP code: Code: [Select] <?php //================================================================ // Configure connection parameters $db_host = "97.0.40.244, 1498"; $db_server_name = "ACMSQL036A"; $db_name = "backoff.db"; $db_file = 'd:\trvbkup\DB'; $db_conn_name = "php_script"; $db_user = "dba"; $db_pass = "sql"; //================================================================ $connect_string = "Driver={Adaptive Server Anywhere 8.0};". "CommLinks=tcpip(Host=$db_host);". "ServerName=$db_server_name;". "DatabaseName=$db_name;". "DatabaseFile=$db_file;". "ConnectionName=$db_conn_name;". "uid=$db_user;pwd=$db_pass"; // Connect to DB $conn = odbc_connect($connect_string,'',''); // Query $qry = "SELECT xrefnum, plunum FROM DBA.PLU_Cross_Ref where xrefnum = '$xrefnum'"; // Get Result $result = odbc_exec($conn,$qry); // Get Data From Result while ($row[] = odbc_fetch_array($result)); // Free Result odbc_free_result($result); // Close Connection odbc_close($conn); // Show data print_r($row[plunum]); //================================================================ ?> |