network18 15 Practically a Master Poster
$query = "INSERT INTO booking  
            (firstname, 
            address1, 
            days, 
            months, 
            bookingtime, 
            address2, 
            lastname, 
            cdays, 
            cmonths, 
            duration, 
            datefrom, 
            dteCallTimeTo, 
            meettype, 
            county, 
            cnumber', 
            fee, 
            pcode, 
            comments, 
            user_id
            ) values ('$firstname', 
            '$address1', 
            '$days', 
            '$months', 
            '$bookingtime', 
            '$address2', 
            '$lastname', 
            '$cdays', 
            '$cmonths', 
            '$duration', 
            '$datefrom', 
            '$dteCallTimeTo', 
            '$meettype', 
            '$county', 
            '$cnumber', 
            '$fee', 
            '$pcode', 
            '$comments', 
            '$userid')";

you were mixing insert and update syntax.

network18 15 Practically a Master Poster

if the checkboxes are not checked they wont appear in the $_POST superglobal.
Try to print your post data like print_r($_POST) and you would know the reason.

network18 15 Practically a Master Poster

Hi,
Needs to construct the tables with the meta info retrived by another stored procedure I wrote, given the table id or name.
There could be some flaws in the logic, not sure.
The flow is -
- iterate through one table which stores tbl name, id info
- pass above info to sp which would return meta info to calling cursor as result set
- store this result set into temp tbl so that another cursor can iterate through them, to construct "create table query" as a string
- end inner cursor
- execute the concatenated string query
- end main or outer cursor

It looks like below -

CREATE PROCEDURE CREATE_TBL
@tbl_id INT
AS
DECLARE @res nvarchar(200) 
select mcol.NEW_COL, col.DATA_TYPE, col.COLUMN_DEFAULT, col.IS_NULLABLE, col.CHARACTER_MAXIMUM_LENGTH size--, mcol.TBL_ID
from seminator.INFORMATION_SCHEMA.COLUMNS col 
inner join MAPPING_TBL mtbl
on col.TABLE_NAME = mtbl.OLD_TBL collate Latin1_General_CI_AS
inner join MAPPING_COL mcol
on col.COLUMN_NAME = mcol.OLD_COL collate Latin1_General_CI_AS and mcol.TBL_ID = mtbl.ID
where mtbl.ID = @tbl_id
 order by COLUMN_DEFAULT

 GO
-- 


CREATE TABLE #plan(
    NEW_COL varchar(40) NOT NULL,
    DATA_TYPE [varchar](30) NULL,
    COLUMN_DEFAULT [varchar](15) NULL,
    IS_NULL [varchar](10) NULL,
    SIZE [varchar](30) NULL
)
GO



Declare @query varchar(5000)
Declare @tbl_id int
Declare c Cursor For SELECT ID FROM MAPPING_TBL where old_tbl = 'ADRESSE'
Open c

Fetch next From c into @tbl_id

While @@Fetch_Status=0 Begin
   --do operations using this current tbl name
   SET @query = 'CREATE TABLE TBL'
   INSERT INTO #plan EXEC CREATE_TBL @tbl_id
   --select * from #plan
   -------------------------2nd
Declare @col varchar(50)
network18 15 Practically a Master Poster

post your code here, use code tags

network18 15 Practically a Master Poster

So here is the html for our first step -

<!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>Untitled Document</title>
<style type="text/css"  >
.tableclass{
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
font-weight:bold;
font-style:inherit;
}
.td-class{
color:#FFFFFF;
background-color:#666666;
}
</style>
</head>

<body>
<table class="tableclass" width="200">
  <tr>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
  </tr>
  <tr>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
  </tr>
  <tr>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
  </tr>
  <tr>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
  </tr>
  <tr>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
    <td class="td-class">&nbsp;word</td>
  </tr>
</table>

</body>
</html>
network18 15 Practically a Master Poster

Hi everyone, I've been a reader for a long time, now I've joined up, as I'm fairly stumped on this one!!

I'm currently teaching myself mysql and php at work, and have a problem. I am using php to produce a listing of restaurants on a page, and I would like to do the following at the end of each line:

1) If the website field is not blank, display the url (or even just "Website")

2) Make the URL Clickable, and open in a new window.

I've managed to produce the list, however my code has gone south somewhere as the "website" field is displaying even when there is no entry in the database. Also when the link is present it's clickable, but opening in the same window. Can someone help me and tell me where I've gone wrong?

<?php
					mysql_connect(HOST,USER,PASS);
@mysql_select_db("db303278079") or die( "Unable to select database");
$query="
SELECT * FROM restaurants";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$rest_name=mysql_result($result,$i,"rest_name");
$address=mysql_result($result,$i,"address");
$telephone=mysql_result($result,$i,"telephone");
$website=mysql_result($result,$i,"website");
$cuisine_type=mysql_result($result,$i,"cuisine_type");
$area=mysql_result($result,$i,"area");
echo "<strong>$rest_name</strong>, $address, $telephone, ($cuisine_type), $area, <A HREF=$website>'Website'</a><br >";
$i++;
}
?>

