473,769 Members | 7,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mysql without Pear DB

2 New Member
Hello!
I would like to ask your help, i have founded a great code here: http://www.jamescaws.c o.uk/2008/07/dynamically-count-exit-link-clicks-throughs-using-javascript-php/

but it uses Pear DB for the database connection. the problem is that it don't works, actually the php don't writes anything in the table and i don't get any error when i add the
Expand|Select|Wrap|Line Numbers
  1. if (PEAR::isError($db)) {
  2. die($db->getMessage());}
code, so not the connection...

Then i tried a simple insert (a Pear DB one, from the pear manual... )
it looks like this:
Expand|Select|Wrap|Line Numbers
  1. $res =& $db->query("INSERT INTO ct_Links (hash, url) VALUES (v, something)");
there's no succes so, maybe somebody can help to rewrite the code to use only simple mysql and php without the pear package... please:D

the connect is simple. but there are some code i don't really no how to transform:
Expand|Select|Wrap|Line Numbers
  1. $db->setFetchMode(DB_FETCHMODE_ASSOC);
  2.  
  3. function local_getLinkID($db, $debugObj, $sHash) {
  4.     $sql = sprintf('SELECT linkID FROM ct_Links WHERE hash = %s', $db->quoteSmart($sHash));
  5.  
  6.     $debugObj->output("local_getLinkID($db, $debugObj, $sHash) : $sql");
  7.  
  8.     $iID = $db->getOne($sql);
  9.  
  10. function local_logNewLink($db, $debugObj, $sHash, $sURL) {
  11.     $sql = sprintf('INSERT INTO ct_Links (hash, url) VALUES (%s, %s)',
  12.         $db->quoteSmart($sHash),
  13.         $db->quoteSmart($sURL)
  14.     );
  15.  
  16.     $debugObj->output("local_logNewLink($db, $debugObj, $sHash, $sURL) : $sql");
  17.  
  18.     $db->query($sql);
  19.  
  20.     return $db->getOne('SELECT LAST_INSERT_ID()');
  21. }
  22.  
  23.  
  24. function local_logLinkClick($db, $debugObj, $iLinkID, $sIP, $sUserAgent) {
  25.     $sql = sprintf('INSERT INTO ct_Log (linkID, ip, useragent) VALUES (%d, INET_ATON(%s), %s)',
  26.         $iLinkID,
  27.         $db->quoteSmart($sIP),
  28.         $db->quoteSmart($sUserAgent)
  29.     );
  30.  
  31.     $debugObj->output("local_logLinkClick($db, $debugObj, $iLinkID, $sIP, $sUserAgent) : $sql");
  32.  
  33.     $db->query($sql);
thanks for any help!!
Sep 1 '08 #1
2 2069
Atli
5,058 Recognized Expert Expert
Hi.

You shouldn't have any trouble changing your code to use the MySQLI extension.
Any decent host should support it.

There are excellent examples of how to use it in the mysqli_query section of the manual.
Sep 2 '08 #2
daralthus
2 New Member
ok thank you very much i will try
Sep 2 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2433
by: Ian.H | last post by:
Hi all, I've taken on a massive project for a client recently and now I've hit some bug fixes that are required (3rd party code). and was just wondering about peoples opinions / personal findings. This set of scripts for the section of the project use an ADODB class for MySQL. I've never used this method before (I wrote a class a while back to handle my MySQL core code which was mainly a wrapper for various mysql_*() functions etc)....
8
2882
by: madcap | last post by:
Hi, Our company was looking for contract programmer to develop an internet/intranet application. We were approached by a freelancer who have quite a lot experience and his resume was impressive. But he did mention that if we download php & mysql and use the application developed within our company, we should be fine and there will not be any legal issues. While some of the folks see this as a low cost solution, others are concerned...
1
2777
by: James | last post by:
Hey everyone, I have a really obscure but impassable problem with a reasonably simple piece of php/PEAR DB/MySQL code When calling several stored procs the first call succeeds, but subsequent calls fail no matter which SP is called first it always works, and the rest fail... with: >>>
0
1454
by: Bill Bevis | last post by:
I'm trying to set up PHP 5.1.3 to run under Apache2, and talk to a MySQL 5.0.21 database, and have been banging my head against a tough install for days. I'm getting a slough of errors like this: /usr/local/ssl/lib/libssl.a(ssl_sess.o)(.text+0xe60): In function `SSL_SESSION_set_timeout': : multiple definition of `SSL_SESSION_set_timeout' /home/software/mysql-standard-5.0.21-linux-i686/lib/libmysqlclient.a(ssl.o)(.text+0x6d8): first...
1
2040
by: Paul | last post by:
I recently upgraded from MySQL 3.23 to 4.1. Now db is not working properly. I'd very much like your help in solving this issue! Here's the code I used to test it: require_once 'DB.php'; $db =& DB::connect('mysql://user:password@localhost/dbname'); if (PEAR::isError($db)) { die($db->getMessage());
8
2164
by: eholz1 | last post by:
Hello Newsgroup, I have redhat 3.0 Enterprise, and mysql (3.58.xxx more or less) installed from a redhat rpm, and php 4.3.9 (installed from an rpm) - I can access data from my mysql db using php and the "pear" Db .php. I recently upgraded my Apache to 2.2 and installed (more or less) PHP 5.2 as well - neither of these installs were from a Redhat rpm, I downloaded the tarballs, extracted, configed, make, etc. Apache seems to work fine...
5
5218
by: john | last post by:
All: Very experienced developer, newbie to PHP. My situation: I have installed on my WIndows XP machine the following: * PHP 5.2.1 * MySQL 5.0 * Apache 2.2 All of these are installed under C:\Program Files under their own
5
3567
by: jmark | last post by:
I need some assistance on how to create a select statement using PEAR DB or MySQL with the LIKE function. That is I am looking of how I can get statement like this work. SELECT * FROM customer WHERE name LIKE '%?'
1
1864
by: Abhinay | last post by:
Hi there, I am C++ programer, new in MySql database, I am using linux OS. Is MySql supports pear to pear replication ( I wanted to duplicate data of master database to salve database at run time for each and every transaction ) ? If no then how to achive it ? I know SqlServer provides pear to pear replication and I wanted to know about similar facility in MySql database. your help would make me happy.
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.