php-general Digest 2 Jun 2007 13:38:28 -0000 Issue 4825
Topics (messages 256000 through 256003):
Cant set info in DB...HELP
256000 by: kvigor
256001 by: Stut
256002 by: Tijnema
Re: uploading really big files
256003 by: Alexander Jaeger
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
Hello,
I'm using phpMyAdmin and I can't get any of my form data into the database.
It returns message: "MySQL returned an empty result set" w/in phpMyAdmin
GUI.
However I get no errors on screen when form info is submitted.
What I have done to solve issue: drop DB and create new.
Review form vars and SQL statements can't find errors...help
Please help...
//=====================FORM======================================
<?php
echo "<div> <link href='css/SOS.css' rel='stylesheet' type='text/css' />
<form id='form1' method='post' action=''>
<label for='select'></label>
<label for='conName'><span
class='style2'>Consumer Information</span><br />
<br />
*Name:</label>
<input type='text' name='conName' id='formPosition' size='100'
class='nameAddressCity_pos' value='{$_POST['conName']}'/>
<br />
<br />
<label for='conAddress'>*Address:</label>
<input name='conAddress' type='text' class='nameAddressCity_pos'
id='textfield' value='{$_POST['conAddress']}' size='100' />
<br />
<br />
<label for='conCity'>*City:</label>
<input name='conCity' type='text' class='nameAddressCity_pos'
id='textfield' value='{$_POST['conCity']}' />
<label for='conState' class='stateLabel'>
*State:</label>
<input name='conState' type='text' class='state' id='textfield'
value='{$_POST['conState']}' />
<label for='conZip'
class='zipLabel'>*Zip:</label>
<input name='conZip' type='text' class='zip' id='textfield'
value='{$_POST['conZip']}' />
<br />
<br />
<label for='conPhone'>*Phone:</label>
<input name='conPhone' type='text' class='nameAddressCity_pos'
id='textfield' value='{$_POST['conPhone']}' />
<br />
<br />
<br />
<span class='style2'>School Nomination
Information </span><br />
<br />
<label for='schName'>*Name:</label>
<input name='schName' type='text' class='nameAddressCity_pos'
id='textfield' value='{$_POST['schName']}' size='100' />
<br />
<br />
<label for='schAddress'>*Address:</label>
<input name='schAddress' type='text' class='nameAddressCity_pos'
id='textfield' value='{$_POST['schAddress']}' size='100' />
<br />
<br />
<label for='schCity'>*City:</label>
<input name='schCity' type='text' class='nameAddressCity_pos'
id='textfield' value='{$_POST['schCity']}' />
<label for='schState'
class='stateLabel'>*State:</label>
<input name='schState' type='text' class='state' id='textfield'
value='{$_POST['schState']}'/>
<label for='schZip'
class='zipLabel'>*Zip:</label>
<input name='schZip' type='text' class='zip' id='textfield'
value='{$_POST['schZip']}' />
<br />
<br />
<span class='style2'><br />
Store Shopped At<br />
<br />
</span>
<label for='strName'>*Name:</label>
<input name='strName' type='text' class='nameAddressCity_pos'
id='textfield' value='{$_POST['strName']}' size='100'/>
<br />
<br />
<br />
<label for='strCity'>*City:</label>
<input name='strCity' type='text'class='nameAddressCity_pos'
id='textfield' value='{$_POST['strCity']}' />
<label for='strStat'
class='stateLabel'>*State:</label>
<input name='strState' type='text' class='state' id='textfield'
value='{$_POST['strState']}' />
<br />
<br />
<br />
<label for='Reset'></label>
<input type='reset' name='reset' value='Reset' id='Submit'/>
<label for='Sumbit'></label>
<input type='submit' name='submit' value='Submit' id='Reset'/>
</form></div>";
//====================END==FORM================================================
echo" <br /><br /><br /><br /><br /><br />";
//===============================striptags=and=trim===================================
$regName = trim(strip_tags($_POST['conName'])); $regAddress
= trim(strip_tags($_POST['conAddress']));
$regCity = trim(strip_tags($_POST['conCity'])); $regState =
trim(strip_tags($_POST['conState']));
$regZip = trim(strip_tags($_POST['conZip'])); $regPhone =
trim(strip_tags($_POST['conPhone']));
$sclName = trim(strip_tags($_POST['schName'])); $sclAddress
= trim(strip_tags($_POST['schAddress']));
$sclCity = trim(strip_tags($_POST['schCity'])); $sclState =
trim(strip_tags($_POST['schState']));
$sclZip = trim(strip_tags($_POST['schZip']));
$stoName = trim(strip_tags($_POST['strName'])); $stoCity =
trim(strip_tags($_POST['strCity']));
$stoState = trim(strip_tags($_POST['strState']));
//==============================end=striptags=and=trim===================================
//==============================Begin dbPopulation of Form
data============================
$dbserver = "localhost";
$dbuser = "root";
$dbpassword = "";
$dbname = "theDB";
$connection = mysqli_connect($dbserver, $dbuser, $dbpassword, $dbname) or
die
("Could not connect to the Server. Contact your Network Administrator or
your Web
Programmer");
$insert_query = "INSERT INTO contestants (conName, conAddress, conCity,
conState,
conZip, conPhone, schName, schAddress, schCity, schState, schZip, strName,
strCity,
strState) VALUES('$regName', '$regAddress', '$regCity', '$regState',
'$regZip',
'$regPhone', '$sclName', '$sclName', '$sclCity', '$sclState', '$sclZip',
'$stoName',
'$stoCity', '$stoState')";
mysqli_query($connection,$insert_query); ?>
//==============================End dbPopulation of Form
data============================
--- End Message ---
--- Begin Message ---
kvigor wrote:
$insert_query = "INSERT INTO contestants (conName, conAddress, conCity,
conState,
conZip, conPhone, schName, schAddress, schCity, schState, schZip, strName,
strCity,
strState) VALUES('$regName', '$regAddress', '$regCity', '$regState',
'$regZip',
'$regPhone', '$sclName', '$sclName', '$sclCity', '$sclState', '$sclZip',
'$stoName',
'$stoCity', '$stoState')";
mysqli_query($connection,$insert_query); ?>
1) You need to use mysqli_real_escape_string on the vars you're putting
into the SQL statement.
2) You need to check the return value from mysqli_query to see if the
query failed. If it is failing I'm guessing actioning suggestion 1 might
help.
-Stut
--- End Message ---
--- Begin Message ---
On 6/2/07, kvigor <[EMAIL PROTECTED]> wrote:
Hello,
I'm using phpMyAdmin and I can't get any of my form data into the database.
It returns message: "MySQL returned an empty result set" w/in phpMyAdmin
GUI.
However I get no errors on screen when form info is submitted.
What I have done to solve issue: drop DB and create new.
Review form vars and SQL statements can't find errors...help
Please help...
//=====================FORM======================================
<?php
echo "<div> <link href='css/SOS.css' rel='stylesheet' type='text/css' />
<form id='form1' method='post' action=''>
<label for='select'></label>
<label for='conName'><span
class='style2'>Consumer Information</span><br />
<br />
*Name:</label>
<input type='text' name='conName' id='formPosition' size='100'
class='nameAddressCity_pos' value='{$_POST['conName']}'/>
<br />
<br />
<label for='conAddress'>*Address:</label>
<input name='conAddress' type='text' class='nameAddressCity_pos'
id='textfield' value='{$_POST['conAddress']}' size='100' />
<br />
<br />
<label for='conCity'>*City:</label>
<input name='conCity' type='text' class='nameAddressCity_pos'
id='textfield' value='{$_POST['conCity']}' />
<label for='conState' class='stateLabel'>
*State:</label>
<input name='conState' type='text' class='state' id='textfield'
value='{$_POST['conState']}' />
<label for='conZip'
class='zipLabel'>*Zip:</label>
<input name='conZip' type='text' class='zip' id='textfield'
value='{$_POST['conZip']}' />
<br />
<br />
<label for='conPhone'>*Phone:</label>
<input name='conPhone' type='text' class='nameAddressCity_pos'
id='textfield' value='{$_POST['conPhone']}' />
<br />
<br />
<br />
<span class='style2'>School Nomination
Information </span><br />
<br />
<label for='schName'>*Name:</label>
<input name='schName' type='text' class='nameAddressCity_pos'
id='textfield' value='{$_POST['schName']}' size='100' />
<br />
<br />
<label for='schAddress'>*Address:</label>
<input name='schAddress' type='text' class='nameAddressCity_pos'
id='textfield' value='{$_POST['schAddress']}' size='100' />
<br />
<br />
<label for='schCity'>*City:</label>
<input name='schCity' type='text' class='nameAddressCity_pos'
id='textfield' value='{$_POST['schCity']}' />
<label for='schState'
class='stateLabel'>*State:</label>
<input name='schState' type='text' class='state' id='textfield'
value='{$_POST['schState']}'/>
<label for='schZip'
class='zipLabel'>*Zip:</label>
<input name='schZip' type='text' class='zip' id='textfield'
value='{$_POST['schZip']}' />
<br />
<br />
<span class='style2'><br />
Store Shopped At<br />
<br />
</span>
<label for='strName'>*Name:</label>
<input name='strName' type='text' class='nameAddressCity_pos'
id='textfield' value='{$_POST['strName']}' size='100'/>
<br />
<br />
<br />
<label for='strCity'>*City:</label>
<input name='strCity' type='text'class='nameAddressCity_pos'
id='textfield' value='{$_POST['strCity']}' />
<label for='strStat'
class='stateLabel'>*State:</label>
<input name='strState' type='text' class='state' id='textfield'
value='{$_POST['strState']}' />
<br />
<br />
<br />
<label for='Reset'></label>
<input type='reset' name='reset' value='Reset' id='Submit'/>
<label for='Sumbit'></label>
<input type='submit' name='submit' value='Submit' id='Reset'/>
</form></div>";
//====================END==FORM================================================
echo" <br /><br /><br /><br /><br /><br />";
//===============================striptags=and=trim===================================
$regName = trim(strip_tags($_POST['conName'])); $regAddress
= trim(strip_tags($_POST['conAddress']));
$regCity = trim(strip_tags($_POST['conCity'])); $regState =
trim(strip_tags($_POST['conState']));
$regZip = trim(strip_tags($_POST['conZip'])); $regPhone =
trim(strip_tags($_POST['conPhone']));
$sclName = trim(strip_tags($_POST['schName'])); $sclAddress
= trim(strip_tags($_POST['schAddress']));
$sclCity = trim(strip_tags($_POST['schCity'])); $sclState =
trim(strip_tags($_POST['schState']));
$sclZip = trim(strip_tags($_POST['schZip']));
$stoName = trim(strip_tags($_POST['strName'])); $stoCity =
trim(strip_tags($_POST['strCity']));
$stoState = trim(strip_tags($_POST['strState']));
//==============================end=striptags=and=trim===================================
//==============================Begin dbPopulation of Form
data============================
$dbserver = "localhost";
$dbuser = "root";
$dbpassword = "";
$dbname = "theDB";
$connection = mysqli_connect($dbserver, $dbuser, $dbpassword, $dbname) or
die
("Could not connect to the Server. Contact your Network Administrator or
your Web
Programmer");
$insert_query = "INSERT INTO contestants (conName, conAddress, conCity,
conState,
conZip, conPhone, schName, schAddress, schCity, schState, schZip, strName,
strCity,
strState) VALUES('$regName', '$regAddress', '$regCity', '$regState',
'$regZip',
'$regPhone', '$sclName', '$sclName', '$sclCity', '$sclState', '$sclZip',
'$stoName',
'$stoCity', '$stoState')";
mysqli_query($connection,$insert_query); ?>
//==============================End dbPopulation of Form
data============================
Try to add a die() to the mysqli_query, like this:
mysqli_query($connection,$insert_query) or die(mysqli_error($connection));
This will probably tell you that there's an error in your SQL code...
Tijnema
--- End Message ---
--- Begin Message ---
Angelo Zanetti schrieb:
clive wrote:
Angelo Zanetti wrote:
Dear all
We need to develop a system where we can upload really big files. IE
15 - 25 Mb.
I know its not a php answer, but if you have ever uploaded a file
with facebook then you will have seen the little applet they push
down to your browser, perhaps investigating something like might
prove useful, I doubt they wrote it themselves, then again maybe they
did.
yeah seen that its a Java applet was going to research it but didnt
have time. Quite a cool component though!
Thanks
Hello List,
i think an upload of 15 - 25 MB is not that big, just depends on which
kind of customers you rely,
in Sweden for an instance is an 100 Mbit line a normal thing for a home
user.
For a Video plattform we use a an Flash upload formular that posts to an
php file, works up to 120MB like a charm (we just havent test > 120MB,
but it should also work)
<Options>
- Give them FTP or SCP or something that is more stable and will re-try.
-> *SCP* (http://en.wikipedia.org/wiki/Secure_copy)
SCP ?!? an shell account for an unkown person on a server?
NO DONT DO THAT!!!
the only way to secure scp running normal envirements is to set
a chroot, and that is way to much effort for a system > 5 users.
(http://sublimation.org/scponly/wiki/index.php/Main_Page)
the least thing you would have to worry about is that your
server is becoming a spam nest.
-> *FTP *
could work depending on the requirements you have.
Try Proftpd it has an easy way to integrate mysql.
(http://www.proftpd.org/)
Also try enabling SSL/TLS to keep some privacy.
-> *Flash *:
There a lot of Tutorials out there, try google or sourceforge.
(http://sourceforge.net/search/?type_of_search=soft&words=flash+upload+php)
the important settings within php is as mentioned memory_limit
as the file gets sucked in,
post_max_size and upload_max_filesize as php denies file larger
than these settings.
By the way as mentioned before, alot of ram is require, but
there is nothing you couldnt throw hardware at.
Also try playing around with safemode, set an upload dir where
the filesystem has no exec rights.
(if somebody uploads a script like sh or bash or what ever)
Dont place the upload within your webroot, or they will be
accessable from the 'outside'.
Dont take for granted that the user uploads a file that you like
him to upload, test the file, copy the file, make filechecks on the type
(not just the normal is '.wmv' within the filename), keep in mind which
user on your system runs the php script.
If you run cronjobs with the uploaded stuff, dont do it with root.
</Options>
<My Opinion>
- The browser gets tired of waiting around for the upload to complete
- because your server is too slow/busy, and the user has a very bad
- experience.
I think that statement is totally wrong, we have all seen the success an
plattform like youtube made, and they do it no other way.
if you have a server that is to slow/busy -> get a another one, or a new Administrator (if it is config based)
</My Opinion>
As a summary, think about what you want to do, it is possible, but as
mentioned by beware of the side effects.
Oh long post....
Cheers,
Alex
--- End Message ---