
Drummin
Members-
Posts
1,004 -
Joined
-
Last visited
Everything posted by Drummin
-
See if this works for you. I added the closing } on line 12 and changed ++$i to $i++ <div style="float:left;width:110px;"> <?php $i = 0; if (count($images) == 0) { ?> <li>No uploaded images found</li> <?php } else foreach ($images as $id => $filename) { ?> <table cellpadding="10px"><tr><td> <a href="view.php?id=<?php echo $id ?>"> <img src="view.php?id=<?php echo $id ?> " width="100" height="100"/> </a><br /> </tr></td> </table> <?php } if(($i++ % == 0) { echo '</div><div style="float:left;width:110px;">'; } //if the current incremented value of $i, divided by 8, has a remainder of 0, write a new division.?>
-
Don't use short tags <? Personally I don't bracket my string values. To each his own. VALUES('$firstname', '$lastname', '$sex', '$notes', '$date_started')
-
Thanks for your help and advice.
-
Can users (name and password) be created via a php script? The idea is for new organizations (after approval) to automatically have their DB created, tables added and needed files copied making the program I've created duplicate. The only stumbling block has been actually making the DB. It would seem "user and password" should be unique for each "client" but a preset user could work I suppose. Any thoughts?
-
Line 11 is $link = mysql_connect($dbhost, $user, $password);
-
I was hoping to use a script to create a database with a script for a project. I've tried several variations of this without success. Any Ideas? Thanks. $dbhost='localhost'; $user='dbuser'; $password='mypassword'; $dbname='test'; $link = mysql_connect($dbhost, $user, $password); if (!$link) { die('Could not connect: ' . mysql_error()); } $sql = "CREATE DATABASE $dbname"; if (mysql_query($sql, $link)) { echo "Database $dbname created successfully\n"; } else { echo 'Error creating database: ' . mysql_error() . "\n"; }
-
Are you getting results from your query? You already have your GET value turned into a variable so I would use it for the query if query results are not being obtained. $query = "SELECT fc_date, fc_speakers, fc_text, fc_topics, fc_refdel FROM tblfedconvn WHERE fc_id=$fc_id";
-
You are using ?id not fc_id for the GET
-
session_start() needs to be called before any output is sent to the browser in each and every script that will make use of the $_SESSION array. I totally respect your knowledge Pikachu2000 as you certainly know more than I do. I however have never used a session start tag except on my login page, and then call upon these session variables in different areas of my site, i.e. $id=session('id'); etc. Yes this happens before the page is sent to the browser. I would imagine that if a session variable needed to be changed, I might need to add the session start on the page making this change, though I'm not sure why as session start is already been called when the user logged in. Anyway, I will keep that in mind should the need arise.
-
I would think you need to use substring to get first letter. Hey what do I know. $sql="SELECT id, f_name, l_name FROM user WHERE f_name LIKE SUBSTRING('$letter',0,1) OR l_name LIKE SUBSTRING('$letter',0,1)";
-
You mentioned you have session start at the top of each page. You should only call this one time, probably on the login-form.php page where the user logs in.
-
You might give this a go. mysql_query("UPDATE table SET column1='$_POST[txt1_$j]', column2='$_POST[txt2_$j], column3='$_POST[txt3_$j]' WHERE ID = '$k'") or die(mysql_error());
-
I would think you could add a css class to the input field. Note that styling buttons might look different in different browsers. Css might look something like this. .button { text-align:center; font-size:12px; width:90px; height:20px; padding:0; margin:0; background:#fff url('images/Button.gif') no-repeat; color:#000; } .babybutton:hover { text-align:center; font-size:12px; width:90px; height:20px; padding:0; margin:0; background:#fff url('images/Buttonhover.gif') no-repeat; color:#87CEFA; cursor: hand; }
-
In case you don't have log in and sessions working you can try this. <?php require_once 'database.php'; $username = mysqli_real_escape_string($_POST['user']); $queryA = "SELECT ID,level FROM user WHERE username = '".$username."' AND password = '".$_POST['pass']."'"; $resultA = mysql_query($queryA); $query_dataA = mysql_fetch_row($resultA); IF (!$query_dataA[0]) { $error = "You have submited an incorrect login and password combination. Please try again...."; } ELSE { session_start(); $_SESSION['user_id']=$query_dataA[0]; $_SESSION['level']=$query_dataA[1]; IF ($_SESSION['level']==1){ header("location:indexn.php"); } IF ($_SESSION['level']==9){ header("location:indexa.php"); } } //Assuming this is part of the login page echo error within content IF (isset($error)) { echo "<p><b>$error</b>"; } You can then pick up the user ID at the top of any page which you can use for query's etc. $userID=$_SESSION['user_id']; This might at least help sort out the user id issue. Not sure if the space around your equals sign might have been giving you problems as well so I tightened them up below. mysql_query(" UPDATE studenti SET $kol='$k1D' WHERE ID=$userID");
-
Looks like this line might be killing it because unexpected T_STRING. $email_message .= "Last Name: ".clean_string($last name)."\r\n"; Notice, $last name should be $last_name
-
From what I see, you are starting the session on the page login_process.php and so the session should start on this page before setting a session and not "started" on any other pages. if($user == $row['username'] && MD5($pass) == $row['password']) { session_start(); $_SESSION['level'] = $row['level']; header('Location:http://localhost/index.php'); } else { echo 'Wrong username or password.';} After the redirect to index.php you should be able to "pick up" that session and use the info, as in $level=$_SESSION['level'];
-
The mysql_real_escape_string is working just fine (after I added my DB connection), though the logic of your forms might be misleading. Add print post to your page to make sure the form names you think are being sent are actually the one's being sent, in other words looking for "new_text" and not "questiontext" or "new_question". It worked fine for me once I figured out which form to use. print_r($_POST) ;
-
Can you directly put an image name in this line and see the picture? Maybe it's a path problem. echo = "<img src=$path"."imagename".".png"." border=\'0\'>";
-
Try $random = rand(1, $images);
-
I think you should wrap each in its own IF statement. IF ($_POST['sezonaSubmit']){ if(isset($_POST['sezonaSubmit'])){ $_SESSION['sezona'] = $_POST['sezona']; } else { $_SESSION['sezona'] = "Letnja Guma"; } }//end if $_POST['sezonaSubmit'] $sezona = $_SESSION['sezona']; IF ($_POST['poredak']){ if(isset($_POST['poredak'])){ $_SESSION['poredak'] = $_POST['red']; } else { $_SESSION['poredak'] = " ORDER BY price ASC"; } }//end if $_POST['poredak'] $order = $_SESSION['poredak'];
-
Simple php form question - How to redirect to page after submit?
Drummin replied to emerson5000's topic in PHP Coding Help
Looks like you're putting the redirect inside you email message. Put it in place of the "Your messages was sent" line. <? $subject="from ".$_GET['name']; $headers= "From: ".$_GET['email']; $headers.=$_GET['phone']. "\n"; $headers.='Content-type: text/html; charset=iso-8859-1'; mail("[email protected]", $subject, " " ."Name: " .$_GET['name']." " ."Phone: " .$_GET['phone']." " ."Email: " .$_GET['email']." " ."Message: " .$_GET['message']." </body> </html>" , $headers); header("location: http://www.company.com/index.html"); ?> -
Simple php form question - How to redirect to page after submit?
Drummin replied to emerson5000's topic in PHP Coding Help
header("location:mypage.php"); -
"Only variables can be passed by reference"
Drummin replied to AnAmericanGunner's topic in PHP Coding Help
I'm no expert at arrays, but I think if you print_r($variable); you'll see pointers. something like [0] => 1, [1] =>5 etc. And I believe you'll need to access these variables by called or "referencing" the pointer. Maybe this would work. $variable = array("1", "5", "10", "15", "20"); print_r($variable); -
Editable form using php variables - textarea
Drummin replied to twilitegxa's topic in PHP Coding Help
As it's more than likely being saved to "text" database field you should use mysql_real_escape_string() to escape input before adding to DB as already suggested. -
restricting user to certain data in a database?
Drummin replied to sudduth66's topic in PHP Coding Help
See if this works for you mysql_connect ("localhost", "****","*******") or die (mysql_error()); mysql_select_db ("Customers"); mysql_select_db ("Client"); $term = $_POST['term']; $sql = mysql_query("SELECT * FROM storage WHERE box_number = '$term' AND member.Client_ID = storage.Client_ID "); if (mysql_num_rows($sql) > 0) { while ($row = mysql_fetch_array($sql)) { echo "box_num: ".$row['box_number'].""; echo "<br/> dept: ".$row['Department'].""; echo "<br/> company: ".$row['Company'].""; echo "<br/> status: ".$row['status'].""; echo "<br/> location: ".$row['location'].""; echo "<br/> description: ".$row['box_desc'].""; } } else { echo "No Boxes available please use your back button to select a new box."; }