mattyd 89 Posting Maven Featured Poster
Thank you, both.
Matthew
Thank you all for your replies. I will transition soon. I appreciate the advice.
Matthew
Below is the current status (Screenshot) of my output after redirection.
Could the DB/Table or server be corrupted?
Would anyone feel confident taking a direct look at my DB? - Someone trusted, good post count, knowledge of PHP/MySQL? This may violate protocol, but I am getting desperate to solve this issue involving rendering DB contents to the table, as seen in screenshot. If interested, please PM me for log-in credentials.
Thank you!
Matthew
Image test: (Not imbedded in post)
<Update: Per Dani's advice, this method works)
I have been researching this as I am getting the distinct feeling I will have to transition my code to this soon, eventually.
From your experience, can someone provide a brief overview of the benefits of MySQLi and why I should transition. Is it even necessary? I'm not sure.
Any advice would be greatly appreciated. I am developing a very large project and want to make sure I do this correctly.
Thank you in advance!
Matthew
Hello.
What I am planning to do for User registration in regards to agreeing to the EULA:
1)For example, there will be three conditions the User must agree to by selecting checkboxes - Only one condition displayed at a time.
2)Upon checking the first condition checkbox, the second condition appears onscreen, smoothly - The first disappearing; This would be a sort of animation. When this second checkbox is selected, this condition disappears, the third and final condition gliding into its place. (I do not want page refreshes or anything of that nature).
I hope I explained this clearly.
From my research, it appears to be JavaScript I should be using to build this. Possibly jQuery (Which I am totally unfamiliar with).
I don't think this should be too difficult to build, but any advice would be greatly appreciated.
Thank you in advance!
Matthew
phorce:
Same results as earlier (But Warning & Warning no longer appear):
NULL YES
Employee Name | Employee Address
JAH!
Null? Is this indicating a variable is empty or that it is reading that the table is not populated? The DB/table is full of data.
Thank you.
phorce:
Attempting to update file, run and post results for you, here.
Problem is, the file will not save.
I am running my tests on a server/DB out of Germany; They seem a bit unprofessional and sloppy.
I will post results as soon as possible.
Thank you for your help and kindness.
Matthew
Results:
It will not let me enter "code" directly here. I tried to C&P it into the <Code> formatting, but it erased my text (?) [Bug?]
Here is a screenshot. There should be a link to enlarge the view.
*You can have direct access to my DB if you'd like - Just PM me and I'll send credentials.
It is:
"emp_name" and "emp_address"
Strange:
When posting the image, a link is provide for a larger view; I will try again. One sec...
Per request:
Thank you, phorce.
Matthew
Here is the full .php file:
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
$con = mysql_connect("localhost","372***", "********");
if (!$con)
{
die('NEIN!' . mysql_error());
}
//Connect to DB
//(Possible offender below)
$res = mysql_query("SHOW DATABASES");
while ($row = mysql_fetch_assoc($res)) {
echo $row['372***'] . "\n";
}
mysql_select_db(372***, $con)
or die("Lost");
echo "<table border='1'>
<tr>
<th>Employee Name</th>
<th>Employee Address</th>
</tr>";
$result = mysql_query("SELECT * FROM b8_14160309_simple*** LIMIT 1") or die (mysql_error());
while($row = mysql_fetch_array($result));
{
echo "YES";
echo "<tr>";
echo "<td>" . $row['emp_name'] . "JAH!" . "</td>";
echo "<td>" . $row['emp_address'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
Hi Dani.
To answer your two posts, above:
1) Yes, those are the names of the two fields in the DB.
2)I inserted JAH! as a test flag to see if it would populate the collapsed, empty cell, which upon run, it did print within the first, bottom-left cell.
Related to this, can you please elaborate on why you think this may be specifically a DB-related issue.
I appreciate your help!
Matthew
Debugging.
I think I have isolated the problem lines, but have yet to solve the retrieved data-in-cell display issue.
I believe the issue lies within these two lines:
echo "<td>" . $row['emp_name'] . "JAH!" . "</td>";
echo "<td>" . $row['emp_address'] . "</td>";
I will fix it, though.
phorce:
Good Morning.
Sorry I missed you last night.
Here are the two files I'm working with (I believe the problem(s) lives in the 2nd example,index1.php):
1)Input
2)Redirected output
1)Input
ob_re_4000.php
<?php
ob_start();
?>
<html>
<body>
<form method="post" action="<?php $_PHP_SELF ?>">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Employee Name</td>
<td><input name="emp_name" type="text" id="emp_name"></td>
</tr>
<tr>
<td width="100">Employee Address</td>
<td><input name="emp_address" type="text" id="emp_address"></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td>
<input name="add" type="submit" id="add" value="Add Employee">
</td>
</tr>
</table>
</form>
<?php
$con = mysql_connect("localhost","*******0", "********1");
if (!$con)
{
die('NEIN! ' . mysql_error());
}
//Connect to DB
$res = mysql_query("SHOW DATABASES");
while ($row = mysql_fetch_assoc($res)) {
echo $row['Database'] . "\n";
}
mysql_select_db(372110, $con)
or die("Lost");
//Detect DB
$sql="INSERT INTO b8_*********_simpleDB* (emp_name, emp_address)
VALUES
('$_POST[emp_name]','$_POST[emp_address]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
//Add entry to DB
?>
<?php
$redirect_page = 'http://absinthe42.eu5.org/index1.php';
$redirect = true;
if ($redirect == true AND !empty($_POST)) {
header("Location:$redirect_page");
}
ob_end_flush();
?>
2)Redirected output
index1.php
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
$con = mysql_connect("localhost","372***", "*********");
if (!$con)
{
die('NEIN!' . mysql_error());
}
//Connect to DB
//(Possible offender below)
$res = mysql_query("SHOW DATABASES");
while ($row = mysql_fetch_assoc($res)) {
echo $row['372110'] . "\n";
}
mysql_select_db(372***, $con)
or die("Lost");
//Detect DB
//START
$result = mysql_query("SELECT * FROM b8_*********_simpleDB3 LIMIT 1");
echo "<table border='1'>
<tr>
<th>Employee Name</th>
<th>Employee Address</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['emp_name'] . "</td>";
echo "<td>" . $row['emp_address'] . "</td>";
echo …
phorce:
Hi.
Yes, the table is very populated. About 7-pages of input data.
Thank you very much for all your help and sugestions!
Matthew
Dani, yes I tried phorces suggestion.
I am not sure if I implemented it correctly (I had to modify the snippet); It may be a false-positive of sorts, the results, but it stated "Theres something wrong here".
So, I am not connecting, or..?... Something?
I am going to bed now and sleep it off until early morning where I can start fresh regarding this. I get rather obsessed and have worn myself out today concerning a block of code.
Thank you and good night.
Matthew
It is not working - This particular section of code was working fine just yesterday. I have no idea what happened. Maddening :/
$result = mysql_query("SELECT * FROM b8_14160309_simpleDB3 LIMIT 1");
echo "<table border='1'>
<tr>
<th>Employee Name</th>
<th>Employee Address</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['emp_name'] . "</td>";
echo "<td>" . $row['emp_address'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
Dani:
Hi.
Yes, not sure what is going on - It all suddenly changed unbeknownst to me.
Yes, it is the right table. I only have two tables on the DB at this time.
Thank you for your help.
Dani,
Hi.
I modified the code. It works wonderful and is exactly what I needed.
One odd issue, though.
I submit data via form > Page redirects to index1.php
It should display a table with four cells, the top two labels, the bottom two, the data input by the User. It displays the table with top labels, but botttom data cells are collapsed. No data. (Note: Entered data does go into the DB. I always check)
Nothing in this code has changed as far as I know. It has always worked easily. Yet, now, I cannot get the data to dump into the two, bottom cells of the table (Please see attachment of the result)
...
$res = mysql_query("SHOW DATABASES");
while ($row = mysql_fetch_assoc($res)) {
echo $row['Database'] . "\n";
}
mysql_select_db(372110, $con)
or die("Lost");
//Detect DB
$result = mysql_query("SELECT * FROM b8_14160309_simpleDB3 LIMIT 1");
echo "<table border='1'>
<tr>
<th>Employee Name</th>
<th>Employee Address</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['emp_name'] . "</td>";
echo "<td>" . $row['emp_address'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
Thank you.
Dani:
Thank you so much for your help. You're brilliant! I am learning so much from your site. It's wonderful.
I modified my code as you posted and it worked perfectly. In the morning I shall further modify the code to include my form. I will post my results here.
Kind regards,
Matthew
I am still working with redirection.
This works great, but is not exactly what I need:
<?php
ob_start();
?>
<h1>ob redirect test</h1>
<?php
$redirect_page = 'https://www.google.com';
$redirect = true;
if ($redirect == true) {
header("Location:$redirect_page");
}
ob_end_flush();
?>
I have spent all day trying to figure out how to use this after a user submits a form BUT have it only activate then. Currently it merely loads Google upon run.
I have a lot of wild ideas such as if statements, setting variables to false, then resetting them to true. Make sense? No, it does not to me either.
I am winding up with a confused, heavy load of "spahgetti" code in my head.
I just need to submit a form and display the submitted user-data on the index.php page.
Thank you for your patience and any advice.
Matthew
cereal:
Works perfectly (And I learned more about proper syntax)!
You're awesome.
Thank you for your help, Friend.
Matthew
I am still working on the redirection issue (As noted in a previous thread here).
I think I may have found a nice solution via a video tutorial on the subject.
When running this test script, it should simply load google.com; The result though is a "Page not found" screen.
Please look at my code.
<?php
ob_start();
?>
<h1>ob redirect test</h1>
Hi
<?php
$redirect_page = 'https://www.google.com';
$redirect = true;
if ($redirect = true) {
header('Location:$redirect_page');
}
ob_end_flush();
?>
Thank you in advance for your assistance!
Matthew
(Mods/Admin: Please move if in wrong area. Thank you)
I am interested in hosting ads on my site, but I have no idea where to begin.
Simply put, I want this to be a selective, semi-targeted process; Companies such as RackSpace, for example.
I would not accept just anything on my site.
Any hints, links or advice would be greatly apreciated.
Thank you in advance!
Matthew
rhodoscoder:
I shall implement ALL of your suggestions and report back to this thread with the results.
Thank you for your excellent help. You outdid yourself, my friend!
Regards,
Matthew
Update:
Fixed the parse error - But page still instantly redirects, omitting User, data-form. Confused.
Thank you for everyone's help thus far!
I am able to redirect sucessfully, but there is a further issue:
Please view current code on the said page:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<?php
//Redirect
header('Location: /index1.php');
?>
<html>
<body>
<form method="post" action="<?php $_PHP_SELF ?>">
<table width="400" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100">Employee Name</td>
<td><input name="emp_name" type="text" id="emp_name"></td>
</tr>
<tr>
<td width="100">Employee Address</td>
<td><input name="emp_address" type="text" id="emp_address"></td>
</tr>
<tr>
<td width="100"> </td>
<td> </td>
</tr>
<tr>
<td width="100"> </td>
<td>
<input name="add" type="submit" id="add" value="Add Employee">
</td>
</tr>
</table>
</form>
<?php
$con = mysql_connect("localhost","372---", "c--------");
if (!$con)
{
die('NEIN! ' . mysql_error());
}
//Connect to DB
$res = mysql_query("SHOW DATABASES");
while ($row = mysql_fetch_assoc($res)) {
echo $row['Database'] . "\n";
}
mysql_select_db(372110, $con)
or die("Lost");
//Detect DB
$sql="INSERT INTO b8_14160309_-------- (emp_name, emp_address)
VALUES
('$_POST[emp_name]','$_POST[emp_address]')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "3 record added";
//Add entry to DB
//TEST
$result = mysql_query("SELECT * FROM b8_14160309_-------- LIMIT 1");
echo "<table border='1'>
<tr>
<th>Employee Name</th>
<th>Employee Address</th>
</tr>";
while($row = mysql_fetch_array($result)) …
I want to allow the User to enter and submit data - Then, that data should be displayed for the User, formatted on a new page.
I apologize if this has already been asked/answered
I am have trouble with this, although I imagine the solution is rather simple:
I have been trying this with questionable results.
Any direction or help would be greatly appreciated.
Thank you in advance!
Matthew
Cereal:
It is I, The_Thorn.
This is my original account, mattyd, dating back years and has been recovered for me by the gracious <daniweb> team.
I am looking at your code samples and planning to implement. I shall let you know how it all works out.
-Matthew
Thank you, Sir!
Explore scripting languages such as:
Many people underestimate their power and potential usages. I will tell you, they can create wonderful, fast programs.
Regards,
Matthew
After years of tumultuous shenanigans, I have returned to <DANIWEB>.
I am primarily here to research and study PHP/MySQL.
I look forward to my time here, helping others and getting help with my project(s).
Note: I am formally known here from a recently-created, new account, The_Thorn.
Regards,
Matthew
Thanks for all the replies! :)
I am assuming there is a specific size needed to use with a laptop hard drive?
*I am more of a software guy and don't know so much about hardware.
Thanks, again, all.
Recently my girlfriend's laptop "died", that is, it may be only the monitor but in any case, it is no longer functional.
My question is this: We would like to recover all data from the laptop hard drive without having to take the laptop to a shop to have it done.
We got her a brand new computer and would like to transfer data from the laptop disk to the new machine's disk. How do we do that?
I read that it could be done by attaching USB cables between both machines; this did not work - The new computer did not detect the old laptop drive.
Any help or a nudge in the right direction would be greatly appreciated.
Thank you in advance.
Matty
Hello.
I am completing work on a commerce website and have noticed a small but strange error that I cannot seem to remedy.
Each page has a footer that contains text; of course, this should align the same on each page view, but the problem is as follows:
Alignment is correct on each page but the index page (please see attached screen shots: the said text is outlined in blue and shows that there is a significant gap above each text element-- but both are different.)
I have tried to determine the problem and have tried to use a CSS workaround but each time it simply extends the length of the index page (and does not fix the error)
I would truly appreciate if someone had the chance to look at this. Thank-you. (code of pages & CSS below)
NOTE: The CSS element for the said text element is <div id="lorem"> and is located at the bottom of both HTML pages.
-Matty
index page
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Perola Jewelry</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META NAME="Description" CONTENT="Handmade jewelry, silver and metals/gemstones as well as unique art pieces.">
<meta name="keywords" content="jewelry silver bronze copper gem stones goldfilled art">
<link rel="stylesheet" type="text/css" href="style.css">
<!--[if lte IE 8]> <link rel="stylesheet" type="text/css" href="ie.css" /><![endif]-->
<link rel="Shortcut Icon" href="/favicon.ico">
<script language="JavaScript" type="text/javascript">
if (document.images)
{
cart =new Image();
cart.src ="image/other/cart2.png";
}
function change1(picName,imgName)
{
if (document.images)
{
imgOn=eval(imgName + ".src");
document[picName].src= …
Matty,
The search that you saved has the parameters (e.g. search=Kim) as part of the string. If you want to start from scratch with a new search then the string should be:http://bluelinedown.netau.net/new_test.php
Instead of:
Thank-you so much for your help - that worked perfectly. :)
~Matty
Hello. I have been following a great tutorial that I found regarding searching a database:
Tutorial: http://www.phpfreaks.com/tutorial/simple-sql-search
When I used this and ran it from my server (doing a search of the database), I bookmarked the page; my question relates to the next step: When I return to the page via the bookmark the actual search has been saved and is displayed, not just the search form. I do not understand this.
I need it to be so that each time a user goes to this search page, no prior search is displayed and it is, of course, available for a new search. Is this issue related to sessions? And if so, how?
Below is the actual code I am using for this search function/page:
<?php
/*****************************
* Simple SQL Search Tutorial by Frost
* of Slunked.com
******************************/
$dbHost = 'mysql7.000webhost.com'; // localhost will be used in most cases
// set these to your mysql database username and password.
$dbUser = '********';
$dbPass = '*******';
$dbDatabase = '**********'; // the database you put the table into.
$con = mysql_connect($dbHost, $dbUser, $dbPass) or trigger_error("Failed to connect to MySQL Server. Error: " . mysql_error());
mysql_select_db($dbDatabase) or trigger_error("Failed to connect to database {$dbDatabase}. Error: " . mysql_error());
// Set up our error check and result check array
$error = array();
$results = array();
// First check if a form was submitted.
// Since this is a search we will use $_GET
if (isset($_GET['search'])) {
$searchTerms = trim($_GET['search']); …
I have read through the FAQ sticky regarding this topic (and have also searched/read here further on this topic) but I am still receiving the following error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/a4542527/public_html/index.php on line 8
The scripting for this is basic at this point (I am building something in steps and this is just a test section: The script will call data from the table and display said data.)
The following is the code (two, separate files located on my server)- I am hoping that someone may see something that I am missing.
connection.php
<?php
$dbhost = 'mysql7.000webhost.com';
$dbuser = 'a4542527_root';
$dbpass = '**********';
$db = 'a4542527_test1';
$conn = mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($db);
?>
index.php
<?php
include 'connection.php';
$query = "SELECT * FROM people";
$result = "mysql_query($query)";
while ($person = mysql_fetch_array($result)){
echo $person ['name'];
echo $person ['descrip'];
}
?>
Thank-you for any help, suggestions or a point in the right direction.
Matty
Do you at least now how to insert the data into the DB? If not, then I suggest you first read an online tutorial on PHP:
http://www.w3schools.com/php/default.aspIf you are already familiar with the syntax of php, then try skipping to the "forms" section of the tutorial. Be sure the read the MySQL portion.
Thank-you for your help, hielo :)
which part are you having trouble with? I suggest you post what you have thus far and provide more details regarding your problem.
I guess I am in the "theoretical" at this point, that is, I have not started coding anything yet. I am new to PHP and am just trying to sort out the steps as to solve this problem. This is a personal project and I am hoping to collect information or simply a push in the right direction from where I can do further research (thus far, my online search has not produced significant returns). I hope that I am explaing my original problem clearly: User types characters into form > submits > data is saved to database > user's formatted data is returned to browser and displayed.
Thank-you.
Matty
Hello. I need some direction for the following problem (I am not sure where to begin my research):
I essentially, using PHP and MySQL, allow a user to enter character data into a form, submit the form, and next have this data saved to the database, then a formatted version of said character data returned to the user's machine and displayed in the browser. (Similar to how I am entering text here, submitting and having a visible formatted copy to view)
I know this is probably a simple matter but I am having trouble getting all the necessary steps in order.
Thank-you for any help in advance.
Matty
I am in the midst of refreshing myself on MySQL.
The basics have been going well but I am having one issue. I have created a table with two columns and three rows. Next I added a third, null column, Price, which I now wish to populate with data, that is, I want to enter separate, new data for each row in the Price column. Below is the output of the table:
_______________________
Name | Color | Price
_______________________
Apples | Red | Null
Kiwis | Green | Null
Berries | Blue | Null
_______________________
I would like to alter the output to this:
Name | Color | Price
_______________________
Apples | Red | 1.00
Kiwis | Green | 1.50
Berries | Blue | 2.25
_______________________
*Note: I have researched this but have not yet found the solution
Thank-you in advance for any help.
should be
use juggernaught;
Thank-you for pointing this out. :icon_wink:
-Matty
I'm new to MySQL, so pardon the dumb question, but what does the word 'juggernaut' mean when it appears immediately before your CREATE statement (as shown in your attached thumbnail)?
"juggernaut" is the name of my database.
Worked fine for me in the MySQL monitor in terminal.
mysql> CREATE TABLE employees ( -> employeeNumber int(11) NOT NULL, -> lastName varchar(50) NOT NULL, -> firstName varchar(50) NOT NULL, -> extension varchar(10) NOT NULL, -> email varchar(100) NOT NULL, -> officeCode varchar(10) NOT NULL, -> reportsTo int(11) default NULL, -> jobTitle varchar(50) NOT NULL, -> PRIMARY KEY (employeeNumber) -> ); Query OK, 0 rows affected (0.10 sec)
Thank-you for your reply. :) It's odd, I do this in the MySQl Terminal and keep getting the same error.