close ad
WARNING PC USERS: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

SQL Syntax (Errors Using MySQL 5.0 Language PHP)

Thread began 10/17/2009 4:30 pm by pipwax1390564 | Last modified 10/20/2009 8:03 pm by pipwax1390564 | 3674 views | 14 replies |

pipwax1390564

SQL Syntax (Errors Using MySQL 5.0 Language PHP)

The Sql fail to submit. This is what I get when I test the page "SELECT * FROM employeelookup 0" I made this change to the code so that I can see the information
===========modified code===========
$query_Members = sprintf("SELECT * FROM employeelookup %s", GetSQLValueString($WhereParam_Members, "int"));
echo $query_Members;
exit;
$Members = mysql_query($query_Members, $Recipes) or die(mysql_error());
$row_Members = mysql_fetch_assoc($Members);
$totalRows_Members = mysql_num_rows($Members);
?>
=============end modified code==============

======================entire code=================
<?php require_once('../../Connections/Recipes.php'); ?>
<?php
mysql_select_db($database_Recipes, $Recipes);
$query_EmployeeLookup = "INSERT INTO employeelookup SELECT employees_1.EmployeeID, jobs.JobID, jobs.JobTitle, employees_1.EmployeeFirst, employees_1.EmployeeLast, departments.DepartmentName, CONCAT(employees.EmployeeFirst,' ',employees.EmployeeLast) AS ManagerName, employees_1.EmployeeEmail, employees_1.EmployeePhone, employees_1.EmployeeMobil, employees_1.EmployeeCube FROM employees, employees employees_1, jobs, jobs jobs_1, departments WHERE ((((jobs.JobTypeID = jobs_1.JobID) AND (jobs.JobDepartment = departments.DepartmentID)) AND (employees.EmployeeJob = jobs_1.JobID)) AND (employees_1.EmployeeJob = jobs.JobID))";
mysql_query($query_EmployeeLookup,$Recipes);
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($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;
}
}

$WhereParam_Members = 'Where MemberID <> 0';
if (isset($WhereParam)) {
$WhereParam_Members = $WhereParam;
}
mysql_select_db($database_Recipes, $Recipes);
$query_Members = sprintf("SELECT * FROM employeelookup %s", GetSQLValueString($WhereParam_Members, "int"));
echo $query_Members;
exit;
$Members = mysql_query($query_Members, $Recipes) or die(mysql_error());
$row_Members = mysql_fetch_assoc($Members);
$totalRows_Members = mysql_num_rows($Members);
?><?php
$query_EmployeeLookup = "DELETE FROM employeelookup";
mysql_query($query_EmployeeLookup,$Recipes);
?>
======================end====================
Any help would be greatly helpful

Sign in to reply to this post

Jason ByrnesWebAssist

Why are you putting the where clause into a parameter for the members recordset?

The way I see it, the where clause will not change, right? parameters are used for variable data. data that may change.

why not just hard code the where clause with the select statement:

SELECT * FROM employeelookup Where MemberID <> 0

Sign in to reply to this post

pipwax1390564

To the best of my knowledge i was following the instructions from the book. (Web application recipes) I just added the members table because I wanted to use thr module for a members system to a web community. However, when I think about it I only had to change the html lables?

Sign in to reply to this post

Jason ByrnesWebAssist

The problem is the way the members recordset is created.


Do not use a parameter, just add the where clause directly in the SQL:
SELECT * FROM employeelookup Where MemberID <> 0

Sign in to reply to this post

pipwax1390564

I am still learning this stuff, I am not sure where I would need to alter the code. Could you help me out? I am using Dreamweaver. My best guess is to double click the recordset and remove the Param and enter the Sql statement you gave me.

Sign in to reply to this post

Jason ByrnesWebAssist

that is correct.

Double click the recordset, remove the parameter and add the where clause directly to the SQL statement.

Sign in to reply to this post

pipwax1390564

Made Great progress these are the errors I am getting Now:

Warning: mysql_select_db(): supplied argument is not a valid MySQL-Link resource in /home/content/p/i/p/pipwax2/html/test/member_results.php on line 3

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/content/p/i/p/pipwax2/html/test/member_results.php on line 5

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/content/p/i/p/pipwax2/html/test/member_results.php on line 44


Here is Line 3:mysql_select_db($database_Recipes, $Recipes);
Here is Line 5:mysql_query($query_EmployeeLookup,$Recipes);
Here is Line 44:mysql_query($query_EmployeeLookup,$Recipes);

My best guess is that $query_EmployeeLookup should be $query_employeeLookup because the table in mysql is emlpoyeelookup but that did not work.

Sign in to reply to this post

pipwax1390564

My database connection is newsfeed

could this be my problem?
Line 3:mysql_select_db($database_Recipes, $Recipes);
the database name is DavidPippen

Sign in to reply to this post

Jason ByrnesWebAssist

Did you edit the "Connections/Recipes.php" file by hand?


On the database tab, double click the recipes connection and click the test button. Does the connection test correctly?


Please send a copy of the Connections/Recipes.php file.

Sign in to reply to this post

pipwax1390564

I will when I get home

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...