Thanks in advance for your help :)

line7

mysql_numrows()

should be

mysql_num_rows()

and the mysql_close() better to put at the end of the script.
Also check if website is a valid url first, if its not opening properly

dmkc commented: thanks for the help, really shows me where I'm going wrong, much appreciated!! :) +0
network18 15 Practically a Master Poster

Ardav@ I like the setlocale solution, but Em not really looking for a date translator. I really appreciate the scripts you've made, It might be useful when I get my website up.

At the moment I'm learning, the "days" could be "fruits". It doesn't matter. I just wanted to get the function working.

Ardav those scripts above doesn't work ><< Might just be my host. I try another host tomorrow.
Thanks for the help, I really appreciate it =)

The script in your #post 8 is modified as below, I am sure it will work for you -

<?php
//nodag = Norwegian day
//endag = English Day
// dag = day\

if(!isset($_GET['ok'])) { //start if
?>
<form action="" method="get">
<select name="lan">
	<option value="eng">English</option>
	<option value="no">Norsk</option>
	</select>
<input type="submit" name="ok" value="Ok">
</form>
<?php
}// end if
elseif(isset($_GET["lan"]) && $_GET["lan"] == "no") { //start elseif
	$norwegian_days = array("Monday"=>"Mandag","Tuesday"=>"Tirsdag","Wednesday"=>"Onsdag","Thursday"=>"Torsdag","Friday"=>"Fredag","Saturday"=>"Lordag","Sunday"=>"Sondag");
	$endag = date("l");
	$nodag = $norwegian_days[$endag];
echo $nodag;
} // end elseif
elseif(isset($_GET["lan"]) && $_GET["lan"] == "eng") { // start else
	$endag = date("l");
echo $endag;
}// end else
?>

Hope you noticed the small change

nav33n commented: Darn! I totally missed the == in my post. Good work! +5
Muazam commented: Very helpful +1
network18 15 Practically a Master Poster

Hey people,
I am doing a project in web development and I wanted to make a system where users can sign up and login to their profiles and have custom URLs like facebook or twitter (www.mysite.com/UserName).
I dont wanna create a folder for every user on the system cuz that's a stupid thing to do :)

Hope you can help :)
thnx in advance

search for the .htaccess
using it you can rewrite your urls after login from www.mysite.com?userId=9 to something like -
www.mysite.com/username

network18 15 Practically a Master Poster

@leviathan185: You can definitely use the strings as the cases inside switch()
@Mauzam : need brak after the case sunday and the syntax after the case is wrong, need to use the 'COLONS (i.e. :)' instead of ';'
your improved switch() below -

switch($endag) { // start switch
	case "Monday":
	$nodag = "Mandag";
	break;
	case "Tuesday":
	$nodag = "Tirsdag";
	break;
	case "Wednesday":
	$nodag = "Onsdag";
	break;
	case "Thursday":
	$nodag = "Torsdag";
	break;
	case "Friday":
	$nodag = "Fredag";
	break;
	case "Saturday":
	$nodag = "Lordag";
	break;
	case "Sunday":
	$nodag = "Sondag";
	break;
	default:
	$nodag = "ERROR";
	} // end switch

I did not check with the rest of your code yet,i assume the rest is fine.

network18 15 Practically a Master Poster
hi how can i make a drop down menu usibg java script.... please help its urgent

use html to code the drop down menu , use ajax based fill up of elements in the drop down from some other ajax page in order not to refresh the page.

network18 15 Practically a Master Poster

mysql_real_escape_string()

network18 15 Practically a Master Poster

you can have a look at this for reference.
It will involve creating the API which will link to your database also depending upon the user key(but i think no need to customize it on user basis, because all users will see the public events only in the embeded calendar) to fetch the public events apart from the html it will provide to render the calendar on the webpage.

network18 15 Practically a Master Poster

yeah that should help me take off... bt as i stated earlier a user can view his own events as well as of others in same group who have shared an event...
I can think of an addition ie with user id we can save group id of an event, in case the user wishes to share it with the group and while displaying we can check if user's own group id matches with event's group id..
what do u say??

its good. see you just needed a little push and now you can fly yourself :)

network18 15 Practically a Master Poster

Hi all,

Since its been a while now that i am learning php I undertook a project to develop event calendar in php and mysql. There will be a public calendar published on site which every1 can view. Then as a user logs in he will have his own personal calendar in which he can publish events and share with either a specific group or make it public.

any suggestions to start up with??
especially m pretty confused for DB structure that will help me accomplish this...

You can have below table structure -

event_id int(2) not null,
event varchar(30) not null,
event_date date ,
entry_date datetime,
user_id int(2) referes to the usermaster table.
and while displaying the calendar check this table for any event available (for the particular user ,this to be done if the user sees only his events only) for that particular date.

network18 15 Practically a Master Poster

Table Inventory:

