Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

PHP MYSQL Problem (Pamana lang)

almore3

Novice
Advanced Member
Messages
25
Reaction score
1
Points
28
Ayaw po magconnect sa mysql ko. I am using Wamp.

<?php

$DIR_MAIN_FOLDER = '/pcf'; <---Ito po ba yung project folder ko?
$DIR_PHYSICAL = 'C:/xammp/htdocs/'.$DIR_MAIN_FOLDER.'/'; <--- tapos ito magiging C:/wamp/www/

$DB_HOST = 'localhost';
$DB_USER = 'root';
$DB_PASS = '';
$BD_TABLE = 'dbrt';
$target=$_SERVER['SERVER_NAME'].$DIR_MAIN_FOLDER;
// $target="dreams.freetzi.com";


function log_activity($transaction_type, $affected_table="", $affected_UID="", $type="", $type_id="", $name=""){
// save logs to database
if(!isset($_SESSION)){
session_start();
}
if(isset($_SESSION['focal_peson_id'][0])){
$name = $_SESSION['focal_peson_id'][0];
}

$query = "INSERT INTO focal_person_activity_logs ( datetime_logged, IP_used, User, transaction_type, affected_table, affected_UID_field, type, type_id)
VALUES ('".date("Y-m-j H:i:s")."', '".$_SERVER['REMOTE_ADDR']."', '".$name."', '".$transaction_type."', '".$affected_table."', '".$affected_UID."','".$type."', '".$type_id."')";
//echo $query;
insert_update_delete($query);
}

function insert_update_delete($query)
{

global $DB_HOST, $DB_USER,$DB_PASS, $BD_TABLE;
@mysql_connect($DB_HOST, $DB_USER,$DB_PASS);
mysql_select_db($BD_TABLE) or die( "Unable to select database");

mysql_query($query)or die( "Unable to execute query");


mysql_close();
}
?>
 
Ayaw po magconnect sa mysql ko. I am using Wamp.

<?php

$DIR_MAIN_FOLDER = '/pcf'; <---Ito po ba yung project folder ko?
$DIR_PHYSICAL = 'C:/xammp/htdocs/'.$DIR_MAIN_FOLDER.'/'; <--- tapos ito magiging C:/wamp/www/

$DB_HOST = 'localhost';
$DB_USER = 'root';
$DB_PASS = '';
$BD_TABLE = 'dbrt';
$target=$_SERVER['SERVER_NAME'].$DIR_MAIN_FOLDER;
// $target="dreams.freetzi.com";


function log_activity($transaction_type, $affected_table="", $affected_UID="", $type="", $type_id="", $name=""){
// save logs to database
if(!isset($_SESSION)){
session_start();
}
if(isset($_SESSION['focal_peson_id'][0])){
$name = $_SESSION['focal_peson_id'][0];
}

$query = "INSERT INTO focal_person_activity_logs ( datetime_logged, IP_used, User, transaction_type, affected_table, affected_UID_field, type, type_id)
VALUES ('".date("Y-m-j H:i:s")."', '".$_SERVER['REMOTE_ADDR']."', '".$name."', '".$transaction_type."', '".$affected_table."', '".$affected_UID."','".$type."', '".$type_id."')";
//echo $query;
insert_update_delete($query);
}

function insert_update_delete($query)
{

global $DB_HOST, $DB_USER,$DB_PASS, $BD_TABLE;
@mysql_connect($DB_HOST, $DB_USER,$DB_PASS);
mysql_select_db($BD_TABLE) or die( "Unable to select database");

mysql_query($query)or die( "Unable to execute query");


mysql_close();
}
?>

Boss anu po ba yung gsto mong mangyari?. or anu ba ginagawa mong system?.
 
Record Tracking boss. Anu problem ko lang is di nagpopulate yung mysql ng mga iniiput kong data sa system. Ang error na is "Unable to execute query" kasi di makaconnect?
 
Hello TS, deprecated na yung mysql need mo ng iupdate code mo ng mysqli or better pdo, regarding sa problema mo, pwede mo ba palabasin error mismo instead na ang prinoproduce mo sa die mo eh unable to execute query, dig mo pa dapat para masolve mo, gamit ka ng mysql_error: parang ganito lang:

Code:
$link = mysql_connect("localhost", "mysql_user", "mysql_password");
mysql_select_db("nonexistentdb", $link);
echo mysql_errno($link) . ": " . mysql_error($link). "\n";

Source: http://php.net/manual/en/function.mysql-error.php

Payo lang sa mga scenario na problema mo eh di makaconnect, check mo dapat kung tama credentials mo para sa database mo, most of the time yun ang problema.
 
Record Tracking boss. Anu problem ko lang is di nagpopulate yung mysql ng mga iniiput kong data sa system. Ang error na is "Unable to execute query" kasi di makaconnect?

gumamit ka ng MySQLi version boss
for OOP version boss
ito po yung sample
Code:
<?php
$server = "localhost";
$username = "root";
$password = "";
 
// Create connection
$conn = new mysqli($server, $username, $password);
 
// Check connection
if ($conn->connect_error) {
die("Connecting to database failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>

kng procedural nman po ito po:
Code:
<?php
$server = "localhost";
$username = "root";
$password = "";
 
// Create connection
$conn = mysqli_connect($server, $username, $password);
 
// Check connection
if (!$conn) {
die("Connecting to database failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>
 
Back
Top Bottom