• We've upgraded our forums. Please post any issues/requests in this thread.

Extracting data from relational databases

Joined
Jun 30, 2008
Messages
1,135 (0.33/day)
Likes
67
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
#1
Hi,

New to phpmyadmin, PHP, MySQL, etc - so please excuse me if the answer to the question is simple.

I've built a database using XAMPP called "evidence db". Within that database, I have a table called "m cases". This table has 11 columns.

I currently have the following code:
Code:
<html>
<head>
<title>Search data</title>
</head>
<body>
<table>
  <tr>
    <td align="center">EMPLOYEES DATA</td>
  </tr>
  <tr>
    <td>
      <table border="1">
      <tr>
        <td>Case ID</td>
      </tr>
<?

mysql_connect("localhost","root","");//database connection
mysql_select_db("evidence db");
				
$order = "SELECT * FROM m cases";
				
$result = mysql_query($order);	

while($data = mysql_fetch_row($result)){
$field1= $row["Case ID"];
  echo("$field1");
}
?>
    </table>
  </td>
</tr>
</table>
</body>
</html>
Error:
Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\helloworld.php on line 25

Thanks in advanced.

PS - If anyone can recommend PHP/Phpmyadmin tutorials - i'd be interested in reading them.
 
Joined
May 21, 2009
Messages
4,966 (1.59/day)
Likes
1,511
System Name i7-PC / HTPC / iMac
Processor i7 3820 / Phenom II 940
Motherboard GIGABYTE G1.ASSASSIN2 / M3A79-T Deluxe
Cooling Corsair Hydro H100i / Scythe II (HS only)
Memory G.SKILL Trident X Series 8GB (2 x 4GB) DDR3 1600mhz / 4GB DDR2 1066 (@800) Corsair Dominator
Video Card(s) GB Radeon HD 7950s 3GB / GB Radeon HD 7950s 3GB
Storage 2x 80GB Intel X-25, 2x600gb SATA, 1x1tb 5400RPM storage /1x600GB, 3x500GB,1x160,1x120 SATA
Display(s) 1x 27" Yamakasi / Vizio 42" HDTV
Case Lian Li Lancool PC-K58 / Antec 900
Audio Device(s) HT Omega Striker 7.1 / Onboard and HDMI from ATi Card
Power Supply PC Power & Cooling 750W / 610W
Software Ubuntu / Windows 8.1 Pro / OS X / PHPStorm / Gaming
#2
i recommend checking out http://www.phpfreaks.com/, not to advert other forums but they are dedicated to php coding and will likely get you solved much faster than here, unless one of the few gurus happen to post.

also, all you ever need other than a forum is the manual pages
http://php.net/manual/en/index.php

more specifically, the man page for mysql_fetch_row(), here:
http://php.net/manual/en/function.mysql-fetch-row.php

as it says, it is recommend with current php versions to use a different mysql extension entirely, with good reason. you may want to consider that. good luck.
 
Joined
Aug 10, 2007
Messages
4,058 (1.07/day)
Likes
1,122
Location
Geneva, FL, USA
Processor Intel i5-6600
Motherboard ASRock H170M-ITX
Cooling Cooler Master Geminii S524
Memory G.Skill DDR4-2133 16GB (8GB x 2)
Video Card(s) Gigabyte R9-380X 4GB
Storage Samsung 950 EVO 250GB (mSATA)
Display(s) LG 29UM69G-B 2560x1080 IPS
Case Lian Li PC-Q25
Audio Device(s) Realtek ALC892
Power Supply Seasonic SS-460FL2
Mouse Logitech G700s
Keyboard Logitech G110
Software Windows 10 Pro
#3
There's a space in that table name, so it needs to be escaped with backticks.

Code:
$order = "SELECT * FROM `m cases`";
In the future, don't put spaces in your table or column names. Use an underscore (m_cases) or go camel case (mCases).

Also, if you're just starting to learn, I'd suggest going with their PDO interface instead of the database specific functions.

http://www.php.net/pdo

Been meaning to put together a small intro to PDO for the forum, with the recent rise in PHP/database questions. Maybe I'll get around to doing it now that I said I would... ;)
 