user_id | weapon_id | armor_id | etc_items
-------- -+---------------+------------+------------
............ | ................. | .............. | this is the important part

How would you store multiple things or items in that spot for just one user?

No need to do it that way, you can save all the etc_items for one particular user some other table which refers your primary table's key; even though you can save all the items for single user in just one column with comma seperated values.

network18 15 Practically a Master Poster

Do what adatapost says above and use your improved code below -

<?
if (isset($_POST[submit]))
{ 

	foreach($uploadArray as $file)
	{  
		//This is the directory where images will be saved
		$target = "orders/";
		$target = $target . basename( $_FILES[$file]['name'] );
		
		$arr_allowed_types = array("image/gif","image/jpg","image/jpeg","image/pjpeg");
		
		if(	in_array($_FILES[$file]["type"],$$arr_allowed_types) && $_FILES[$file]["size"] < 5000000)
		{ 
			if(move_uploaded_file($_FILES[$file]['tmp_name'], $target)) 
			{   
				// redirect to upload success url
				header('Location: ' . SUCCESS_URL);
			}	
			else 
			{
				echo "Sorry, there was a problem uploading your file.";
			}
		
		}
		else
		{
		  echo "Invalid file";
		}
	
	} 
}
?>
kvprajapati commented: Great! +6
network18 15 Practically a Master Poster

your syntax for the else is wrong, it should not have been square brackets there.
your code below -

if(isset($_POST['log']))
{
	$username = $_POST['username'];
	$pass = $_POST['passd'];
	
	include("connectOrder.php");
	$sql = "SELECT * FROM users WHERE user_name='$username' AND password = '$pass' AND access_level != 0";
	mysql_query($sql);
	$num=mysql_num_rows($sql);
	if($num == 1)
	{
		session_start();
		
		$_SESSION["user_id"]=$row_sqllog["user_id"];
		$_SESSION["username"]=$row_sqllog["user_name"];
		header ("Location: order.php");
	}
	else
	{
		header ("Location: login.php?login=wrong");
	}

}

Also make sure the filepath you including is all right and also the same in header.

network18 15 Practically a Master Poster

#i have try this code for retrieved information from database, everything is ok..and for that case i want to use the id to display the whole of data same as i used <a href="complaint.php"> "this is for example.." but i want that row link to database as an "ID" display for retrieved that row in database..that means the link is the headline to database for that row..#somebody help me....i stuck for this one...

still not much is clear from this english, i guess you want to set the next page as complaint.php which will show different containts for each link you click, and will show the details for that particular id.
If that's the case, just pass the id also to this link's href like -

<a href="complaint.php?id=<? echo $rows['ID']; ?>">

later on in complaint.php you can get this id as $_GET and use it to fetch the data from the database.
I will comment on few more unnecessary things form your code, below -
<form name="form1" method="post" action="<? echo $_SERVER; ?>"> writing $_SERVER in the action will take the page that, but it will contain the url of the same page, so its not needed really it's fine to have action=''

sha09 commented: help me so much +0
network18 15 Practically a Master Poster

i am trying to develop a site.............when i referesh page it gives me the follwoing error
Use of undefined constant admin_mail - assumed 'admin_mail'

i am hosting my site on my home server so i want to set my php.ini so that i didn't get the above error

It may be the case that you unknowingly deleted the '$' in front of the variable 'admin_mail'.
search for it in your script

network18 15 Practically a Master Poster

You got the connection? try this-

$this->User->query("select count(*) from (SELECT user_id FROM `reports` group by report_id) as tb where tb.user_id=5");
network18 15 Practically a Master Poster

Can you be more descriptive about what you expect from php, like what do you mean by 'uild-in function of authentication' ?

network18 15 Practically a Master Poster

please post your script's part, which you think contains an error.

network18 15 Practically a Master Poster
$str = "20px 100% dfsd 10em ";
$test = preg_split('(px|em|pt|%)',$str,-1, PREG_SPLIT_OFFSET_CAPTURE);
//echo '<pre>';
print_r($test);
//echo '</pre>';

This isn't working either...what can be the code for it

network18 15 Practically a Master Poster

hey what you asking is very broad, about developing a complete form, is this a homework problem.
It seems that, you expect somebody to post the complete code for the form you want.
Try google for some with the keywords like 'inventory management form' etc and try to modify the code as par your needs.then post the difficulties you facing here.
This might be the better approach.

network18 15 Practically a Master Poster

Many Internet Service Providers (ISP's) require that you send your username and password before you are allowed to send email. This is called "Authentication" or "SMTP Auth".

More recently, some ISP's have begun to require that you have TWO separate and different login names - one for checking mail and one for sending mail. This is called "SMTP Relay".
So there might be the problem with your smtp server settings, check with it.

network18 15 Practically a Master Poster

The type of table in mySQL will serve a lot of purpose for this :)
ex. innodb or myISAM
innodb provides the lock on row basis instead of that on complete table.
So ur this type of problem might get solved, just have some research for the table types of mysql and probably you can change your database/table structure to implement it.