PDA

View Full Version : Connecting to database in dreamweaver?


mr_badger
12-16-2006, 08:32 PM
I'm using dreamweaver 8 and Mysql control center. I have created 2 tables in phpmyadmin on my webhosting control panel, when I connect to my database in dreamweaver the connection is successful but It's not showing my tables that I have created, I just dont understand what to do. I know someone here can help me.

davidj
12-18-2006, 06:23 AM
you need to create a connecton script and run a simple select statement

this is the proper test

I have attached a connections test script.

run the script from your testing server. Just ignore the sockets and ports fields

welcome to the forum mr badger

mr_badger
12-18-2006, 09:35 PM
Thankyou for replying.
I have downloaded the script and put my ftp settings and my database settings into the script and uploaded it to my server, still I can't connect to my tables?

davidj
12-19-2006, 05:47 AM
what message did you get back from the test script

mr_badger
12-19-2006, 06:01 PM
The message says that the connection faied because it Cannot connect with pdo_mysql extension. Reason: extension is not installed.

davidj
12-19-2006, 08:15 PM
have you tried a phpinfo() test?

mr_badger
12-19-2006, 09:21 PM
I have done the phpinfo() test and it shows my PDO drivers as sqlite, sqlite2 enabled.

davidj
12-19-2006, 09:35 PM
anything in there to do with MYSQL ?

mr_badger
12-19-2006, 11:09 PM
This is a screenshot of the MySQL part of phpinfo().

davidj
12-20-2006, 05:52 AM
every thing looks fine there

have you tried WAMP?

http://www.wampserver.com/en/

you may need to uninstall your Apache, PHP, MYSQL but at last you will have everything you need with a complete working installation

mr_badger
12-20-2006, 12:08 PM
I'm already using the wamp server.

davidj
12-20-2006, 12:18 PM
this is a weird one

the account your using to connect to the database. Is the access rights correct in mysql for that connection?

davidj
12-20-2006, 12:30 PM
also have you tried writing a sql statement like a select and running it in order to return some data from the table

just a test to find out where its falling over

mr_badger
12-20-2006, 02:53 PM
No I have not done any of that and wouldn't know how to either, and I'm guessing all the access rights are correct as I can make a successful connection. Just cant see my tables.

davidj
12-20-2006, 03:00 PM
this looks familiar

although its mentioning asp and .net

http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_19515#aspnet_db

There is a _scripts dir in your local. navigate to this and copy it to your live dir

davidj
12-20-2006, 03:09 PM
its called _mmServerScripts

davidj
12-20-2006, 03:20 PM
also try and delete your site definitions then re-define them
after you have deleted the definition then delete the _mmServerScripts directory befor you set them up again

clutching at straws here

mr_badger
12-24-2006, 05:53 PM
I have done everything you have suggested but still I cant see my tables.
I was wondering if the tables were not done properly that they might not show up?

davidj
12-24-2006, 10:03 PM
try setting them up using EMS MYSQL Manager

http://www.sqlmanager.net/products/mysql/manager

you need the lite free version

mr_badger
12-27-2006, 04:27 PM
Thankyou so much, everything is now working. I can see my tables and I can now work with them in dreamweaver. The SQL manager has seemed to have done the trick.

One more question. What do I need to upload to the webserver for it to work live.

davidj
12-27-2006, 07:04 PM
you can connect your EMS MYSQL Manager to the live MYSQL db and just export the database from your local to your live

remember with mysql you cant just copy the database over like you could with access.

mr_badger
01-02-2007, 07:59 PM
I have finished everything that I wanted to but now I'm getting this error mysql_query(): supplied argument is not a valid MySQL-Link resource in (my wamp server) on line 90.
I have checked for spelling mistakes and there isn't any, what could be the problem?

davidj
01-02-2007, 09:02 PM
are you getting any results back even though your getting the error

mr_badger
01-03-2007, 11:30 AM
On some occasions I was getting a error of a duplicate entry of '0'? but on other occasions I wasn't getting any results.

davidj
01-03-2007, 11:33 AM
post your code

mr_badger
01-03-2007, 12:04 PM
<?php require_once('Connections/Restaurant.php'); ?>

