Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 09-09-2004, 04:22 AM   #1 (permalink)
EdB
Registered User
 
Join Date: Sep 2004
Posts: 1
EdB is on a distinguished road
Help neded with SQL please

Hi,

I have inherited some code that does not work, but I am no SQL programmer. Please could someone help me?

Code:
<?php require_once('Connections/connect.php'); ?>
<?php
mysql_select_db($database_connect, $connect);
$query_cases = "SELECT *, date_format(date, '%D %M %Y') as formatted_casesdate FROM cases WHERE cases.case_id=$cid";
$cases = mysql_query($query_cases, $connect) or die(mysql_error());
$row_cases = mysql_fetch_assoc($cases);
$totalRows_cases = mysql_num_rows($cases);
$prepath="http://www.abcdefghij.com/docs/case/";
?>
Ok, if I load this page I get:
You have an error in your SQL syntax near '' at line 1

If I remove this part of the code:
Code:
or die(mysql_error());
The page loads, it does not work as it supposed to but at least I get something on the page. Can someone explain to me please what this code is doing?

Thanks in advance.
EdB is offline   Reply With Quote
Old 09-09-2004, 06:01 AM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,696
redhead is on a distinguished road
Re: Help neded with SQL please

I took the liberty to move this to PHP section, which I think is more apropriate.
Quote:
Originally posted by EdB
Hi,
I have inherited some code that does not work, but I am no SQL programmer. Please could someone help me?
Code:
<?php require_once('Connections/connect.php'); ?>
This is your line 1, which means it is in the Connections/connect.php your error is.
Quote:
Originally posted by EdB

Ok, if I load this page I get:
You have an error in your SQL syntax near '' at line 1

If I remove this part of the code:
Code:
or die(mysql_error());
The page loads, it does not work as it supposed to but at least I get something on the page. Can someone explain to me please what this code is doing?
Ths line you're talking about isn't even shown in your code segment, it most likely is presented in your Connections/connect.php since you're not showing that, it is very difficult to track down where it fails..
Most likely you're trying a connect call, which fails and the die() is miss placed, so when you remove it you omit the troubled segment of your code, but without your connect script it isn't easy to tell.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
New to SQL and databases rmill9681 Everything SQL ( MySQL, MSSQL, DB2, Postgre, Oracle, etc...) 3 09-09-2004 08:31 AM
SQL Forum Belisarius Feedback 2 06-14-2004 06:16 AM
SQL Server Worm -- Is It Just Me.... technobard Lounge 6 01-30-2003 02:53 PM
loading sql schema from php sde PHP 7 12-11-2002 06:57 PM


All times are GMT -8. The time now is 10:37 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting