473,698 Members | 2,166 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 2064
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
2432
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
2879
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
2773
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
1450
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
2033
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
2160
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
5215
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
3563
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
1860
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
8674
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
8603
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,...
0
9026
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8893
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
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7723
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
4366
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.