<?php

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;



switch ($theType) {

case "text":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "long":


case "int":

$theValue = ($theValue != "") ? intval($theValue) : "NULL";

break;

case "double":

$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";

break;

case "date":

$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

break;

case "defined":

$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

break;

}



return $theValue;


}

$editFormAction = $_SERVER['PHP_SELF'];

if (isset($_SERVER['QUERY_STRING'])) {

$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);

}




if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

$insertSQL = sprintf("INSERT INTO tblbookings (tableID, bookingDate, bookingName, bookingPhone, bookingEmail) VALUES (%s, %s, %s, %s, %s)",

GetSQLValueString($_POST['tableID'], "int"),

GetSQLValueString($_POST['bookingDate'], "date"),

GetSQLValueString($_POST['bookingName'], "text"),

GetSQLValueString($_POST['bookingPhone'], "text"),

GetSQLValueString($_POST['bookingEmail'], "text"));



mysql_select_db($database_Restaurant, $Restaurant);

$Result1 = mysql_query($insertSQL, $Restaurant) or die(mysql_error());

$deleteSQL = "DELETE FROM tblAvailability WHERE availID = ". addslashes($_POST['availID']);

$Result_del = mysql_query($deleteSQL, $restaurant) or die(mysql_error());




$insertGoTo = "bookingthankyou.php";

if (isset($_SERVER['QUERY_STRING'])) {

$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";

$insertGoTo .= $_SERVER['QUERY_STRING'];


}
header(sprintf("Location: %s", $insertGoTo));


}

$colname_rsBooking = "1";

if (isset($_POST['availID'])) {

$colname_rsBooking = (get_magic_quotes_gpc()) ? $_POST['availID'] : addslashes($_POST['availID']);

}


mysql_select_db($database_Restaurant, $Restaurant);

$query_rsBooking = sprintf("SELECT* FROM tblAvailability, tblTables WHERE tblAvailability.tableID = tblTables.tableID AND availID = %s", $colname_rsBooking);

$rsBooking = mysql_query($query_rsBooking, $Restaurant) or die(mysql_error());

$row_rsBooking = mysql_fetch_assoc($rsBooking);

