-
Posts
96 -
Joined
-
Last visited
Posts posted by frobak
-
-
yeah sorry i solved it, my db include file was wrong, so it was looking at my old server and database!
-
can you mark this as solved, im stupid!
-
yes ive just copied the above table structure direct from phpmyadmin?
-
but heres the table, copied directly from mysql? the columns there?
customer_id int(15) No
company_name varchar(20) Yes NULL
address_line1 varchar(20) Yes NULL
address_line2 varchar(20) Yes NULL
City varchar(20) Yes NULL
postcode varchar( Yes NULL
contact_name varchar(25) Yes NULL
emailaddress varchar(25) Yes NULL
webaddress varchar(25) Yes NULL
phone varchar(20) Yes NULL
fax varchar(20) Yes NULL
mobile varchar(20) Yes NULL
-
thank but this still doesnt work, i am still getting the same error
Unknown column 'company_name' in 'field list'
surely this is something really simple?
-
CREATE TABLE customers(
customer_id INT(15),
company_name VARCHAR(20),
address_line1 VARCHAR(20),
address_line2 VARCHAR(20),
City VARCHAR(20),
postcode VARCHAR(,
contact_name VARCHAR(25),
emailaddress VARCHAR(25),
webaddress VARCHAR(25),
phone VARCHAR(20),
fax VARCHAR(20),
mobile VARCHAR(20));
-
Hi i have this simple php insert statement, but whatever i try it says:
Unknown column 'company_name' in 'field list'
all the column names are the same in my html documnt, this statement here and in my database table. Thsi is really simple and driving me mad
<?
if($_POST['add']) {
include("includes/db_connect.inc.php");
$sql = ("INSERT INTO customers
(company_name, address_line1, address_line2, city, postcode, contact_name, emailaddress, webaddress, phone, fax, mobile) VALUES
('$_POST[company_name]', '$_POST[address_line1]', '$_POST[address_line2]', '$_POST[city]', '$_POST[postcode]', '$_POST[contact_name]',
'$_POST[emailaddress]', '$_POST[webaddress]', '$_POST[phone]', '$_POST[fax]', '$_POST[mobile]')");
$result = @mysql_query($sql,$connection) or die(mysql_error());
}
?>
any help much appreciated.
cheers
-
Thsi file open a dialog box to open the index page and not the mp3 file.
ANy idea why this happen?
<?php
include '../functions/db_connect.inc.php';
$sql = ("INSERT INTO downloadcount
(downloadid) VALUES
('$_REQUEST[downloadreq]')");
$result = @mysql_query($sql,$connection) or die(mysql_error());
$filename = "milli.mp3";
$myFile = "/httpdocs/djneils/mixes/milli.mp3";
$mm_type="application/octet-stream";
header("Cache-Control: public, must-revalidate");
header("Pragma: hack"); // WTF? oh well, it works...
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($myFile)) );
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary\n");
readfile($myFile);
?>
-
Ive tried this but it opens the index page and not the mp3?
<?php
include '../functions/db_connect.inc.php';
$sql = ("INSERT INTO downloadcount
(downloadid) VALUES
('$_REQUEST[downloadreq]')");
$result = @mysql_query($sql,$connection) or die(mysql_error());
$filename = "milli.mp3";
$myFile = "/mixes/milli.mp3";
$mm_type="application/octet-stream";
header("Cache-Control: public, must-revalidate");
header("Pragma: hack"); // WTF? oh well, it works...
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($myFile)) );
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Transfer-Encoding: binary\n");
readfile($myFile);
header('Location: ../index.php');
?>
-
Hi
Im making a real simple audio download page with a counter on each download, nothing fancy, just need the job done. So the basics are i want a user to click on a link, and i want it to update a database table, which works fine, but i want it to also open the audio file for download, which i cant get to work.
The script im trying to run is as follows:
<?php
include '../functions/db_connect.inc.php';
$sql = ("INSERT INTO downloadcount
(downloadid) VALUES
('$_REQUEST[downloadreq]')");
$result = @mysql_query($sql,$connection) or die(mysql_error());
$handle = fopen("../mixes/milli.mp3", "r"); <----------this not working??????????
header('Location: ../index.php');
?>
Am i barking up the wrong tree? or can i get this to work? any help appreciated.
cheers
fro
-
-
$sql = "UPDATE customers SET
cust_firstname = '$_POST[cust_firstname]',
cust_surname = '$_POST[cust_surname]',
house_no = '$_POST[house_no]',
streetname = '$_POST[streetname]',
postcode = '$_POST[postcode]',
emailaddress = '$_POST[emailaddress]',
homephone = '$_POST[homephone]',
mobphone = '$_POST[mobphone]',
WHERE username = {$_SESSION['username']}";
why am i being told i have an sql error near my where clause?
-
-
This doesnt work though?
$sql = "SELECT * FROM customers WHERE userid= $_SESSION['userid']";
it says: Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Inetpub\vhosts\frobak.co.uk\httpdocs\pages\show_cust_details.php on line 18
-
excellent, cheers for your help guys!
-
So how would i use the variable say to update a table, ie UPDATE customers WHERE userid = ?????????
-
session_start();
if (isset($_POST['userid']) && isset($_POST['password'])) {
$table_name = "customers";
include '../functions/db_connect.inc.php';
$userid = $_POST['userid'];
$password = $_POST['password'];
// check if the user id and password combination exist in database
$sql = "SELECT * FROM customers WHERE userid= '$userid'";
$result = mysql_query($sql)
or die('Query failed. ' . mysql_error());
if (mysql_num_rows($result) == 1) {
// the user id and password match,
// set the session
$_SESSION['db_is_logged_in'] = true;
$_SESSION[$userid] = $userid;
// after login we move to the main page
header('Location: ../pages/control_panel.php?$userid;');
exit;
} else {
$errorMessage = 'Sorry, wrong user id / password';
}
}
How do i get the posted value of userid to $_SESSION[$userid]?
and then how do i call it in another script?
-
Hi, im making a simple user control panel, the user logs in by entering a user id and passowrd, which is checked in a mysql database before displaying the control panel. from this control panel i want the user to be able to change user details, sign up for bits, register for stuff etc. When the user clicks on a link to update their user details for example, i want to use the user id originally posted with the login form.
Is it possible to register a session variable from a posted field in a form, and then retreive and use throughout my control panel? Ive tried many different ways to pass variables but its not happening?
Any ideas?
using fopen to write a sql query
in PHP Coding Help
Posted
Hi
Im trying to write a very simple script that creates a php file that logs a download in a database.
Basically, the user will upload some audio and I want to use fopen to automatically create a download counter. I get the file created ok, but my $sql, $result & $connection are stripped and not written, so the queries wont run.
Is there anyway to escape this, so it writes the variables.
Heres the code:
<?php
$file = "downloads/pbz99.php";
$open = fopen($file, "w+");
fwrite($open,"<?php include ('functions/db_fws_connect.inc.php');
$sql = 'INSERT INTO `frobakco_fwsapps`.`downloadcount` (`downloadcountid`, `downloadid`) VALUES (NULL, '99')';
$result = @mysql_query($sql,$connection) or die(mysql_error());?>
<html><head><title>DJ Neil S audio download page</title></head><body><a href='../mixes/.$filename.mp3'></a></body></html>");
?>
any ideas