php

Calling a PHP function within an <a > tag, anchor tag

Is it possible to call a PHP function within an anchor tag. I have a PHP function called logout(); Now I want something similar to this. <a href="logout();" >Logout</a> I know with Javascript this works but what is the best approach using PHP function? ...

Another rookie question; How to implement Count() here?

I have this query: SELECT mt.*, fordon.*, boende.*, elektronik.*, business.*, hem_inredning.*, hobby.* FROM classified mt LEFT JOIN fordon ON fordon.classified_id = mt.classified_id LEFT JOIN boende ON boende.classified_id = mt.classified_id LEFT JOIN elektronik ON elektronik.classified_id = mt.classified_id LEFT JOIN business ON bu...

Intermittent "No Database Selected" in PHP/MySQL?

Have a PHP/MySQL form with a dropdown box containing a list of 350 names. When any random name is selected, sometimes it works & displays info about that name from the database, and sometimes the form gives the error "No Database Selected". Here's what I've tried, pretty much grasping at straws as I'm not a programmer: Increasing max...

php foreach question

I have the following code $oldID=-1; $column=0; foreach($pv->rawData as $data) { if ($oldID!= $data->relativeTypeID) { $oldID= $data->relativeTypeID; $column++; $row=1; } echo "Row: ".$row.": Column: ".$column.": ID".$data->relativeTypeID."<br>"; // if exists a description if($data->descr...

PHP curly string syntax question

I'm running PHP 5.3.0. I've found that the curly string syntax only works when the first character of the expression is $. Is there a way to include other types of expressions (function calls, etc)? Trivial example: <?php $x = '05'; echo "{$x}"; // works as expected echo "{intval($x)}"; // hoped for "5", got "{intval(05)}" ...

Handling "other" option in dropdown select with free text input field

Hi, I'm trying to figure out the best way to handle a dropdown list where one of the options "other" shows a hidden text field (via jQuery), where the user can then enter text. Should both the dropdown and the input field be given the same "name" attribute, then server side code runs a check on the values of each in order to know what on...

receiving error undefined index on two variables

Using adLDAP.php class receiving following error: Notice: Undefined index: memberof in /web/ee_web/include/adLDAP.php on line 762 line 762: if (is_array($groups[0]["memberof"])) { Also receiving error: Notice: Undefined index: count in /web/ee_web/include/adLDAP.php on line 982 line 982: $entries[0]["memberof"]["count"]++; Unsure ...

where are the frameworks for creating libraries?

Whenever I create a PHP library (not a framework) I tend to reinvent everything every time. "Where to put configuration options?" "Which design pattern to use here?" "How should all the classes extend each other?" and so on... Then I think, isn't there a good library framework to use anywhere? It's like a framework for a web applic...

php session variable

Hi Everyone, my session variable seems to keep dropping its array values. What could I be doing wrong? Is it my object? session_start() is initiated at the beginning, if(isset($_SESSION['locations'])) { unserialize($_SESSION['locations'])->listItems($_POST['companyLocation']); echo "session exists"; } else{ $_SESSIO...

How do I create a timed ban on an account? (PHP/mysql)

I want to create a function that allows me to ban an account for 10days. In the dbc, I have a field called "ban" and Boolean of 1=notban, 0=ban. I also have a field called "date_banned" which is just the timestamp of when the user got banned. My question is how do I create a time frame of 10days from the date the user was banned? ex:...

Regular expression problem (PHP)

Hello all. I have a little problem with my regular expression, that I use in PHP. My code identify all tags of my content and add a link in this image. My code is working when I use dinamycally, without any defined image. When I try with a imapge path, the code does not work. How can I solve this problem? Working code: $content = preg_...

Text mining with PHP

Hi, I'm doing a project for a college class I'm taking. I'm using PHP to build a simple web app that classify tweets as "positive" (or happy) and "negative" (or sad) based on a set of dictionaries. The algorithm I'm thinking of right now is Naive Bayes classifier or decision tree. However, I can't find any PHP library that helps me do...

MySQL & PHP Tagging

Hi, I'm creating a webapp. I want to support tags. How have to be the MySql table?. I want to relate a link, with various tags. Thanks. ...

How to Pass URL param in form on submit?

I have <form name="feedback" method="post" onsubmit="return checkform()" action="engine.php?ad="> and I need to append a variable to engine.php?ad=, which is <?=$_GET['page'];?> in php (pass a URL param to the next page using this.) How would I go about adding that? I also have it in javascript if needed. ...

php search and replace

I am trying to create a database field merge into a document (rtf) using php i.e if I have a document that starts Dear Sir, Customer Name: [customer_name], Date of order: [order_date] After retrieving the appropriate database record I can use a simple search and replace to insert the database field into the right place. So far so go...

The best way to store username and password without a database

Hello everyone, I want to build a simple single user login "library" in PHP, but I'm facing the following dilemma: how should I store username and password if I'm not using a database? A simple plain text file could be easily read and then the password could be easily decripted so that's not an option. If I create a php file with just ...

help with htaccess

I want to redirect this: foo.com/xxx ... to this: foo.com/somepage.php?id=xxx This is how I do it: Options +FollowSymLinks RewriteEngine On RewriteCond %{QUERY_STRING} ^$ RewriteRule ^([^/]+)$ http://foo.com/somepage.php?id=$1 [L] the problem now, is that foo.com doesn't work any more. I can't see foo.com neither foo.com/index.p...

I have a problem with mysql and php

Hi I have a problem, this is my code: $db = new mysqli("localhost", "root", "", "blah"); $result1 = $db->query("select * from c_register where email = '$eml' and password = '$pass'"); if($result1->fetch_array()) { $auth->createSession(); $_SESSION['user'] = 'client'; promptUser("You have successfully...

How practical is it to host Apache and mySQL/PostreSQL on the same Linux box?

I'd like to set up a LAMP (or LAPP) web server for hosting Internet sites. Assuming no more than moderate traffic, are there practical concerns against setting it all up on the same machine (or, in this case, VPS?) ...

Event bubbling with img tags?

I did some googling and figured I'm probably experiencing so called "event bubbling" that I've never heard of but are not surprised by it's existance. I want it to fire only once and I'm wondering how to fix this. Basically, I have this small code snippet: $('.bggallery_images').click(function () { alert('test'); }); ...