Joined
Jun 30, 2008
Messages
1,135 (0.33/day)
Likes
67
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
#4
Did put the backticks and have also updated the DB name to have no spaces - still no luck. Will have a better look at it tomorrow. Thanks for the input.
 

Easy Rhino

Linux Advocate
Joined
Nov 13, 2006
Messages
14,405 (3.56/day)
Likes
4,256
System Name VHOST01 | Desktop
Processor i7 980x | i5 7500 Kaby Lake
Motherboard Gigabyte x58 Extreme | AsRock MicroATX Z170M Exteme4
Cooling Prolimatech Megahelams | Stock
Memory 6x4 GB @ 1333 | 2x 8G Gskill Aegis DDR4 2400
Video Card(s) Nvidia GT 210 | Nvidia GTX 970 FTW+
Storage 4x2 TB Enterprise RAID5 |Corsair mForce nvme 250G
Display(s) N/A | Dell 27" 1440p 8bit GSYNC
Case Lian Li ATX Mid Tower | Corsair Carbide 400C
Audio Device(s) NA | On Board
Power Supply SeaSonic 500W Gold | Seasonic SSR-650GD Flagship Prime Series 650W Gold
Mouse N/A | Logitech G900 Chaos Spectrum
Keyboard N/A | Posiden Z RGB Cherry MX Brown
Software Centos 7 | Windows 10
#5
just FYI, technically evidence db is a schema and not a database.
 

Mindweaver

Moderato®™
Staff member
Joined
Apr 16, 2009
Messages
6,570 (2.08/day)
Likes
3,905
Location
Charleston, SC
System Name Sechs / EyeSeven
Processor i7 5820k @ 4.5ghz / i7 2600k @ 4.0Ghz
Motherboard X99S GAMING 7 / ASRock Z68 Extreme3 Gen3
Cooling CORSAIR Hydro Series H100i Extreme / Stock cooler... H50 leaked!..
Memory G.Skill DDR4 2800 16GB 4x4GB / G.Skill DDR3 1600 8gb 2x4GB
Video Card(s) PNY Quadro K2000 / MSI GTX 970 GAMING 4Gb
Storage Samsung 850 PRO 256GB SSD /Intel 240gb, corsair 120gb SSD, 3x 1 tb s storage
Display(s) 2x Acer G276HL 27" 1080p / 3x Acer 22" Nvidia surround
Case Phanteks “Enthoo Pro series”/ Cooler Master Storm Scout
Audio Device(s) Azalia Realtek ALC1150 / SB X-Fi Gamer
Power Supply Corsair CXM CX600M / Corsair 600w
Mouse Razer DeathAdder Chroma / Razer DeathAdder
Keyboard Razer BlackWidow Ultimate /
Software Windows 10 Pro x64 / Windows 10 Pro x64
#6
You don't have a password setup for "root"? I would set a password or actually go one step further and change the "root" user id to something else completely, but that's just me. :toast:

EDIT: Nice catch Easy Rhino! :toast:
 

Aquinus

Resident Wat-man
Joined
Jan 28, 2012
Messages
10,397 (4.85/day)
Likes
5,477
Location
Concord, NH
System Name Kratos
Processor Intel Core i7 3930k @ 4.2Ghz
Motherboard ASUS P9X79 Deluxe
Cooling Zalman CPNS9900MAX 130mm
Memory G.Skill DDR3-2133, 16gb (4x4gb) @ 9-11-10-28-108-1T 1.65v
Video Card(s) MSI AMD Radeon R9 390 GAMING 8GB @ PCI-E 3.0
Storage 2x120Gb SATA3 Corsair Force GT Raid-0, 4x1Tb RAID-5, 1x500GB
Display(s) 1x LG 27UD69P (4k), 2x Dell S2340M (1080p)
Case Antec 1200
Audio Device(s) Onboard Realtek® ALC898 8-Channel High Definition Audio
Power Supply Seasonic 1000-watt 80 PLUS Platinum
Mouse Logitech G602
Keyboard Rosewill RK-9100
Software Ubuntu 17.10
Benchmark Scores Benchmarks aren't everything.
#7
You need error checking, my friend.

