Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




C Function In Php To Do Printing Of Data Taken From Mysql?


how to call C function in php to do printing of data taken from mysql? I have written a php personnel program and I need to printing by Browser (user) over the internet.

I understand PHP cannot to real printing --correct me if I am wrong -- ( good for paperless concept). But I really need to doing for some integration of C programming- at the I will learn C programming myself via text.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Printing Data?
why the following code isn't printing any data from the selected database. PHP Code:

Printing And Outputting Data
I have looked through the online manual and haven't found a way to format data from either a form or
data that was retrieved from a database. I would like to provide an "elegant" printout to my users
and I heard (when I didn't need to use it) somewhere that such a function existed.

....or is HTML the way to go using Javascript?

Variable From Function Not Printing
I have a function that gets the information from the logged in user from a database. I use this in another function to print this information but this doesn't work. This prints the firstname of the user, it should but it doens't. PHP Code:

Printing POST Data In Netscape.
I've got a site that generates all sorts of reports on the fly both by including text files with content and pulling stuff from a database all based on user selections from a form. Needless to say, users HAVE to be able to print these reports for this thing to have any applicable use whatsoever.

My Problem: Netscape will not print these pages. The error is: Data Missing.

This document resulted from a POST operation and has expired from the cache. If you wish you can repost the form data to recreate the document by pressing the reload button.

It would seem the solution lies in forcing Netscape to cache these pages. This seems ridiculous to me as these will always be dynamically generated pages - but whatever, the "common sense" of Netscape eludes me often.

Printing An Array Minus Certain Data?
I have a list of email addresses in a variable. There could be 5, there could be 500, and they're all mixed around in no certain order..

$mailing_list = "mail1@mail.net, mail2@mail.net, mail3@mail.net, mail4@mail.net";
$arr = explode(", ",$mailing_list);

is there a way to print $arr, specifically leaving out one of the email addresses? Say if I wanted to print everything in the $mailing_list contents EXCEPT mail2@mail.net, how would I go about it?

Printing From A Mysql Database
I am a newbie to PHP but have been set a task to use the MYSQL database I have created and be able to print information from it using PHP but the problem is I amnot sure where to start.

MySQL Result Printing In For-loop
I have a script that count and print every week in a selected year. Now i want to connect this to the returned result from a MySQL query. Code to explain what I am trying to accomplish: Code:

Printing Pdf Documment From Mysql Table
I am trying to print a catalogue from a mysql table. I want it to print 6 products per page and then automaticcaly do the next page, until it is completed is this possible The first bit of code is the code to print the catelog, and the second is the include file that it uses:

How Do I Prevent Mysql From Printing Redundant Records?
I have a very urgent question. I am using php and mysql.
Say I have a database full of names and email addresses. I want to do a query that when you type in the name or partial name, mysql will only show a name once, even if it is in the database 200 times. Then I want to click on that name and have mysql show the 200 email addresses associated with that name (which I know how to do). See below:

Printing Mysql Auto-increment Key Value On A Form
i need to print off the auto increment key value on a form. How does the syntax go to accompish this. Field name is rrn. Output only.

Comparing Form Data To Mysql Data
Im interested in building a script that would take form data, a variable like an address, and compare it with a known address in a mysql table (called addresses), then if there is a match log the address information in a separate table called (addresslog), and return the visitor to a certain page. If there is no match between the address entered in the form and known addresses then the information is still logged into the addresslog database but the visitor will be sent to a different page.

I'm still new to this, and am working through the logic and the syntax, but I believe I'm close. It's still not working, I have all of the proper tables, maybe I'm way off with the coding so I thought I would seek out some expert advice. Here's the entire script with as much explanation as I could give. PHP Code:

Function To Simplify Data
I seem to be writing the following a lot (this is just one of many
examples):

$sql = 'SELECT `ID`, `NAM` FROM HEP ORDER BY `ID`'
$query = mysql_query($sql);
while($row = mysql_fetch_row($query)) {
$ei = $row[0];
$en = $row[1];
$content .= '<li><a href="test.php?i='.$data("ID").......
}

I want to write a function like this

function getdata($sql) {
$query = mysql_query($sql);
while($row = mysql_fetch_row($query)) {
$v[$i][{name of first column in select query (e.g. ID)}] = $row[0];
$v[$i][{name of first column in select query (e.g. NAM)}] = $row[1];
$i++;
}

Then, in my code I can write something like

$sql = 'SELECT `ID`, `NAM` FROM HEP ORDER BY `ID`'
$data = getdata($sql)
while(loop through array - i have no idea how you do this - but can look it
up) {
$content .= '<li><a href="test.php?i='.$data("ID").......
}

What is the most efficient way to write such a function?

Function To Sanitize Data
I am trying to sanitize $_POST and $_GET variables globally to stop things like sql injection. I have not really been able to get it to work. I have a nice way to replace the things I don't want to be posted but I am trying to do this globally and not one value at a time. Code:

Display Binary Data From A Function
I am trying to retrieve binary data (a JPEG or GIF for this example) from a function and display the data on a seperate page. The function is held in a file called getdata2.php and looks like this. PHP Code:

Type Of Data Returned By A Function
I've noticed that some code analyzers comment that the type of data
returned by my functions is "unknown" in the following syntax:

function fnFooBar($aryParameters) {
$bRetVal = True;
return $bRetVal;
}

I *think* I can specify that by doing something like this:

function fnFooBar($aryParameters) bool {
$bRetVal = true;
return $bRetVal;
}

Is this correct?
If so, is there a performance gain, or is it just clean coding?

What Function Do I Use For Data Encyrption And Decryption ?
What function do i use for data encyrption and decryption ?

Offline Function, Variables With No Data In Them
I've been trying to figure this out for a while, the function returns a result but its not the result l want.  I've tried to debug the function and it seems that $groupid and $status aren't being set as when l echo'ed them out they both had no data in them.

If l set the variables data inside the function the code executes perfectly, so l cant understand why it isnt working.

What l need the code to do is check to see if the member logging in is an admin (group id or a root admin (group id 9) and if the game is offline (status 1) to only only admin and root admin.  However is the game is offline but status is set to 2, then only root admin can login.  If the game is offline, normal members are not allowed to login.

Clearance is there so l can check to see whether or not to allow them pass or stop them from logging in. Code:

Fread And Fseek Function Produces No Data
I'm still making my way through the "Making Use of PHP" book but have come across another example that isn't working for me. The following code is supposed to extract the content of a file beginning on the second line. It's worked in the examples up to now (such as using fgets and feof). I've checked my code against the author's and can find no difference. Can anyone see anything wrong here? (The page displays totally blank in the browser.)

<?php
$myfile = "testfile.txt";
$openfile = fopen ($myfile, "r") or die ("Couldn't open the file.");
$filesize = filesize($myfile);
fseek ($openfile, 8);
$sp_data = fread ($openfile, (filesize - 8));
print $sp_data;
?>

Get Mysql Data
I have a database, and what I want is for people to be able to put in a number from the database and it pull up their info and put into a form, so then they can just add to what they already had.

Data And Mysql
I want column XY be unique so:

 xy | gg | zz | ee
 12 | df | df | fd
 13 | df | df | fd

I want to enter more data but it might enter 12 | df | df | fd again so i would get an error. How would i prevent that without having to loop threw the whole database checking for that entry?

Getting Data With MYSQL
IM interested in knowing of any better ways of retreiving data from mysql and if my current way is safe as i request it over all my scripts.

$information = mysql_fetch_row(mysql_query("SELECT `row` FROM `table` WHERE `username` = 'Memphis'"));

print("$information[0]");

Getting Data From Mysql To Put Into Form
i am trying to set up a page that will allow the user to select a name from a list. The details of this name(ie, last name,address, job etc) are then taken from a database and put into a form. If any changes are needed the user makes them then presses a submit to update the database.

I can get the information out of the database and into the form fields but i have one small problem...

In the address field i can only get the first part of the address...
ie

if the address is 123 Sample Street

only 123 gets put into the form field.

How do i get the rest of the address to appear?

i am sure it is quite simple but cant quite put my finger on the answer!

my code is:

Address: <input type="Text" name="address" value =<?php echo $myrow["address"] ?>><br>

where $myrow is the array holding the results from my database query.

Any help would be appreciated!

Importing Data Into Mysql
I'm starting working on a new project where I'll have to allow users to upload and import tab-formatted text files into the db. Should I use the LOAD DATA INFILE from PHP or write a custom procedure?

Problems Getting Data From Mysql
I've written a scipt for breaking articles into several pages and it seem to be working fine but I can't get them from the database. PHP Code:

Mysql Data Doubled
I'm facing a problem with mysql and don't know what is the problem as I still learn php/mysql. I use a simple script to upload some images and a file. Everything runs very well untill I choose a name for a file that is allready in the database, the new data just overwrite the old one which gives me allmost two identical results in the db, allmost because only the path to the uploaded images are changed, the comments, name, creation data stay different.

Here is my db:

Fragment Data In Mysql
i just wondering if there is update and delete,indert query activity in database.Which make it slow, how do we know if this thing happened and how to solve it?

Php, MySQL, And Binary Data
I'm trying to upload binary data and store it in mySQL as a mediumblob. Since there's always the possibility of quotes (along with any other character) within the binary stream, I assume I need to do something along the lines of AddSlashes to ensure that the sql request won't fail. The trouble is I'm finding that StripSlashes is blowing away the string when I retrieve it. I've tried rolling my own encoding, but ereg_replace("'", "'", $string) is truncating my data, apparantly at the first null character it hits.

So: what's a solution for safely getting binary data into mysql via php?

Load Data Into MySQL
I have a table in which its primary key is auto-incremented. Yet, when
I try to load data using load data infile, this column will not
auto-increment. I am leaving that column blank in my file to be
uploaded, yet it fills this value in with a zero for all records.

Should I be using a php script to load this file? Why isnt this
updating correctly?

How To Get The Data From MySQL Into A PHP Template
I am creating a template page that will have the same subsections on each page. Each subsection is supposed to get information from a MySQL database. The subsections are: Location, Host, Cost, Travel, Age Restrictions, Work Project, Ministry Description. The variables are $locationID (primary key),$location, $host, $cost, $travel, $agerestrictions, $project, $ministry.

Now. My question is so simple. How do I get information from the database to the template based on the link (location) that the user chooses. I'm sure an "mysql_connect();" is involved, but I'm not sure how to pass the selection to the database and get the information back that I need to plug into the template.

Pull Data Out Off Mysql
I am making a database using mysql where i have 2 tables, one for car manufacturers and one for car models.I've already done that. I have made a php page where i have 2 drop down menus.

The first menu shows car makers(manufacturers) and the 2nd nothing. Now when a user opens the 1st menu and selects a maker , the 2nd automatically fills up with models from that car maker only and it gets its information from the database.That is every time i decide to add a new model to my database the 2nd menu (if selected) must go and search the database for all the models for that maker and show them. Code:

PHP/MySQL Moving Row Data Help!
I have a table with about 600 rows of data in it. I'm trying to figure out how to move row 600 up to row 300. But I can't seem to figure out how.

Can't Get Data To Post To Mysql
What am I doing wrong with this code? I cant get my field values to post to my database....

Getting Data From A Specific Row With Mysql
I'm makin a member's area on my site with sessions, as they log in correctly the username is stored as $_SESSION['user']

what I can't work out, is how to access my table and extract data from just the row that has that username, eg

SELECT * FROM table WHERE username=$_SESSION['user']

as I'm trying to make the users be able to edit profile, upload pics etc... any idea what I'm doing wrong?

Data Not Being Retrieved From Mysql
i'm workin on an app that will allow a client to update news items themselves without needing to ftp or know sql. Just in the process of setting it all up, i've got a page that retrieves the title of the news item(referred to as a slug in this context), the date it was last updated and an id for the item. the title itself becomes a link to a page that contains the full content of the item by appending the id to the url and calling that id from the database.

The first page (news.php) works fine, it retrieves what it needs to and sends the user to the next page (story.php) when they click the link. However, for some reason the exception ("That press release could not be located in our database") is being displayed each time and not the content of the news story. i'm stumpted as to why this is the case as the fact that news.php is working shows there is data in there and that my connection script (db.php) is working. PHP Code:

MySQL Loosing Data?
I am in desperate need of some help, recently data in our mySQL has been removing itself, rows themselves have not been delted buit just edit and row information has been wiped and left blank.

We have checked the logs and it does not appear to be anyone doing it as there are no UPDATE/EDIT or DELETES being found in the logs. Any advice has this happened to anyone else before?

MySQL Data Extraction
Using the following code (with MySQL user and password removed , the data extracts correctly, but the carriage return () doesnt seem to be working, the data is just displayed across the screen. Code:

Web Form Data To MySQL DB
I pulled this script off of an MySQL article from the MySQL website itself. I adjusted it to my needs and I could connect to the DB, it could find the proper table, but it doesn't enter the data into the database table. So I pulled the original script off in hand, created the DB and table it had listed and still the same problem... it can't connect. Here's the script: Code:

Excel Data To Mysql
Is this possible to transfer excel data to mysql database?

Load Data Into MySQL
I have a table in which its primary key is auto-incremented. Yet, when
I try to load data using load data infile, this column will not
auto-increment. I am leaving that column blank in my file to be
uploaded, yet it fills this value in with a zero for all records.

Should I be using a php script to load this file? Why isnt this
updating correctly?

Mysql Data Copy
I have mysql table1 on my local comp. It looks something like this.

----------------------------------------------------------------------------
-
broj_tel | poruka | sifra |
grad | id |
----------------------------------------------------------------------------
|
+385912701600 0 Zprod rijeka
5 |
----------------------------------------------------------------------------
|
+385912701699 1 kprod crikvenica
3 |
----------------------------------------------------------------------------
-

On the remote server (web hosting) i have table2 looking something like
this:

----------------------------------------------------------------------------
---------
id_independant | Name | Surname | broj_tel
| poruka |
----------------------------------------------------------------------------
--------- |
11122 Martin Johnes
+385912701600 1 |
----------------------------------------------------------------------------
----------|
16163 John Doe
+385912701699 0 |
----------------------------------------------------------------------------
----------

Question: I nead periodicly (some scheduler, my concern) to make something
like this:

select * from table1
insert into table2 (poruka) whare table1.broj_tel = table2.broj_tel

To read the data from table1, and inserts into table2 coloumn poruka whare
tabel1.broj_tel i equal table2.broj_tel
Problem is that the data is in diferent databases.

MySQL Data Expiration
Well I have to make a "job search" for a temperary staffing company. What i have to do is make a control panel for staffing coordinators that will allow them to post jobs. That is the easy part. I have to set an option on the form to make this automaticly expire after a certian amount of days. Like if the job starts next week, I'll have it expire in 7 days.

Retrieve Data From Mysql
i have this code:
<?php
// Connects to your Database
mysql_connect("localhost") or die(mysql_error());
mysql_select_db("eurialz") or die(mysql_error());

//This code runs if the form has been submitted
if (isset($_POST['submit'])) {

//This makes sure they did not leave any fields blank
if (!$_POST['username'] | !$_POST['pass'] | !$_POST['pass2'] | !
$_POST['name'] | !$_POST['gender'] ) {
header("location: register.php?error=yes");
exit;}

// checks if the username is in use
if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);}
$usercheck = $_POST['username'];
$check = mysql_query("SELECT username FROM users WHERE username =
'$usercheck'")
or die(mysql_error());
$check2 = mysql_num_rows($check);

//if the name exists it gives an error
if ($check2 != 0) {

header("location: register.php?error2=yes");
exit;

}

// this makes sure both passwords entered match
if ($_POST['pass'] != $_POST['pass2']) {
header("location: register.php?error3=yes");
exit;
}

// here we encrypt the password and add slashes if needed
$_POST['pass'] = md5($_POST['pass']);
if (!get_magic_quotes_gpc()) {
$_POST['pass'] = addslashes($_POST['pass']);
$_POST['username'] = addslashes($_POST['username']);
}

// now we insert it into the database
$insert = "INSERT INTO users (username, password, name, gender,
dobmonth, dobday, dobyear)
VALUES ('".$_POST['username']."', '".$_POST['pass']."', '".
$_POST['name']."', '".$_POST['gender']."', '".$_POST['dobmonth']."',
'".$_POST['dobday']."', '".$_POST['dobyear']."')";
$add_member = mysql_query($insert);
header("Location: newmember.php");
?>

Autofill Data Using Php/mysql
I have searched google and had no luck. I am trying to create a form
where user enter postcode and address box fills up automatically from
the back-end db.

can anyone guide me on how to do this. An example would be helpful or
maybe few links to related tutorial.

Loops, Php And Mysql Data
I am writing a profile creator script where a user gets
a URL invite in their mail in the form of;

http://domain.com/profile-create.ph...kd98jadf098asdf

Things are working well except for a small annoyance in which someone
might have a solution to.

In the event that someone accesses profile-create.php without an
access_code the script generates a warning. If there is an access_code
that matches the access code entered in the MySQL database then they
are directed to the profile creation page. My problem is;

If someone accesses profile-create.php with an access_code but it
doesn't match any entries in the database I would like to generate a
warning.

When I try to do this with an else statement it produces an error for
every access code listed in the database which isn't the correct one,
so I could end up with a successful profile creation page with a bunch
of errors.

I've played with break and pattern matching but no results. Here is
the script below.
[color=blue]
>---------------------------------------------------------------<[/color]

<?php

$access_code = $_GET['access_code'];

if ($access_code) {

echo db_connect();

$result = mysql_query('SELECT random_link FROM invites');

while ($row = mysql_fetch_array($result, MYSQL_NUM)) {

$random_link_db = $row[0];

if ($random_link_db == $access_code) {
echo profile_creator_page();
}

// Would like to insert an error warning here

}
}

else {
echo "Error!"
}

function profile_creator_page() {
echo "All's well!";
}

?>
[color=blue]
>---------------------------------------------------------------<[/color]

Data From MySQL Into CSV For Excel?
I've a survey form that I need to get data from and put into a mySQL
database.
Easy, can do it eyes closed.

But, then I need to be able to take that same information and convert
it (either directly or pulling it back out from the database) into a
CSV (or any file for that matter) that can be easily imported, added
into an existing Excel database.

I've no idea how to do that. (I can query the database, that I can do,
and create recordsets, AND create text files, but I've never created a
CSV file before.)

Is there a source, a good Web site for example, that explains that
kind of process pretty well?

Help Req. Reading Data From MySQL Db With PHP
I have PHP code (below) which reads data from a MySQL format database. The
problem I am having is trying to find out when the last ID entry was made.
When the script is executed, the $gbID is supposed to be read and display
the last entered ID number ($How_many_entries) - the ID number is entered /
updated automatically in another PHP script which deals with data entry to
the database.

But instead of displaying the result of the query, it displays the ID
number ($How_many_entries) as "Resource id #4", and looking around the
search engines, no page makes particular sense as to what I've done wrong.

Does anyone know how to get the $gbID number from the database and into
$How_many_entries so I can perform some math work on it?

<?
$DatabaseName = "Guestbook";
$table_to_look_for = "entries";

$connection = @mysql_connect("localhost") or die("<B>Could not connect to
MySQL: </B>".mysql_error());

mysql_select_db($DatabaseName);

// get all tables in the database
$result = @mysql_list_tables ("DatabaseName");

// Display database entries in reverse order (remove 'DESC' to have forward
display of results)
$sql = "SELECT gbID, gbDate, gbIP, gbURL, gbName, gbComment FROM
$table_to_look_for ORDER BY gbid DESC";

$result = @mysql_query($sql, $connection) or die("<B>Problem reading from
database: </B>".mysql_error());

while ($row = mysql_fetch_array($result))
{
$gbID = $row['gbID'];
$gbDate = gmstrftime('%A %d %B %Y at $T',strtotime($row['gbDate']));
$gbURL = $row['gbURL'];
$gbName = $row['gbName'];
$gbComment = nl2br($row['gbComment']);

$display_entry .= "$gbID:<BR><B>Posted on: </B>$gbDate &nbsp;<B>IP:
</B>Logged<BR><B>Posted by: </B>$gbName<BR><B>Personal website:
</B>$gbURL<BR><B>Comment: </B>$gbComment<BR><BR>";
}

$sql = "SELECT last_insert_id($gbID) FROM $table_to_look_for";
$How_many_entries = @mysql_query($sql, $connection);

// $How_many_entries = $How_many_entries / 5;
echo "Entries: $How_many_entries<BR>";

etc....

Inserting Data Into Mysql
I have a simple loop
include '../php_library/connect.php'
include '../php_library/opendb.php'

$conn=mysql_connect($host,$dbuser,$dbpass) or die ('Error');
mysql_select_db($dbname);
//Open the file
$fp = fopen($src,"r");
//for each line in the file
while ($row=fgetcsv($fp,10000,'')) { //Get line
$sql_insert="INSERT INTO ...";
if (!mysql_query($sql_insert,$conn)){
OutputError($sql_insert,$mysql_error());
$FailedCount++;
}
else {$InsertCount++;}
}

It works fine for the first couple of hundred or so rows but the stops -
no errors, it just stops mid-loop.

I'm guessing some sort of buffer problem (needs flushing?) but it is a
guess.

I'm running this all locally - XP, Apache2, PHP5, mySQL 4.1

Mysql Data Links...
I have a mysql query... The data i get out of the query is listed in a table.
I want each row(or the first column on each row) to be a link that links directly to a "edit" page for the row. How do i do that? My main problem is to make one unique link for each row that actually links to something.

Using Php To Insert Data Into MYSQL
I just whipped up this script for part of our project. Do the insert statements and script look legit in order to make php insert data into my mysql tables which I already created in previous scripts? Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved