PHP - Requesting Help In Php Odbc Stored Procedure Calling
Hi Everyone,
This is Tamilmani Mohan , i have few doubts in SQL Stored Procedure. I am able to run the SQL SP using odbc driver and also get the result set. For Example: odbc_exec($connection,"exec get_Members"); I don't know how to run the input / output parameters SP's? Example:- If i run the below code by using SQL Management Visual Studio, I am able to insert to new record and get the member id and error code values. declare @MemberId int,@Error int EXEC INSERT_MEMBER 1,'Tamilmani','Mohan','Address1', 'Address2', 'Address3','Salem','Tamilnadu','India',9993234234 , @MemberId OUTPUT , @Error OUTPUT SELECT @MemberId , @Error I don't know how to run this type code in PHP ODBC ? Kindly , please any one give me good suggestion for this problem ? Thanks Tamilmani Mohan Similar Tutorialswrote a stored procedure this morning and i don’t know how to get the values out of it through a class function in php or phpmyadmin. here is what i wrote : public function totalProcedures($friend_name,$session_id) { /* *query to fetch stored procedure */ try { //executing the stored procedure $sql_sp="CALL timeline (:friend, :session,@updates, @group_posts)"; $stmt_sp= $this->_db->prepare($sql_sp); $stmt_sp->bindValue(":friend",$friend_name); $stmt_sp->bindValue(":session",$session_id); $stmt_sp->execute(); $rows=$stmt_sp->fetch(PDO::FETCH_ASSOC); $stmt_sp->closeCursor(); // closing the stored procedure //trying to get values from OUT parameters. $stmt_sp_2=$this->_db->prepare("select @updates,@group_posts"); $stmt_sp_2->execute(); return $stmt_sp_2->fetch(PDO::FETCH_ASSOC); } catch (PDOException $ei) { echo $ei->getMessage(); } } can someone helpme how to get results. here is the storedprocedu DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE `timeline`(IN `friend` VARCHAR(255), IN `session_id` VARCHAR(255), OUT `updates` VARCHAR(62555), OUT `group_posts` VARCHAR(62555)) BEGIN select * FROM updates where author in (friend,session_id) order by time desc limit 5; select * FROM group_posts where author_gp in (friend,session_id) order by pdate desc limit 5; END$$ DELIMITER ; i get the result in php myadmin as follows:
how do i do this inside a php class function. CALL timeline('shan2batman','aboutthecreator', @updates, @group_posts);
Hi Everyone, I have this php page that runs couple of MS SQL stored procedures to fetch me values from SQL Server, however I have run into a problem where not more then 2 stored procedures are executed at same time. For instance below mentioned code only fetches me values for 1st and 2nd SP's. If I need values from the 3rd stored procedure then I would have to comment either one of the first two stored procedure. Can someone please tell me what is that I am doing wrong. I am relatively new to PHP, so please be gentle. Any help would be highly appreciated. Thanks. <?php if($conn = mssql_connect('host', 'user', 'pass')) echo 'Connected to SQLEXPRESS<BR>'; if(mssql_select_db("database",$conn)) echo 'Selected DB: SomeDatabase<BR>'; $variable1=something; $sql_statement = mssql_init("stored_procedure1 '$variable1'", $conn); $result=mssql_execute($sql_statement); $x=0; while ($row = mssql_fetch_assoc($result)) { $column2[$x]= $row['column2']; $column1= $row['column1']; $x++; } echo "Value 1: $column1 </br>"; echo "Value 2: $column2[0] </br>"; echo "Value 3: $column2[1] </br>"; echo "Value 4: $column2[2] </br>"; echo "Value 5: $column2[3] </br>"; echo "Value 6: $column2[4] </br>"; echo "Value 7: $column2[5] </br>"; mssql_free_statement($sql_statement); $sql_statement = mssql_init("stored_procedure2 '$variable1'", $conn); $result=mssql_execute($sql_statement); $x=0; while ($row = mssql_fetch_assoc($result)) { $someval1[$x]= $row['somecolumn1']; $someval2[$x]= $row['somecolumn2']; $someval3= $row['somecolumn3']; $someval4= $row['somecolumn4']; $someval5= $row['somecolumn5']; $someval6= $row['somecolumn6']; $x++; } echo "Something1: $someval1[0]</br>"; echo "Something2: $someval3 </br>"; echo "Something3: $someval2[0] </br>"; echo "Something4: $someval4 </br>"; echo "Something5: $someval6 </br>"; echo "Something6: $someval5 </br>"; mssql_free_statement($sql_statement); $sql_statement = mssql_init("stored_procedure3 '$variable1'", $conn); $result=mssql_execute($sql_statement); $x=0; while ($row = mssql_fetch_assoc($result)) { $somevaluecheck= $row['somecolumncheck']; $x++; } echo "SomethingCheck: $somevaluecheck </br>"; mssql_free_statement($sql_statement); ?> I am trying to make a setup file for a website I'm developing, and am having the database tables and stored procedures created automatically. However, I'm having issue getting the stored procedures to be created. Here is my code: Code: [Select] $db->Q(" DELIMITER $$ CREATE PROCEDURE `Database`.`Procedure_Name`(in sp_uid mediumint(20) unsigned, in sp_user varchar(15), in sp_pass varchar(20), in sp_email varchar(30)) BEGIN Insert Into Table Values (sp_uid, sp_user, md5(sp_pass), sp_email, '1', '1', '0'); Select true; END$$ "); Assume that the "$db->Q()" works just fine, as I'm having issues no where else with it. This automatically connects to the database and runs a query with whatever is inside the "()". The tables are being created just fine, but no stored procedures are being created. I've tried everything I can think of, and googled my question many different ways without finding an answer or work-through. Does anyone know what I am doing wrong? Thanks in advance. Hi All, I'm hitting brick walls while trying to run a stored procedure query with PDO (linking to MSSQL) If I run the query from SSMS (SQL Server Management Studio) I get a result every time (one single row is returned, as expected) - I'm placing the same query into PHP without any dynamic variables etc - its just a straight query... when it runs the query in PDO it fails every time with this error:
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[IMSSP]: The active result for the query contains no fields.' in index.php:195 The code is as follows: $SQLSTMTA="exec pEmployeeGetData @EmployeeID='1',@Year='2020'"; $STHA = $DBH2->prepare($SQLSTMTA); //$STH->bindParam(':EMPID', $EmployeeID); $STHA->execute(); while($result = $STHA->fetchAll()) { //(row 195) var_dump($result); } I've also tried a few variations on the above such as ->Fetch (as opposed to FetchAll) without any luck. Any ideas on how I can get around this? Thanks in Advance!
Hi all,
This is just an experiment to make sure that I can get data from a Stored Proc 'IF' and when I need to, so it's basically a THOUGHT EXERCISE.
MSSQL 2014
I'm a noobie and need a hand, I've managed to get my Instance connected to the internet and I can query it using PHP and SQL, I can also look at views with no problem.
I have it working as an "ADODB.Connection" and like I said it connects and I can query data and display results.
Now I have coded a Stored Proc "GetMonthDays" in Sql Server:
Which returns days 1 through xxx in a given month and also returns the Day name eg... Sat for each date
2014-01-01 Thurs
2014-01-02 Fri
etc...
It works perfectly and very fast so All cool with that side BUT...
I want to be able to query the Database through a Stored Proc, I've spent all day trying to find a way to get this to work and I've hit a wall
Can anyone please tell me IF it's A. possible and B. maybe if they are really really nice and share with me a code example that I can change to fit my needs ?
This T-SQL returns what it needs to
Begin EXEC dbo.qselGetMonthDays '2015-01-01' End Cheers JD Edited by juddadredd, 02 January 2015 - 04:55 PM. Hi,
I have an adverts table that has records of currently running adverts, i have not used stored procedures or triggers before.
I would like to create a stored procedure or a trigger using phpmyadmin for mysql.
Exactly what i want to achieve is, when a record is accessed in adverts table, it causes a table called HITS to create a record that has the adverts_id, IP where the advert was clicked from, current date.
Is that possible?
i have made a logon script but he must give a output parameter "relatieid" but if i do print relatieid i don't get the output parameter. what can i do to get the output parameter. i must give -1 if your logon data don't be good and your relatie id if you are succesfull logon. i saw that you can use fatchall but how my script is: php Code: [Select] <?php session_start(); $sessieid = session_id(); error_reporting(-1); ini_set('display_errors', 1); if($_SERVER['REQUEST_METHOD'] == 'POST') { $username = $_POST['username']; $wachtwoord = $_POST['wachtwoord']; $ip = $_SERVER["REMOTE_ADDR"]; $computernaam = php_uname('n'); if(trim($username) == '') { echo "<font color='red'>Vul geldige gebruikersnaam in!</font><br>"; header("refresh:5;url=/login/"); exit() ; } if(trim($wachtwoord) == '') { echo "<font color='red'>Vul geldige wachtwoord in!</font><br>"; header("refresh:5;url=/login/"); exit() ; } $db = new PDO('mssql:host=localhost\snelstart;dbname=SluisWWW','test','********'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $db->prepare("EXECUTE spMagInvoeren ?,?,?,?,?,?,?"); $stmt->bindValue(1 ,$username, PDO::PARAM_STR); $stmt->bindValue(2 ,$wachtwoord); $stmt->bindValue(3 ,$ip); $stmt->bindValue(4 ,$computernaam); $stmt->bindValue(5 ,$sessieid); $stmt->bindParam(6 ,$poging); $stmt->bindParam(7 ,$relatieid); $stmt->execute(); print "<br/>Returned: $relatieid<br/><br/>\r\n"; { setcookie("TestCookie", $username); // redirecten exit(); } } stored procedure ms sql server Code: [Select] USE [SluisWWW] GO /****** Object: StoredProcedure [dbo].[spMagInvoeren] Script Date: 04/04/2012 09:54:59 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Henk Boessenkool -- Create date: 23 Maart 2012 -- Description: test login -- ============================================= ALTER PROCEDURE [dbo].[spMagInvoeren] -- Add the parameters for the stored procedure here @Usernaam nVarchar(20) , @Wachtwoord nvarchar(20), @IPAdres nvarchar(20), @Computer nvarchar (20), @SessieID nvarchar(50), @PogingenOver integer OUTPUT, @RelatieNummer integer OUTPUT AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. DECLARE @Success INT SET NOCOUNT ON; SET @Success = (SELECT COUNT(*) FROM contactpersonen WHERE (username = @Usernaam AND wachtwoord = @Wachtwoord)) IF @Success = 1 BEGIN SET @RelatieNummer = (SELECT TOP 1 relatie_id FROM [SluisWWW].[dbo].[contactpersonen] WHERE (username = @Usernaam AND wachtwoord = @Wachtwoord)) END ELSE SET @RelatieNummer = -1 INSERT INTO [SluisWWW].[dbo].[Logins] (Login,Wachtwoord,RelatieID,IP,Computer,SessieID) VALUES (@Usernaam,@Wachtwoord,@RelatieNummer,@IPAdres,@Computer,@SessieID) set @PogingenOver = 24 -- Insert statements for procedure here END I'm using a CRUD system which won't automatically update the lft and rght values of my hierarchical tables when I enter a new row. I don't know what the best way to solve this is, all I can think of is adding a stored procedure to the table so that whenever a new row gets added, the procedure will make sure the lft and rght values get shifted. Is this even possible with stored procedures?
Hello - I need a way to execute a stored procedure from a wordpress site with an external database where the stored procedure is housed. I am very limited in php code. All I know is from what little I have used My Custom Functions plugin. Please be very detailed. This stored procedure I run truncates and re-populates a number of tables I use for various reports. I am pulling data from the wp db and creating tables in the external db which make the data easier to read than through the wp meta data. The tables are housed in a separate db so as not to slow down the wp db. The hosting company does not allow 'Events' to run on the mySql db so I am left with figuring out how to create a cron job using a php file which would be the best. Aside from that, I thought a button on an admin page for execution would make it easier if I have to do it be hand. Thanks for your help. Hello All Can someone help me with this: I am trying to create some PHP code to pass 2 variables to a stored procedure. At the moment I have: <?php // Connect to MSSQL and select the database $serverName = "(local)"; $connectionInfo = array( "Database"=>"ashley"); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn === false ) { echo "Could not connect.\n"; die( print_r( sqlsrv_errors(), true)); } /*Call the stored procedure with a named parameter*/ $tsql = 'EXEC CPS_ADD_NEW_USER @agentF = php,@agentS=test'; $stmt = sqlsrv_query($conn, $tsql); /* Free statement and connection resources. */ sqlsrv_free_stmt( $stmt); sqlsrv_close( $conn); ?> Could anyone advise me what I need to be doing and where I am going wrong Thanks in advance Bicky Hi Please take a look at my code snippet. I don't know how to get the number of rows returned from a MySQL stored procedure so that I can handle it accordingly. Any ideas please? Thanks Hi: I am trying to request an id to do a transfer back to a page, but am having difficulties. This is on a page where a person can add a new section, which gets assigned a unique id. I am trying to send the user to the page where they can edit the new page, once it has been created. Like this: a_websiteDataADD.php Code: [Select] <?php $id = $_REQUEST['id']; ?> ... <script language="JavaScript"> alert("The new section was added!"); location.href = "a_websiteData.php?id=[id]"; </script> What am I missing on this ?? Hi there,
I have a question, which I seem to be unable to find out myself;
I have my own webshop (coded by myself), and trying to add multiple configurable options into it, each option having their own stock limit.
Here is the problem:
I am trying to implement AJAX for the following:
Lets say: Customer wants Product A with Config 1: A, Config 2: C and Config 3: C
Lets say config 1 is length, Config 2 is design of the product, and config 3 is the dimension of the product.
Config 1 Option A has 12 items in stock
Config 2 Option C has 7 items in stock
Config 3 Option C has 1 item in stock.
Here is my question:
How do I implement AJAX to check all these variables (so lets say: You have Config A with Option A (12 stock) B (16 stock) and C(109 stock), etc, and when she selects for example Config 3 Option C, that she can ONLY order 1 of the items, and if she tries to put the order in higher (in the selector) that it sais that with the current configuration only 1 order can be made?
Hi
What is the best recommended way to "sort through" and "place certain data" into a sql table?
For example, I create a input form.php
Company Name:
The Blah CompanyProduct/Industry Dedicated ServersHTML Source Code <div class="allservers"> <div class="serverType" id="server1"> <div class="myFeaturesBox"> <ul class="tabination"> <li><a href="#" class="activeTab" data-tab='feature'>FEATURED</a></li> <li><a href="#" data-tab='single'>SINGLE PROCESSOR</a></li> <li><a href="#" data-tab='dual'>DUAL PROCESSOR</a></li> <div class="clear"></div> </ul> <div class="feature myTab activeTabs"> <table class="table"> <tr> <th></th> <th>Processor</th> <th>RAM</th> <th>Hard Drive</th> <th>Price/Mo</th> <th></th> <th></th> </tr> <tr> <td><img src='img/server.png' alt='Server' width="20" height="20" /></td> <td>Intel Xeon E3-1230 (4x3.2GHz)</td> <td>8 GB DDR3</td> <td>1x500 GB SATA</td> <td>$98.00</td> <td><a href="https://portal.securedservers.com/wap-jpost3/UP011013E31230" target="_self"><img src='img/deploy.png' alt='Deploy Now' width="86" height="18" /></a></td> <td class="wB"></td> </tr> <tr> <td><img src='img/server.png' alt='Server' width="20" height="20" /></td> <td><div style="position:relative;">Intel Xeon E3-1240 v3 (4x3.4GHz)</div></td> <td>8GB DDR3</td> <td>1x1 TB SATA</td> <td>$128.00</td> <td><a href="https://portal.securedservers.com/wap-jpost3/UP031013E31240" target="_self"><img src='img/deploy.png' alt='Deploy Now' width="86" height="18" /></a></td> <td class="wB"></td> </tr> <tr> <td><img src='img/server.png' alt='Server' width="20" height="20" /></td> <td><div style="position:relative;">Intel Xeon E3-1240 v3 4-bay (4x3.4GHz)</div></td> <td>8GB DDR3</td> <td>4x500 GB SATA</td> <td>$148.00</td> <td><a href="https://portal.securedservers.com/wap-jpost3/UP431013E31240" target="_self"><img src='img/deploy.png' alt='Deploy Now' width="86" height="18" /></a></td> <td class="wB"></td> </tr> <tr> </table>Submit Button --> sends to the "sorting process?" than into proper DB tables for search query. Ultimately, there I require to be able to pull from my DB upon query, pricing, hardware, processor, etc.. Any recommendation for me to try? I'm new to PHP but I want to learn and do it myself (better after effect feeling than paying someone) This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=351526.0 Hi all. I have been trying something for 2 days, having no success and was hoping someone could help. I know this is a long post but it's mostly just php code below. I'm trying to do "pagination" for a script that I came across. First of all.. I am not a programmer in any way. I didn't even know what pagination was until 2 days ago when I was trying to explain what I wanted in a forum and was educated. So.. off to Google I went. I found all kinds of "free pagination" script articles with "how-to's". Well.. I think you need to at least have an idea of how to program becuase I've tried 4 now and failed every time. Or... maybe I'm just the world's worst at understanding programming concepts (very possible). I really have spent just hours and hours trying to make pagination happen.. to no avail. So.. if you know an easier way, please share! Or.. If you care to read on and help with the pagination script I've been trying to make work, that would be awesome. Either way, I would be most grateful! Here's what I got and what I've tried.. My index.php page: Code: [Select] <?php include_once('inc_dbcon.php'); require_once('admin/config.php'); require_once($languageFile); // Preview descrition length in characters $previewLength = 240; // check to see if in admin mode and validate key global $keyOut; $keyOut = ""; if (isset($_GET["k"])) if($_GET["k"] == $key){ // Key comes from admin/password.php file $keyOut = "&k=" . $key; } global $category; $category = "%"; if (isset($_GET["category"])) $category = mysql_real_escape_string($_GET["category"]); $msg = ""; if (isset($_GET["msg"])) $msg = mysql_real_escape_string($_GET["msg"]); // SEARCH CODE START $searchQuery = ""; if (isset($_GET["q"])) $searchQuery = mysql_real_escape_string($_GET["q"]); if ($searchQuery != "") { $query_Recordset1 = "SELECT postId,category,title,description,isAvailable,description,price,confirmPassword,category,imgURL,imgURLThumb,DATE_FORMAT(timeStamp,'%b %d, %Y %l:%i %p') AS timeStamp1 FROM md_postings WHERE isConfirmed = '1' AND title like '%$searchQuery%' OR description like '%searchQuery%' ORDER BY `timeStamp` DESC"; } else { $query_Recordset1 = "SELECT postId,category,title,description,isAvailable,description,price,confirmPassword,category,imgURL,imgURLThumb,DATE_FORMAT(timeStamp,'%b %d, %Y %l:%i %p') AS timeStamp1 FROM md_postings WHERE isConfirmed = '1' AND category like '$category' ORDER BY `timeStamp` DESC"; } // SEARCH CODE END - see also line 113 below $maxRows_Recordset1 = 100; $pageNum_Recordset1 = 0; if (isset($_GET['pageNum_Recordset1'])) { $pageNum_Recordset1 = mysql_real_escape_string($_GET['pageNum_Recordset1']); } $startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1; $query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1); $Recordset1 = mysql_query($query_limit_Recordset1); if (!$Recordset1){ print("It appears we have a problem: " . mysql_error()); exit(); } $row_Recordset1 = mysql_fetch_assoc($Recordset1); if (isset($_GET['totalRows_Recordset1'])) { $totalRows_Recordset1 = mysql_real_escape_string($_GET['totalRows_Recordset1']); } else { $all_Recordset1 = mysql_query($query_Recordset1); $totalRows_Recordset1 = mysql_num_rows($all_Recordset1); } $totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1; $queryString_Recordset1 = ""; if (!empty($_SERVER['QUERY_STRING'])) { $params = explode("&", $_SERVER['QUERY_STRING']); $newParams = array(); foreach ($params as $param) { if (stristr($param, "pageNum_Recordset1") == false && stristr($param, "totalRows_Recordset1") == false) { array_push($newParams, $param); } } if (count($newParams) != 0) { $queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams)); } } $queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="md_style.css" rel="stylesheet" type="text/css" /> <script language="JavaScript"> function doFilter(dis) { window.location.href = "index.php?category=<?php echo $category ?>&type=" + dis.value + "<?php echo $keyOut;?>" } </script> </head> <body> <?php include_once("inc_navigation.php") ;?> <div id="md_container"> <?php if ($msg == "deleted") print("<br clear='all' /> <div class='md_msg' style='margin-top:-10px;'>" . STR_DELETED ."</div>"); ?> <br clear="all" /> <div id='md_listingBox'> <?php if($totalRows_Recordset1 < 1) { // SEARCH START new Code - added IF statement to support search if ($searchQuery != "") echo "<p><br /><br /><br />" . STR_NORESULTS . "<b>" . $searchQuery ."</b></p>"; else echo "<p><br /><br /><br />" . STR_NOITEMS . "</p>"; // SEARCH END NEW CODE } else { do { $img = "/images/gift_light.gif' title='This is a gift!'"; $type = $row_Recordset1['type']; $isAvailable = $row_Recordset1['isAvailable']; $isAvailableClass = ($isAvailable == 0) ? 'md_taken' : ''; $thumbnail = ' '; if (strlen($row_Recordset1['imgURLThumb']) > 3){ $thumbnail = "<a href='viewItem.php?id=" . $row_Recordset1['postId'] . "' class='md_recordLink " . $isAvailableClass . "'>"; $thumbnail .= "<img src='" . $row_Recordset1['imgURLThumb'] . "' class='md_thumbnail' border='0'></a>"; } ?> <table width="100%" border="0" cellpadding="4" class="md_listingTable"> <tr> <td width="54" align="center"><?php echo $thumbnail; ?></td> <td valign="top"> <div class='md_date'><?php echo $row_Recordset1['timeStamp1'];?></div> <a href="viewItem.php?id=<?php echo $row_Recordset1['postId'] . $keyOut;?>" class='md_recordLink<?php echo $isAvailableClass; ?>'><?php echo stripslashes($row_Recordset1['title']); ?></a> — $<?php echo $row_Recordset1['price']; ?> <br /> <?php echo stripslashes(substr($row_Recordset1['description'],0,$previewLength)); ?>... </td> </tr> </table> <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); } // end else clause ?> </div> </div> <?php include_once("inc_footer.php");?> </body> </html> <?php mysql_close($dbConn); ?> Here's the inc_dbcon.php file that it calls to connect: Code: [Select] <?php // Change these to be for your database $dbhostname = "localhost"; $dbname = "justtes1_123"; $dbusername = "justtes1_12"; $dbpassword = "abc12"; if(!$dbConn = mysql_connect($dbhostname, $dbusername, $dbpassword)) die('I could not connect to the database. Clease check the inc_dbcon file and make sure everything is correct.'); if(!mysql_select_db($dbname, $dbConn)) die('I could not select the database. Check the inc_dbcon file and make sure everything is correct.'); ?> I've trying to use the pagination script from: http://www.phpeasycode.com/pagination/ Here's the "usage example" that is in the pagination script: Code: [Select] <?php $rpp = 10; // results per page $adjacents = 4; $page = intval($_GET["page"]); if($page<=0) $page = 1; $reload = $_SERVER['PHP_SELF']; // connect to your DB: $link_id = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error()); mysql_select_db($dbname, $link_id); // select appropriate results from DB: $sql = "SELECT * FROM table_name WHERE table_field LIKE '%search string%' ORDER BY field_name"; $result = mysql_query($sql, $link_id); // count total number of appropriate listings: $tcount = mysql_num_rows($result); // count number of pages: $tpages = ($tcount) ? ceil($tcount/$rpp) : 1; // total pages, last page number $count = 0; $i = ($page-1)*$rpp; while(($count<$rpp) && ($i<$tcount)) { mysql_data_seek($result,$i); $query = mysql_fetch_array($result); // output each row: echo "<p>" . $query['table_field_1'] . ", " . $query['table_field_2'] . "</p>\n"; $i++; $count++; } // call pagination function: include("paginate.php"); echo paginate_three($reload, $page, $tpages, $adjacents); ?> The pagination script also comes with a demo.php. I uploaded that and it works just great. But.. when I try to incorporate the above usage into my index.php, I fail miserably. So.. If you prefer, I can copy index.php with what I've tried.. which is apparently very wrong. The page I tried it in is he http://justtesting.freehosting.com/indexPaginate.php So.. if anyone is able to tell me how they'd incorporate the usage script into the index.php, that would solve my 2 day dilemna and I would be eternally grateful. If you want to login to my test version (feel free to edit as this is purely a test site), it's he http://justtesting.freehosting.com/ ftp host: 62.75.203.94 FTP Username: justtes1 FTP Password: JpxF34j80h A HUGE thanks for anyone who can help! I have tried everything for hours and hours.. I'm developing a javascript widget to display on other people's websites that will have a php file(on my hosting account) as its source. Is there a way for php to get the domain of the site that is requesting the php file? I want the user to be able to specify if they want the widget to only display on their website. So i would store the user's domain name in my db and then write in the php script to check to see if the website requesting the widget matches whats in my db...if so display widget...if not..don't. Hey everyone, I'm new to this forum and I came here looking for some help with PHP. I've just started getting into PHP and you guys are probably a smile ahead. So basically, I have some inputs and want them to be sent to my email in a basic layout shown below. Code: [Select] Inputs: Title = _title Forum Name = _forumname Name = _irlname Age = _age I want the email to be sent to me like: Code: [Select] Email Title --------------- Forum Name: TextGiven Real Life Name: TextGiven Age: TextGiven Here is my current code which titles the email correctly, but I want to figure out how to make $message set to the example email I showed above. Code: [Select] <?php $to = "******@*********.net"; $subject = $_REQUEST['_title']; $headers = "From: ***** Applicant \r\n"; $headers .= "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\r\n" . "Content-Transfer-Encoding: 7bit\r\n"; $message = $_REQUEST['_forumname' & '_irlname']; <--- Part I want fixed if(mail($to, $subject, $message, $headers)) { echo 'MAIL SENT'; } else { echo 'MAIL FAILED'; } ?> I have this code, and it works. But I want $message = "" to make the message contain not just the forum name, but as well as the name, age, and all other inputs I want. Ok so I am writing a CMS to wrap around a company script I wrote a while back. I am having trouble requesting dynamic form names. Heres the code to generate the input fields: $fields = mysql_result($result,$i,"fields"); $exFields = explode(",", $fields); for($i = 0; $i < count($exFields); $i++){ echo "$exFields[$i] : <input type=\"text\" name=\"$exFields[$i]\"> <br>"; } Ok so it generates the fields the way I want. (design crap will be done later) But I am having issues on processing the form, for example: Fields get generated -> Client Fills them in -> Submitted into our already built function. The function takes those form values and creates an XDF file with the correct requested values. But like I said I am having issues requesting the form values because they wont be static they will differ depending on each PDF. Can anyone point me in the direction on how to get the form values? Hello guys,
I require a suggestion about how shall I proceed as when I am about to set a goal for my future in programming world, Just so that you could suggest me better, I urge you to please read about a little background history of mine. And please stay neutral in regards of language, dont say PHP because you are a PHP developer and dont say Java because you are a Java developer.
Thanks.
I stepped into programming when I was in school (below A-levels at 14, now I am 29) and I started to bunk school and went to internet cafe and would sit there reading sources of HTML pages in year 2000. I would observe their programming styles, I would learn about the tags they used and then search internet (it was IE6 then and Yahoo searching at its peak) so I could learn about it.
Years passed, and having my family related to medical professions, I took admission in Pharmacy in University and quit after 2 years and entered working class. My development slowed down but passion always stayed the same.
Now I am in Spain and working as a technician of mobile repairing with a company, but I still have this passion of programming and when I learn that etc etc friend of mine now is working with CISCO in Germany, now is working as a game developer in America, I become really sad. I could have been one of those. But the fact is that I am not. So I restarted again with development and started learning PHP on my work desk using online resources and tutorials and asking silly questions.
Nothing I could become but an obsolete language programmer with a mess.
Now when I havent been able to become someone, till now, I still have passion and I want to be somewhere.
-----------------------------
I am confused for some days now, shall I continue with PHP (apart from the fact that i am a MYSQL learner, haven't learned PDO or MYSQLi till now) or shall I step into Java learning, using the online resources ofCourse, but if I step into Java, It will be a fresh start and I will be able to organize it better on my way with guidance of professionals like you.
The Things confusing me: (as I am imagining in my mind)
PHP:
A great web development language being used on billions of website, have an extraodinary support, well documented, World is moving online, so future is e-commerce in these terms.
JAVA:
Feels a giant to me, and impresses me at times, a myth to me, I am speaking illogical I know, and after android, I see a great potential in this language.
Edited by Digitizer, 28 August 2014 - 06:03 PM. |