Change this:
PHP:
mysql_connect("localhost","root","");//database connection
mysql_select_db("evidence db");
				
$order = "SELECT * FROM m cases";
				
$result = mysql_query($order);
To this:
PHP:
$conn = mysql_connect("localhost","root","");//database connection
if(!$conn) {
    throw new Exception('Unable to connect');
}

$dbname = 'evidence db';
if(!mysql_select_db($dbname)) {
    throw new Exception('Unable to use db: {$dbname}');
}
				
$order = "SELECT * FROM `m cases`";
				
if(!$result = mysql_query($order, $conn)) {
    throw new Exception("Query failed.\n".mysql_error($conn));
}
Since your table also has a space in it, you need to denote the table name using back ticks. It may allow double quotes for table names as well, but I don't recall (I use PostgreSQL too often.)

Error:
Warning: mysql_fetch_row() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\helloworld.php on line 25
Your query is throwing an error (mysql_query(), must be returning a non-object and the only non-object it returns is false on an error.) Try out the back-ticks, that probably will fix it.
PHP:
$order = "SELECT * FROM `m cases`";
Lastly, the mysql functions you are using are deprecated. Look into MySQLi or ADODB.
 
Last edited:
Joined
Jun 30, 2008
Messages
1,135 (0.33/day)
Likes
67
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
#8
Thanks for the input. It's now working

:toast:
 
Joined
Jun 30, 2008
Messages
1,135 (0.33/day)
Likes
67
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
#9
Has anyone ever had problems with dreamweaver displaying the page layout differently to that shown on a web browser?
 

Kreij

Senior Monkey Moderator
Staff member
Joined
Feb 6, 2007
Messages
13,817 (3.49/day)
Likes
5,524
Location
Cheeseland (Wisconsin, USA)
Processor Intel Core 2 Quad QX9650 Extreme @ 3.0 GHz
Motherboard Asus Rampage Formula
Cooling ZeroTherm Nirvana NV120 Premium
Memory 8GB (4 x 2GB) Corsair Dominator PC2-8500
Video Card(s) 2 x Sapphire Radeon HD6970
Storage 2 x Seagate Barracuda 320GB in RAID 0
Display(s) Dell 3007WFP 30" LCD (2560 x 1600)
Case Thermaltake Armor w/ 250mm Side Fan
Audio Device(s) SupremeFX 8ch Audio
Power Supply Thermaltake Toughpower 750W Modular
Software Win8 Pro x64 / Cat 12.10
#10
I haven't but that probably because I never used Dreamweaver. :D

Okay, I'm not trolling. I've noticed that in several IDE environments that what the IDE shows is not always the same as when it runs in a browser or as an application. For instance, working with WPF in VS2010, what is shown in the IDE is not always the same as when you run the app outside of the IDE.
Minor emulation differences I assume.

Best to check everything in its final resting place (like in a browser) than count on the display in the tools to be accurate.
 

Aquinus

Resident Wat-man
Joined
Jan 28, 2012
Messages
10,397 (4.85/day)
Likes
5,477
Location
Concord, NH
System Name Kratos
Processor Intel Core i7 3930k @ 4.2Ghz
Motherboard ASUS P9X79 Deluxe
Cooling Zalman CPNS9900MAX 130mm
Memory G.Skill DDR3-2133, 16gb (4x4gb) @ 9-11-10-28-108-1T 1.65v
Video Card(s) MSI AMD Radeon R9 390 GAMING 8GB @ PCI-E 3.0
Storage 2x120Gb SATA3 Corsair Force GT Raid-0, 4x1Tb RAID-5, 1x500GB
Display(s) 1x LG 27UD69P (4k), 2x Dell S2340M (1080p)
Case Antec 1200
Audio Device(s) Onboard Realtek® ALC898 8-Channel High Definition Audio
Power Supply Seasonic 1000-watt 80 PLUS Platinum
Mouse Logitech G602
Keyboard Rosewill RK-9100
Software Ubuntu 17.10
Benchmark Scores Benchmarks aren't everything.
#11
Dreamweaver has its own HTML render. You will find that with certain setting, they will look a little different between different browsers, be it Firefox, Chrome, IE, etc. When testing, you really should check all the different browsers that you're planning to support. That's the only way to make sure it works on all of them the way you have your HTML and CSS configured because two browsers might handle padding, margins, and borders differently depending on the settings.