$totalRows_rsBooking = mysql_num_rows($rsBooking);

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Confirm your booking :::::: Via</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-color: #CC0000;
}
.style1 {
font-size: 18px;
color: #FFFFFF;
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
}
.style2 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
.style4 {color: #FFFFFF}
-->
</style></head>

<body>
<p class="style1">Confirm your booking</p>

<p class="style2">Your booking details are listed below. Click Confirm to make your table reservation.</p>
<form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>">
<p class="style2 style4">You have booked table number <strong><?php echo $row_rsBooking['tableNumber']; ?></strong> for the time <strong><?php echo $row_rsBooking['availSlot']; ?></strong> on<br />
<strong><?php echo $row_rsBooking['availDate']; ?></strong>. This table is for <strong><?php echo $row_rsBooking['tablePlaces']; ?></strong> people.</p>
<p>


<input name="availID" type="hidden" id="availID" value="<?php echo $row_rsBooking['availID']; ?>" />


<input name="tableID" type="hidden" id="tableID" value="<?php echo $row_rsBooking['tableID']; ?>" />


<input name="bookingDate" type="hidden" id="bookingDate" value="<?php echo $row_rsBooking['availDate']; ?>" />
<input name="hiddenField" type="hidden" value="<?php echo $row_rsBooking['availSlot']; ?>" />


<input name="bookingName" type="hidden" id="bookingName" value="<?php echo $_POST['bookingName']; ?>" />


<input name="bookingEmail" type="hidden" id="bookingEmail" value="<?php echo $_POST['bookingEmail']; ?>" />


<input name="bookingPhone" type="hidden" id="bookingPhone" value="<?php echo $row_rsBooking['tableNumber']; ?>" />
</p>
<p>
<label>
<input name="Submit" type="submit" class="style2" value="Confirm" />
</label>
</p>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p class="style2">&nbsp;</p>
</body>
</html>
<?php

mysql_free_result($rsBooking);

The error is line 90.

davidj
01-03-2007, 12:28 PM
ok i have looked through it

i get very dissapointed when i see dreamweaver code. Its like cracking nuts with a sledge hammer.

if you give my tutorials a try you will find it much easier to understand and you will then be writing code intead of pushing buttons to write the code.

ok

the error your getting is really a warning which can be suppressed by adding an @ before the function so

mysql_query():

becomes

@mysql_query():

davidj
01-04-2007, 07:42 AM
if you would like i could rewrite your code (the page that you pasted) and show you just how better it could be

mr_badger
01-07-2007, 01:59 PM
If you wouldn't mind rewriting my code please do, the easier the better. What would you recommend for writing php code?

davidj
01-07-2007, 02:29 PM
i use dreaweaver but 100% in code view

i am allergic to wizards and i dont mean the pointy hat type

davidj
01-07-2007, 02:46 PM
<?php
require_once('Connections/Restaurant.php');
$tableID = $_POST['tableID'];
$bookingDate = $_POST['bookingDate'];
$bookingName = $_POST['bookingName'];
$bookingPhone = $_POST['bookingPhone'];
$bookingEmail = $_POST['bookingEmail'];

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO tblbookings (tableID, bookingDate, bookingName, bookingPhone, bookingEmail) VALUES (%s, %s, %s, %s, %s)", $tableID, $bookingDate, $bookingName, $bookingPhone, $bookingEmail);
mysql_select_db($database_Restaurant, $Restaurant);
$Result1 = mysql_query($insertSQL, $Restaurant) or die(mysql_error());

$deleteSQL = "DELETE FROM tblAvailability WHERE availID = ". addslashes($_POST['availID']);
$Result_del = mysql_query($deleteSQL, $Restaurant) or die(mysql_error());

header(sprintf("Location:bookingthankyou.php");

}
$colname_rsBooking = "1";
$colname_rsBooking = $_POST['availID'];

mysql_select_db($database_Restaurant, $Restaurant);
$query_rsBooking = sprintf("SELECT* FROM tblAvailability, tblTables WHERE tblAvailability.tableID = tblTables.tableID AND availID = %s", $colname_rsBooking);
$rsBooking = mysql_query($query_rsBooking, $Restaurant) or die(mysql_error());
$row_rsBooking = mysql_fetch_assoc($rsBooking);
$totalRows_rsBooking = mysql_num_rows($rsBooking);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Confirm your booking :::::: Via</title>
</head>
<body>
<p class="style1">Confirm your booking</p>
<p class="style2">Your booking details are listed below. Click Confirm to make your table reservation.</p>
<form id="form1" name="form1" method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<p class="style2 style4">You have booked table number <strong><?php echo $row_rsBooking['tableNumber']; ?></strong> for the time <strong><?php echo $row_rsBooking['availSlot']; ?></strong> on<br />
<strong><?php echo $row_rsBooking['availDate']; ?></strong>. This table is for <strong><?php echo $row_rsBooking['tablePlaces']; ?></strong> people.</p>
<p>


<input name="availID" type="hidden" id="availID" value="<?php echo $row_rsBooking['availID']; ?>" />


<input name="tableID" type="hidden" id="tableID" value="<?php echo $row_rsBooking['tableID']; ?>" />


<input name="bookingDate" type="hidden" id="bookingDate" value="<?php echo $row_rsBooking['availDate']; ?>" />
<input name="hiddenField" type="hidden" value="<?php echo $row_rsBooking['availSlot']; ?>" />


<input name="bookingName" type="hidden" id="bookingName" value="<?php echo $_POST['bookingName']; ?>" />


<input name="bookingEmail" type="hidden" id="bookingEmail" value="<?php echo $_POST['bookingEmail']; ?>" />


<input name="bookingPhone" type="hidden" id="bookingPhone" value="<?php echo $row_rsBooking['tableNumber']; ?>" />
</p>
<p>
<label>
<input name="Submit" type="submit" class="style2" value="Confirm" />
</label>
</p>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p class="style2">&nbsp;</p>
</body>
</html>

mr_badger
01-07-2007, 05:02 PM
Thankyou. That looks alot better and easier to read. I will try your tutorials and see how I go.