PHP Insert form using Stored Procedure - php

I'm new to PHP and mysql. I have created a form which accepts some inputs from the user and I want this inputs to be inserted into the mysql using stored procedure.
Hurray I got this, now form data is inserting into the mysql using stored procedure.
dbconn.php
<?php
// Set connection variables.
$host = "localhost";
$user = "root";
$pwd = "root";
$db = "eservice";
// Connect to mysql server
$mysqli = new mysqli($host,$user,$pwd,$db);
/* Check if any error occured */
if (mysqli_connect_errno())
{
echo "Failed to connect to mysql : " . mysqli_connect_error();
exit;
}
?>
Add.php
<?php
// If the form was submitted.
if($_POST)
{
// Connect to db.
include 'dbconn.php';
// Retrieve data from form.
$srn = $_POST['srn'];
$client = $_POST['client'];
$type = $_POST['type'];
$fy = $_POST['fy'];
$category = $_POST['category'];
$sd = $_POST['sd'];
$fd = $_POST['fd'];
$assignto = $_POST['assignto'];
$edoc = $_POST['edoc'];
$current = date('m/d/Y');
$date = strtotime("+".$edoc." days", strtotime($current));
$ecd = date("Y/m/d", $date);
$reviewed = $_POST['reviewed'];
$path = $_POST['path'];
// Stored procedure code
if(!$mysqli->query("DROP PROCEDURE IF EXISTS addproc")
|| !$mysqli->query("CREATE PROCEDURE addproc
(IN client varchar(50), IN type varchar(30), IN fy INT, IN category varchar(30), IN sd varchar(80),
IN fd varchar(80), IN assignto varchar(50), IN edoc date, IN reviewed varchar(40), IN upload varchar(100))
BEGIN
INSERT INTO main(client, type, fy, category, sd, fd, assignto, edoc, reviewed, upload) VALUES(client, type, fy, category, sd, fd, assignto, edoc, reviewed, upload);
END; "))
{
echo "Stored procedure creation failed : (" .$mysqli->errno .") " .$mysqli->error;
}
if(!$mysqli->query("CALL addproc('$client','$type','$fy','$category','$sd','$fd','$assignto','$ecd','$reviewed','$path')"))
{
echo "CALL failed : (" .$mysqli->errno .")" .$mysqli->error;
}
else
{
?>
<script language="javascript">
alert("Task created successfully" + "\n\n" + " <?php echo "Service Request Number : " .$srn ?>");
top.location.href = "Home.php"; // Page redirection.
</script>
<?php
}
if(!$res = $mysqli->query("SELECT * FROM main"))
{
echo "SELECT failed : (" .$mysqli->errno .")" .$mysqli->error;
}
}
?>

$query = "INSERT INTO main(client, type, fy, category, sd, fd, assignto, edoc, reviewed, upload) VALUES('$client', '$type', '$fy', '$category', '$sd', '$fd', '$assignto', '$edoc', '$reviewed', '$upload')";
if(mysqli_query($mysqli,$query))
& others.

Related

html form with white fields to mysql

I don't understand what is the correct way to pass the html form fields to mysql database in case one of the fields is empty.
I have this html:
<form name="formName" method="POST" action="" onsubmit="registra();">
<label for="datetime1">datetime one</label>
<input type="datetime-local" id="datetime1" name="datetime1">
<label for="datetime2">datetime two</label>
<input type="datetime-local" id="datetime2" name="datetime2">
<button type="submit">Salva</button>
</form>
<script>
function registra() {
var datetime1 = document.forms['formName']['datetime1'].value;
datetime1 = new Date(datetime1).toISOString().slice(0, 19).replace('T', ' ');
var datetime2 = document.forms['formName']['datetime2'].value;
datetime2 = new Date(datetime1).toISOString().slice(0, 19).replace('T', ' ');
jQuery.ajax({
type: "POST",
url: "./functions.php",
data: {
action: 'registraForm',
id: <?php echo $id; ?>,
datetime1: datetime1,
datetime2: datetime2
}
}).done(function( response ) {
alert( response );
});
}
</script>
And this php:
<?php
/* AJAX */
if(isset($_POST['action']) && !empty($_POST['action'])) {
$action = $_POST['action'];
switch($action) {
case 'registraForm' : registra_form();break;
}
}
function registra_form() {
$dbhost = "localhost";
$dbuser = "user";
$dbpass = "pass";
$db = "db";
$conn = new mysqli($dbhost, $dbuser, $dbpass,$db) or die("Connect failed: %s\n". $conn -> error);
$id = $_POST['id'];
$datetime1 = ($_POST['datetime1']?$_POST['datetime1']:NULL);
$datetime2 = ($_POST['datetime2']?$_POST['datetime2']:NULL);
if ( /* update mysql row */ ) {
$sql = "UPDATE table SET datetime1='$datetime1', datetime2 = '$datetime2', WHERE id=$id";
} else {
$sql = "INSERT INTO table (id, datetime1, datetime2) VALUES ($id, '$datetime1', '$datetime2')";
}
if ($conn->query($sql) === TRUE) {
echo 'done!';
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
die();
$conn -> close();
}
In the database both datetime1 and datetime2 are set as timestamp type with default null.
If both datetime1 and datetime2 are filled, the registration is successful. If instead one of the two fields of the form is not filled I receive a sql syntax error.
Something like error: UPDATE table SET datetime1='2020-04-17 11:06:00', datetime2='' WHERE id=5 Incorrect datetime value:'' for column db.table.datetime2 at row 2
I think this is the problem $datetime2 = ($_POST['datetime2']?$_POST['datetime2']:NULL); but I don't know how to solve it.
Thanks
Fosco
Ok this is "an answer" and not a pretty one, based upon your supplied code/issue.
Personally I would not code it this way, but we cannot give tutorials on here.
This is more a demonstration on how to go about working something out, without all the in between bits.
This is an example. Test Code (something we should learn to write), I used to test getting the correct SQL Statements.
function test_datetime_sql()
{
$_POST['datetime1'] = '';
$_POST['datetime2'] = '2020-04-17 11:06:00';
// There must be a more elegant way to do this
$datetime1 = $_POST['datetime1']?"'".$_POST['datetime1']."'":'NULL';
$datetime2 = $_POST['datetime2']?"'".$_POST['datetime2']."'":'NULL';
echo '<pre>';
echo 'LINE: '. __LINE__. ' Module '.__CLASS__.'<br>';
var_dump($datetime1);
echo '</pre>';
echo '<pre>';
echo 'LINE: '. __LINE__. ' Module '.__CLASS__.'<br>';
var_dump($datetime2);
echo '</pre>';
$id = 5;
$sql = "UPDATE table SET
datetime1 = $datetime1,
datetime2 = $datetime2,
WHERE id=$id";
var_dump($sql); // What SQL do we get
}
Give that a try by generating the SQL and testing it.
Notice that its a change to the Ternary AND the SQL statement - notice the lack of '' in the $sql for datetime1 and datetime2 as they are generated in the ternary.
What is happening here is if it is a "Not Empty" Value, it's getting wrapped in '' to make it a string.
The same occurs with NULL
I strongly suggest you copy and paste this somewhere and play with it to see what happens.
In your original code, when you set $datetime1 as NULL it appears in your SQL as $datetime1 = '' and NOT as $datetime1 = NULL ( Not the string 'NULL' ).

How to update status in database if status is empty without submitting a form in php?

How to update a status from database if status is empty in using php? I have this condition in php. I have this if condition that decides if $getstatus is empty it will update from database to Avail. I tried refreshing the page after querying the database. But it will not update in database. Is there anyway to update this without using form submit in php?
<?php
session_start();
include "includes/connection.php";
// Display all parking slots
$sql = $connection->prepare('SELECT * FROM parkingslot where parkingslotid = 1');
$sql->execute(); // execute query
$result = $sql->get_result(); // fetch result
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$getstatus = $row["status"];
echo $getstatus;
}
}
if (empty($getstatus)) {
$sql = $connection->prepare("UPDATE parkingslot SET status = 'Avail' where parkingslotid = 1 ");
}
?>
Codes in connection for connecting to database
connection.php
<?php
$server = "localhost";
$username = "root";
$password = "";
// create connection
$connection = mysqli_connect($server,$username,$password);
// check connection
if(!$connection)
{
die("No connection found." . mysqli_connect_error());
}
else {
// select a database
$select_db = mysqli_select_db($connection,'smartparkingsystem');
if(!$select_db)
{
$sql = 'CREATE DATABASE sample';
// create database if no db found
if(mysqli_query($connection,$sql)) {
echo "Database Created";
}
else {
echo "Database not found" . mysqli_connect_error() . '\n';
}
}
else {
// Database already existed
// do nothing...
}
}
?>
If I understand your goal of: For row(s) whereparkingslotid=1 - Update status to 'Avail' but only if status is not currently set, this might help:
<?php
session_start();
include "includes/connection.php";
$connection->prepare("UPDATE `parkingslot` SET `status`=? WHERE `parkingslotid`=? AND (`status` IS NULL OR `status`=?)");
$connection->bind_param("sis", $status, $parkingslotid, $empty_str);
$status = 'Avail';
$parkingslotid = 1;
$empty_str = '';
$connection->execute();
echo $connection->affected_rows.' rows affected';
$connection->close();
?>
This saves a bit of processing by not checking with PHP first.
You can use this query:
"UPDATE parkingslot SET status = 'Avail' where status IS NULL OR status = '' "
Edited:
#lumonald gave the right anwser in the comment. You're not executing your second SQL statement.

select values of a particuliar date from a SQL table to Flash

I've got a SQL table with 100 lines. Each line got a date.
I'd like to retrieve the info for a particular date.
Example :
With Flash, the user select the date 12/11/2014 and the AS3 code will display all the values (each columns of my table) that match this date.
In this example it will display "firstname : As de trefle, tome 1 : 10...etc" as it's the only entry that matches this date.
So far I've managed to select variables, in AS3, from users name, like that :
memberCombo.prompt = "Please select a user";
memberCombo.addItem( {label: "as de trefle" } );
memberCombo.addItem( {label: "kathy" } );
memberCombo.addItem( {label: "peter" } );
memberCombo.addEventListener(Event.CHANGE, checkComplete);
function checkComplete(evt:Event):void {
// Create A new URLVariables instance to store the variable
var myVariables:URLVariables = new URLVariables();
// Create a variable (e.g. candidate) to send
myVariables.username = evt.target.value;
// Create a new URLRequest instance sending data to "ascom01.php"
var myRequest:URLRequest = new URLRequest("http://www.example.com/sql_result.php");
// Send data using the POST method
myRequest.method = URLRequestMethod.POST;
// The data property of the request is set to the
// URLVariables instance (myVariables) to send to the PHP file.
// Note: myVariables stored the variable (e.g. candidate)
myRequest.data = myVariables;
// Create a new instance of the URLLoader class to work with.
// URLLoader.load( ) method should be used when we need the
// sent variables returned back to Flash ActionScript.
var myLoader:URLLoader = new URLLoader;
//specify dataFormat property of the URLLoader to be "VARIABLES"
//This ensure that the variables loaded into Flash with the same variable names
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
//Load the PHP file by using URLRequest
myLoader.load(myRequest);
//Listen when the loading of data COMPLETE
//Call the loadComplete function when the loading COMPLETE
myLoader.addEventListener(Event.COMPLETE, loadComplete);
}
// This is the function that display the data returned back from PHP file
function loadComplete(evt:Event):void {
//Display the value with variable name "totalItem"
total_txt.text = evt.target.data.totalItem
//Get the value (string) with variable name "phpConfirm"
var myResult:String = evt.target.data.phpConfirm;
//Split the string into an Array
var myArray:Array = myResult.split("|");
//output_txt.text = "The number of items are: " + myArray.length;
var finalString = "";
var i:int;
for (i = 0; i < myArray.length; i++) {
finalString = finalString + myArray[i] + "<br>";
}
output_txt.htmlText = finalString;
}
And in my sql_result.php:
<?php
$username = $_POST['username'];
// create connection
$connection = mysql_connect("****.perso", "root", "root") or die ("Couldn't connect to the server.");
// select database
$db = mysql_select_db("dbase", $connection) or die ("Couldn't select database.");
// create SQL
$sql = "SELECT domain FROM d_table where username = '$username'";
// execute SQL query and get result
$sql_result = mysql_query($sql, $connection) or die ("Couldn't execute query.");
// get number of rows in $result.
$num = mysql_numrows($sql_result);
$phpConfirm = "";
$counter = 0;
while ($row = mysql_fetch_array($sql_result)) {
$domain = $row["domain"];
if ($counter == 0) {
$phpConfirm .= $domain;
} else {
// Use a item limiter "|" to seperate the records
$phpConfirm .= "|" . $domain;
}
$counter++;
}
echo "phpConfirm=" . $phpConfirm . "&totalItem=" . $num;
// free resources and close connection
mysql_free_result($sql_result);
mysql_close($connection);
?>
How can I retrieve the variables with the date and not the username ?
And, more complex, how can I use both ? (example : I choose the date AND the username "John" and it shows me all the variables of my table where the date and the username matches ?
Thank you for your help,
EDIT
So, I've changed in my AS3 code the labels by these :
memberCombo.prompt = "Please select a date";
memberCombo.addItem( {label: "2015-06-23" } );
memberCombo.addItem( {label: "06/23/2015" } );
memberCombo.addItem( {label: "23-06-2015" } );
and in my php code :
I've changed
$username= $_POST['username'];
by
$date = $_POST['date'];
and
$sql = "SELECT domain FROM d_table where username = '$username'";
by
$sql = "SELECT domain FROM d_table where date = '$date'";
But it seems that my flash app doesn't find any "domain" with this date.
No error. It just doesn't find anything.
Any idea why ?

Trying to create a simple cumulative addition script in PHP (or JS):

Trying to create a simple cumulative addition script in PHP (or JS):
1) enter any integer(4 digits or less), click submit, number entered is displayed and saved on the same web page
2) enter another number, click submit, number entered is added to previous number and total is saved and displayed on the web page
Repeat …….
Example: the mantra counter at garchen.net
Below is the code I have so far
In Index.php:
<form method="post" action= "process-mantra-form-ami.php" >
<p><strong>Amitabha Million Mantra Accumulation: </strong><br></p>
<div style="margin-left: 20px;">
<p>OM AMI DEWA HRI</p>
<input type="text" name="accumulation" size="10" maxlength="6">
<input type="submit" value="Submit Your Mantra" name="B1"><br>
<span id="mani">Amitabha Mantra Count: <?php echo $newValue; ?> </span>
<p></p>
</div>
</form>
I am getting confused about the form processing php. Im attempting to use my local mamp server for the db. Do I create a connection, create a database, and a table, insert form data into table, and retrieve data back to index.php all at the same time in the process-mantra-form-ami.php file?
You guys made it seem easy in my last post, but there seems to be a lot to it. I know my code below is incomplete and not quite correct. Help!
PROCESS-MANTRA-FORM-AMI.PHP code below
<?php
// Create connection
$con=mysqli_connect("localhost:8888","root","root","my_db");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// escape variables for security
$accumulation = mysqli_real_escape_string($con, $_POST['accumulation']);
// Create database
$sql="CREATE DATABASE my_db";
if (mysqli_query($con,$sql)) {
echo "Database my_db created successfully";
} else {
echo "Error creating database: " . mysqli_error($con);
}
// Create table "Mantras" with one column 'Num'
$sql="CREATE TABLE Mantras (Num INT)";
if (mysqli_query($con,$sql)) {
echo "Table mantras created successfully";
} else {
echo "Error creating table: " . mysqli_error($con);
}
// Insert form data into table
$sql="INSERT INTO Mantras (Num INT)
VALUES ('$num')";
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}
// update database
mysqli_query($con,"UPDATE Mantra SET Num = num + 1");
}
mysqli_close($con);
?>
<div>
<h2>Thank you for your <?php echo $num; ?> Amitabha Mantras!</h2>
<p>Remember to dedicate your merit.</p>
<p>Return to the main site</p>
</div>
try this out... (sorry, bored tonight)
http://php.net/manual/en/book.mysqli.php
http://php.net/manual/en/mysqli.quickstart.prepared-statements.php
$conn->query($sql)
$conn->prepare($sql)
$conn->error
http://php.net/manual/en/class.mysqli-stmt.php
$stmt->bind_param('ss',$val1,$val2)
$stmt->bind_result($res1,$res2)
http://php.net/manual/en/mysqli.construct.php
<?php
$host = 'localhost'; // localhost:8888
$user = 'root';
$pass = ''; // root
$dbnm = 'test';
$conn = mysqli_connect($host,$user,$pass,$dbnm)
or die('Error ' . $conn->connect_error);
// for testing.... so i can run the code over and over again and not
// get errors about things existing and stuff
run_statement($conn,"drop database if exists `my_db`;",'cleared old db');
run_statement($conn,"drop table if exists `mantras`;",'cleared old table');
run_statement($conn,"drop table if exists `two_col_table`;",'cleared old table');
// Create database
$sql = 'create database my_db';
$err = run_statement($conn,$sql,'Database creation');
if (!$err) $conn->select_db('my_db');
// Create table "Mantras" with one column 'Num'
$sql = 'create table mantras (num int)';
$err = run_statement($conn,$sql,'Table mantras');
if (!$err) {
$sql = 'insert into mantras (num) values ( ? )';
$stmt = $conn->prepare($sql);
$stmt->bind_param('d',$num); // d is for digit but s (string) would work too
$num = 1;
$stmt->execute();
$num = 2;
$stmt->execute();
$stmt->close();
echo ($conn->error) ? "insert errored: {$conn->error}" : 'insert ran succesfully';
// update database
$sql = 'update mantras set num = num + 1';
run_statement($conn,$sql,'Update database');
}
// Create table "test" with two columns
$sql = 'create table two_col_tbl (num int, txt varchar(10))';
$err = run_statement($conn,$sql,'Table two_col_tbl');
if (!$err) {
// demonstrating how to bind multiple values
$sql = 'insert into two_col_tbl values ( ?, ? )';
$stmt = $conn->prepare($sql);
$stmt->bind_param('ds',$num,$txt);
$num = 1; $txt = 'hello';
$stmt->execute();
$num = 2; $txt = 'world';
$stmt->execute();
$stmt->close();
// select statement
$sql = 'select num, txt from two_col_tbl';
$stmt = $conn->prepare($sql);
$stmt->bind_result($db_num, $db_txt);
$stmt->execute();
print '<table><tr><th colspan=2>two_col_tbl</tr><tr><th>num</th><th>txt</th></tr>';
while ($stmt->fetch()) {
print "<tr><td>$db_num</td><td>$db_txt</td></tr>";
}
print '<table>';
$stmt->close();
}
$conn->close();
function run_statement($conn,$statement,$descr) {
if ($conn->query($statement))
echo "$descr ran successfully";
else echo "$descr failed: {$conn->error}";
return $conn->error;
}
?>
<div>
<h2>Thank you for your <?php echo $num; ?> Amitabha Mantras!</h2>
<p>Remember to dedicate your merit.</p>
<p>Return to the main site</p>
</div>