My rule of thumb is: Don't use Dreamweaver. :)
 
Joined
Jun 30, 2008
Messages
1,135 (0.33/day)
Likes
67
Location
England
System Name Wasleys PC
Processor Intel i5 2400 3.10GHz
Motherboard Asus P8z68-V
Cooling AC Freezer Pro
Memory Kingston 4GB (2x2GB) DDR3 Hyperx Memory
Video Card(s) HIS ATi 6850 1GB DDR3
Storage Seagate ST3500320AS 500GB Hard Drive SATA II 7200rpm *32MB Cache*
Case Antec 900 with mods
Audio Device(s) On Board
Power Supply OCZ Stealth Xtream 500W
Software Windows 7
#12
Just out of interest - What do you guys use?
 

W1zzard

Administrator
Staff member
Joined
May 14, 2004
Messages
17,024 (3.43/day)
Likes
17,884
Processor Core i7-4790K
Memory 16 GB
Video Card(s) GTX 1080
Display(s) 30" 2560x1600 + 19" 1280x1024
Software Windows 7
#13
Just out of interest - What do you guys use?
i use dreamweaver for the rough layouting. any text editor (ultraedit in my case) + firefox firebug for the details

if you are asking what database: tpu uses mysql everywhere, memcached for caching
 
Joined
May 21, 2009
Messages
4,966 (1.59/day)
Likes
1,511
System Name i7-PC / HTPC / iMac
Processor i7 3820 / Phenom II 940
Motherboard GIGABYTE G1.ASSASSIN2 / M3A79-T Deluxe
Cooling Corsair Hydro H100i / Scythe II (HS only)
Memory G.SKILL Trident X Series 8GB (2 x 4GB) DDR3 1600mhz / 4GB DDR2 1066 (@800) Corsair Dominator
Video Card(s) GB Radeon HD 7950s 3GB / GB Radeon HD 7950s 3GB
Storage 2x 80GB Intel X-25, 2x600gb SATA, 1x1tb 5400RPM storage /1x600GB, 3x500GB,1x160,1x120 SATA
Display(s) 1x 27" Yamakasi / Vizio 42" HDTV
Case Lian Li Lancool PC-K58 / Antec 900
Audio Device(s) HT Omega Striker 7.1 / Onboard and HDMI from ATi Card
Power Supply PC Power & Cooling 750W / 610W
Software Ubuntu / Windows 8.1 Pro / OS X / PHPStorm / Gaming
#14
i use jetbrains phpstorm. if i were to use a wysiwyg it would be dreamweaver, but i don't do much real layout work, and stick to coding.
 

Aquinus

Resident Wat-man
Joined
Jan 28, 2012
Messages
10,397 (4.85/day)
Likes
5,477
Location
Concord, NH
System Name Kratos
Processor Intel Core i7 3930k @ 4.2Ghz
Motherboard ASUS P9X79 Deluxe
Cooling Zalman CPNS9900MAX 130mm
Memory G.Skill DDR3-2133, 16gb (4x4gb) @ 9-11-10-28-108-1T 1.65v
Video Card(s) MSI AMD Radeon R9 390 GAMING 8GB @ PCI-E 3.0
Storage 2x120Gb SATA3 Corsair Force GT Raid-0, 4x1Tb RAID-5, 1x500GB
Display(s) 1x LG 27UD69P (4k), 2x Dell S2340M (1080p)
Case Antec 1200
Audio Device(s) Onboard Realtek® ALC898 8-Channel High Definition Audio
Power Supply Seasonic 1000-watt 80 PLUS Platinum
Mouse Logitech G602
Keyboard Rosewill RK-9100
Software Ubuntu 17.10
Benchmark Scores Benchmarks aren't everything.
#15
I use vim to edit PHP, my database of choice is PostgreSQL. Even when I do layout, I usually write the CSS by hand and I use various browsers to test it. I prefer Chrome, but not everyone uses Chrome, so I keep Firefox and IE handy as the most commonly used.