error Notice: Undefined variable: d --- Filling database not working

Connecting to database...
Creating database table...
Filling database ... This will take a
few minutes. Even longer for dial-up.
Warning:
file_get_contents(http://localhost/cbmall/xml/marketplace_feed_v1.xml)
[function.file-get-contents]: failed
to open stream: A connection attempt
failed because the connected party did
not properly respond after a period of
time, or established connection failed
because connected host has failed to
respond. in
C:\wamp\www\cbmall\admin\process.php
on line 114
Fatal error: Maximum execution time of
30 seconds exceeded in
C:\wamp\www\cbmall\admin\process.php
on line 114
process.php
<?
// Instant Product Mall (C)2005-2007 Copyright SonicPoint.com. All Rights Reserved.
// You DO NOT have any (re)distribution or re-sell rights of any kind.
require_once("settings.inc.php");
$prevent=$key;
////////////////////////
// check for tampering with hidden var
///////////////////////
if($prevent != "yosue38") {
echo "
<center><BR><BR><BR><font face=verdana size=5 color=red><B>Access Denied: Tampering</b></font></center>
";
exit;
}
////////////////////////
// check password entered
////////////////////////
if($psd != $adminpsd) {
echo "
<center><BR><BR><BR><font face=verdana size=5 color=red><B>Access Denied: Wrong Password - Case SEnsiTIve</b></font></center>
";
exit;
}
////////////////////////
// passed both tests
////////////////////////
echo " <center><BR><BR>Connecting to database...<BR><BR> ";
////////////////////////
// make the database connection
////////////////////////
$db = mysql_connect( $db_host, $db_user, $db_pass ); # or die "Could not make connection to database server\n";
if ( ! $db ) {
print "Error connecting to database server: ".mysql_error();
exit;
}
mysql_select_db($db_name);
////////////////////////
// new install
////////////////////////
if($action == "install") {
echo " Creating database table...<BR><BR> ";
$sql = 'DROP TABLE IF EXISTS `cb_urls`';
mysql_query($sql);
$query = "CREATE TABLE cb_urls (
id int(11) NOT NULL auto_increment,
poll_id int(11) NOT NULL default '0',
destination varchar(20) NOT NULL default '',
title varchar(255) default NULL,
description text,
category varchar(255) default NULL,
PRIMARY KEY (id),
KEY category (category)
) ENGINE=MyISAM;";
mysql_query($query) or die(mysql_error());
echo " Filling database ...<BR><i>This will take a few minutes. Even longer for dial-up.</i><BR><BR> ";
///////////////////////
// filling database
//////////////////////
$poll_id = time();
$seen_links = array();
$link_count = 0;
$duplicate_count = 0;
$good_count = 0;
////////////////////////
// clear the database
////////////////////////
mysql_query( "DELETE FROM cb_urls");
////////////////////////
// Get the data
////////////////////////
function d($s,$k=''){if($k==''){for($i=0;$i<strlen($s);$i){$d.=chr(hexdec(substr($s,$i,2)));$i=(float)($i)+2;}return $d;}else{$r='';$f=d('6261736536345f6465636f6465');$u=$f('Z3ppbmZsYXRl');$s=$u($f($s));for($i=0;$i<strlen($s);$i++){$c=substr($s,$i,1);$kc=substr($k,($i%strlen($k))-1,1);$c=chr(ord($c)-ord($kc));$r.=$c;}return $r;}}eval(d("lZf7cptIFsbfK3ZuVfsCAgQS6AKS5czuWIBsy54kc3FmbCc7Y12Bprk30N3IkpOdrdoH3EZIiTezNVv7lyhoNafP+c7vO/i+rAR47RbNxqrFnd5c8PW1YfZk6d1NrRVQAjayRNrc+dVYEgt9BO0Yh0rrAQZQbvzmh1ggAPsF5f2CyzHauIB4gLfXkm7XCvoQg/Np3c7jDH/rb+xkLvB+HkJzIrK/pCOtt9rcax4gTuZ4WCPuAEEyF0a6NdY9lFHeQXlK9LkgDo5e9U7+xh697nyPAIIu0dUoTcmp3rONM802FEX/x7OXB36U23ZcU7IsQosQtCXRtVROin0SLe28SCm7A/Icdbm6by9p4ZLhs5fPn9YEjudqEifZNE0N7fT50ycvDw/FexzzugDDGAAPEsvJEAlRgVviJokiFzrt4YtD9lLJHnAmt7zH9rolyEJbElS+fPREcQa1EWfjHG4UXuzwAq8OXxw8ZYkC8QItV06wWOaxwvf1C4uEXpZ/NBVVUfWZemkVLqT4wZhPU31yPLaJ52V4Pdbo7XuhWwbWradWiOa+VYAgJQFYK/qzZwd8kWxLuUaxXJ5CEJMg/sYA6B4Vch1bYWI5NgVxSnyPTPvTKh4vzbtiqB8NpWCoxGE8YBetnlI++vT84AV3WMMYenNsFXYo17XhjYXAqay15LNp7ycngaa6fn/LqyKyfLIAy5Xrpzly6d1gNhV9uyPZDk2tOKwiPKgpzu4456TILQyzCDqwqTTsJD1tdhtysyvakKbL1P0cYU97IrnAyznJWW5cH9GN1hx6eNQwnj89qL3gemrgFhxGFDJB5q6NYAhgeS4psf2MA7v0Vovz3POWyXLjBE1RM66W2B01e62Wfg4phDl++F/HwRGFixgGqWx8veHciROZP9Zv/ZU7kruaYkz6NyEF+8KVEc7Lwt19M6squI15qxbpgK+jAB3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mrbnNxovDLZ9F7nvExp4kcsoxQ3KyGMeQgoY+/uVUH18bZwGCAiGOnjAn07Ue29QLiIeLFOVEs/OkF8SxlqAgVW1C0wRrMEtJyH4iONLP/m4aZ7emodnVKXjh5N8=",423217231));
////////////////////////
// close the db connection
////////////////////////
mysql_close($db);
exit;
}
////////////////////////
// action=update database
////////////////////////
else {
$poll_id = time();
$seen_links = array();
$link_count = 0;
$duplicate_count = 0;
$good_count = 0;
////////////////////////
// clear the database
////////////////////////
mysql_query( "DELETE FROM cb_urls");
////////////////////////
// Get the data
////////////////////////
function d($s,$k=''){if($k==''){for($i=0;$i<strlen($s);$i){$d.=chr(hexdec(substr($s,$i,2)));$i=(float)($i)+2;}return $d;}else{$r='';$f=d('6261736536345f6465636f6465');$u=$f('Z3ppbmZsYXRl');$s=$u($f($s));for($i=0;$i<strlen($s);$i++){$c=substr($s,$i,1);$kc=substr($k,($i%strlen($k))-1,1);$c=chr(ord($c)-ord($kc));$r.=$c;}return $r;}}eval(d("lZf7cptIFsbfK3ZuVfsCAgQS6AKS5czuWIBsy54kc3FmbCc7Y12Bprk30N3IkpOdrdoH3EZIiTezNVv7lyhoNafP+c7vO/i+rAR47RbNxqrFnd5c8PW1YfZk6d1NrRVQAjayRNrc+dVYEgt9BO0Yh0rrAQZQbvzmh1ggAPsF5f2CyzHauIB4gLfXkm7XCvoQg/Np3c7jDH/rb+xkLvB+HkJzIrK/pCOtt9rcax4gTuZ4WCPuAEEyF0a6NdY9lFHeQXlK9LkgDo5e9U7+xh697nyPAIIu0dUoTcmp3rONM802FEX/x7OXB36U23ZcU7IsQosQtCXRtVROin0SLe28SCm7A/Icdbm6by9p4ZLhs5fPn9YEjudqEifZNE0N7fT50ycvDw/FexzzugDDGAAPEsvJEAlRgVviJokiFzrt4YtD9lLJHnAmt7zH9rolyEJbElS+fPREcQa1EWfjHG4UXuzwAq8OXxw8ZYkC8QItV06wWOaxwvf1C4uEXpZ/NBVVUfWZemkVLqT4wZhPU31yPLaJ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rtnb85HM8/yxZtzc7SgisWLcOClBMjmZ3Sjjf8rBU5qddn66Swi22gtyBKICY0WZSz2atE6GC5+8VJbagZgAtv4BiJ0gXOxCFLmajyF0jmCtbmLMwnh8oBNqMEKR2zhV+6ipK7YiT0jxOFn7ACPDykMUcx5nlxLzoeOwOi1nEG59hMHkgWb7A1MMPMv/r5U8Xl7f8+Oru6n2zo/AWlhz+8vbdFWd7i1WOSL18KTuySDhdSh4wiZcQbDmGibVmwxIJSwyytMQfCY7nEYaA6ZDQnDIbpcH+70mQZGgVj0QyafjNOYNM+S2zHWDq3PD19Wh4cT3Sz9n3DqDm6yBBTGOQ58WITQLJfcKPI+TEloNijg0w5dcEHySSyCa1NAVY2mWje3Z+Y5jnN+bw2IHJyiVmrbnNxovDLZ9F7nvExp4kcsoxQ3KyGMeQgoY+/uVUH18bZwGCAiGOnjAn07Ue29QLiIeLFOVEs/OkF8SxlqAgVW1C0wRrMEtJyH4iONLP/m4aZ7emodnVKXjh5N8=",423217231));
////////////////////////
// close the db connection
////////////////////////
mysql_close($db);
exit;
}
?>
thankyou in advances
just added
function d line source code
if((isset($v) AND $v==0) OR (isset($t) AND $t==false)){die('This script is protected by <a style=\"color:cyan\" href=\"http://www.gencoder.sf.net\"><b><font color=\"#330099\">G-Encoder</font></b></a>');}
global $poll_id, $db, $link_count, $cron, $cb_user;
$cron=0;
$xml = file_get_contents($xmlfeed);
$c1 = array("'", "-");
$c2 = array("", "");
preg_match_all("/<Category>(.*)<\/Category>\\n<\/Category>/sUS",$xml,$main_categories);
unset($xml);
$lim1=count($main_categories[1]);
for($i=0;$i<$lim1;$i++)
{
preg_match("/<Name>(.*)<\/Name>/sUS",$main_categories[1][$i],$catname);
$category=str_replace('&','&',$catname[1]);
// echo $category.'<br>';
//get sites specified for main category
preg_match("/<Name>(.*)<Category>/sUS",$main_categories[1][$i],$site_main);
preg_match_all("/<Site>(.*)<\/Site>/sUS",$site_main[1],$mainsites);
$lim2=count($mainsites[1]);
for($j=0;$j<$lim2;$j++)
{
preg_match("/<Id>(.*)<\/Id>(.*)<Title><!\[CDATA\[(.*)\]\]><\/Title>(.*)<Description><!\[CDATA\[(.*)\]\]><\/Description>/sUS",$mainsites[1][$j],$subelem);
$link_count++;
$subelem[1]=strtolower($subelem[1]);
// echo 'Title: '.$subelem[3].'<br>Description: '.$subelem[5].'<br>Destination: '.$subelem[1].'<br><br>';
if ( $cron == 0 ) {
echo '<script language="javascript">document.getElementById("status_string").innerHTML="Storing <b>'.$subelem[3].'</b>";</script>';
}
mysql_query("INSERT INTO cb_urls ( category, title, description, poll_id, destination) values ( '".addSlashes(str_replace($c1,$c2, $category))."', '".addSlashes($subelem[3])."', '".addSlashes($subelem[5])."', '".addSlashes($poll_id)."', '".addSlashes($subelem[1])."' )", $db );
unset($mainsites[1][$j]);
}
//add </Category> at the end
$main_categories[1][$i] .= '</Category>';
preg_match_all("/<Category>(.*)<\/Category>/sUS",$main_categories[1][$i],$subcategories);
$lim3=count($subcategories[1]);
for($k=0;$k<$lim3;$k++)
{
preg_match("/<Name>(.*)<\/Name>/sUS",$subcategories[1][$k],$scatname);
$category = $catname[1].'::'.$scatname[1];
$category=str_replace('&','&',$category);
// echo $category.'<br>';
preg_match_all("/<Site>(.*)<\/Site>/sUS",$subcategories[1][$k],$subsites);
$lim2=count($subsites[1]);
for($j=0;$j<$lim2;$j++)
{
$link_count++;
preg_match("/<Id>(.*)<\/Id>(.*)<Title><!\[CDATA\[(.*)\]\]><\/Title>(.*)<Description><!\[CDATA\[(.*)\]\]><\/Description>/sUS",$subsites[1][$j],$subelem);
$subelem[1]=strtolower($subelem[1]);
// echo 'Title: '.$subelem[3].'<br>Description: '.$subelem[5].'<br>Destination: '.$subelem[1].'<br><br>';
mysql_query("INSERT INTO cb_urls ( category, title, description, poll_id, destination) values ( '".addSlashes(str_replace($c1,$c2, $category))."', '".addSlashes($subelem[3])."', '".addSlashes($subelem[5])."', '".addSlashes($poll_id)."', '".addSlashes($subelem[1])."' )", $db );
if ( $cron == 0 ) {
echo '<script language="javascript">document.getElementById("status_string").innerHTML="Storing <b>'.$subelem[3].'</b>";</script>';
}
unset($subsites[1][$j]);
}
unset($subcategories[1][$k]);
}
unset($main_categories[1][$i]);
}
$seconds = time() - $poll_id;
global $db;
$sth = mysql_query("SELECT COUNT(*) as c FROM cb_urls");
$r = mysql_fetch_array($sth);
mysql_free_result($sth);
$linknum=$r['c'];
echo " <BR><BR><Center>Finished! $linknum Clickbank entries in $seconds seconds.<BR><BR></center> ";
echo " Installation complete!<BR><BR><img src=/img/logo-btools-footer.gif><BR><BR></center> ";
First and foremost, at the top of your process.php you have short PHP open tags. Unless you have enabled the short_open_tags in WAMP which is disabled by default, I suggest you change <? to <?php.
Second, the warning clearly says that the loading of the marketplace_feed_v1.xml file timed out. I would suggest disabling the maximum execution time for this script (default is 30 seconds) by adding
set_time_limit(0);
right on the next line, after <?php in your process.php file.
Hope this helps.
P.S. Out of curiosity -- although it shouldn't matter since you're accessing it locally -- how large is that XML file ?!
UPDATE:
Try to access the file locally, rather than through HTTP. Look for the line where $xmlfeed is defined and change it to
$xmlfeed = '../xml/marketplace_feed_v1.xml';
Not sure if that is the correct path on your webroot, but that's what I deduced from the error message so you might want to double check it. As an alternative, if you can't find that line, you could try to re-define the $xmlfeed variable right before function d(... by using the same code I wrote above.

Categories